Initial Fibaro HC Climate support (#20256)
* Initial version of climate * initial commit of climate device support * Fixed opmode and fanmode * Cleanup * meh * added back all other components Oops * wider support for thermostats Added one more identifier for thermostats to broaden compatibility * Added even more climate types * Reworked detection mechanism Better support for combined devices * Added additional modes * force visibility on climate * Changed logging of device data * Improved operatingmode support Improved operatingmode support * Updated logic for opmode/fanmode list creation Implemented a universal mapping logic for opmode and fanmode, to make it more widely compatible Improved mapping of Fibaro FGT devices * Lint fixes * bump * Fixes based on code review * Fixes * Moved to fibaro folder * lint inspired cosmetic changes * Mapped all operating modes to existing HA ones Mapped all operating modes to existing HA ones * Improved compatibility with Heatit thermostats Thanks to astrandb for testing, debugging and fixing my code * Changes based on code review Changes based on code review * more fixes based on more code review more fixes based on more code review
This commit is contained in:
1 parent
38f063a158
commit
1a05f7b04d
2 files changed
+325
-17
No files matched your search
@@ -26,20 +26,11 @@ CONF_DIMMING = 'dimming'
|
||||
CONF_GATEWAYS = 'gateways'
|
||||
CONF_PLUGINS = 'plugins'
|
||||
CONF_RESET_COLOR = 'reset_color'
|
||||
|
||||
DOMAIN = 'fibaro'
|
||||
|
||||
FIBARO_CONTROLLERS = 'fibaro_controllers'
|
||||
FIBARO_DEVICES = 'fibaro_devices'
|
||||
|
||||
FIBARO_COMPONENTS = [
|
||||
'binary_sensor',
|
||||
'cover',
|
||||
'light',
|
||||
'scene',
|
||||
'sensor',
|
||||
'switch',
|
||||
]
|
||||
FIBARO_COMPONENTS = ['binary_sensor', 'climate', 'cover', 'light',
|
||||
'scene', 'sensor', 'switch']
|
||||
|
||||
FIBARO_TYPEMAP = {
|
||||
'com.fibaro.multilevelSensor': "sensor",
|
||||
@@ -56,7 +47,11 @@ FIBARO_TYPEMAP = {
|
||||
'com.fibaro.remoteSwitch': 'switch',
|
||||
'com.fibaro.sensor': 'sensor',
|
||||
'com.fibaro.colorController': 'light',
|
||||
'com.fibaro.securitySensor': 'binary_sensor'
|
||||
'com.fibaro.securitySensor': 'binary_sensor',
|
||||
'com.fibaro.hvac': 'climate',
|
||||
'com.fibaro.setpoint': 'climate',
|
||||
'com.fibaro.FGT001': 'climate',
|
||||
'com.fibaro.thermostatDanfoss': 'climate'
|
||||
}
|
||||
|
||||
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
|
||||
@@ -174,6 +169,16 @@ class FibaroController():
|
||||
"""Register device with a callback for updates."""
|
||||
self._callbacks[device_id] = callback
|
||||
|
||||
def get_children(self, device_id):
|
||||
"""Get a list of child devices."""
|
||||
return [
|
||||
device for device in self._device_map.values()
|
||||
if device.parentId == device_id]
|
||||
|
||||
def get_siblings(self, device_id):
|
||||
"""Get the siblings of a device."""
|
||||
return self.get_children(self._device_map[device_id].parentId)
|
||||
|
||||
@staticmethod
|
||||
def _map_device_to_type(device):
|
||||
"""Map device to HA device type."""
|
||||
@@ -229,6 +234,7 @@ class FibaroController():
|
||||
devices = self._client.devices.list()
|
||||
self._device_map = {}
|
||||
self.fibaro_devices = defaultdict(list)
|
||||
last_climate_parent = None
|
||||
for device in devices:
|
||||
try:
|
||||
device.fibaro_controller = self
|
||||
@@ -249,15 +255,26 @@ class FibaroController():
|
||||
self._device_config.get(device.ha_id, {})
|
||||
else:
|
||||
device.mapped_type = None
|
||||
if device.mapped_type:
|
||||
dtype = device.mapped_type
|
||||
if dtype:
|
||||
device.unique_id_str = "{}.{}".format(
|
||||
self.hub_serial, device.id)
|
||||
self._device_map[device.id] = device
|
||||
self.fibaro_devices[device.mapped_type].append(device)
|
||||
_LOGGER.debug("%s (%s, %s) -> %s. Prop: %s Actions: %s",
|
||||
if dtype != 'climate':
|
||||
self.fibaro_devices[dtype].append(device)
|
||||
else:
|
||||
# if a sibling of this has been added, skip this one
|
||||
# otherwise add the first visible device in the group
|
||||
# which is a hack, but solves a problem with FGT having
|
||||
# hidden compatibility devices before the real device
|
||||
if last_climate_parent != device.parentId and \
|
||||
device.visible:
|
||||
self.fibaro_devices[dtype].append(device)
|
||||
last_climate_parent = device.parentId
|
||||
_LOGGER.debug("%s (%s, %s) -> %s %s",
|
||||
device.ha_id, device.type,
|
||||
device.baseType, device.mapped_type,
|
||||
str(device.properties), str(device.actions))
|
||||
device.baseType, dtype,
|
||||
str(device))
|
||||
except (KeyError, ValueError):
|
||||
pass
|
||||
|
||||
|
||||
Reference in new issue
Block a user