From 4868a779e2c81335efc0911ad5ba3cf4348a2b62 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 1 Jan 2019 23:31:13 +0100 Subject: [PATCH 1/9] Preparing for transition to config flow Added multiple gateway support Reworked parameter flow to platforms to enable multiple controllers Breaking change to config, now a list of gateways is expected instead of a single config --- .../components/binary_sensor/fibaro.py | 8 +-- homeassistant/components/cover/fibaro.py | 8 +-- .../{fibaro.py => fibaro/__init__.py} | 68 +++++++++++++------ homeassistant/components/light/fibaro.py | 8 +-- homeassistant/components/scene/fibaro.py | 4 +- homeassistant/components/sensor/fibaro.py | 8 +-- homeassistant/components/switch/fibaro.py | 8 +-- 7 files changed, 68 insertions(+), 44 deletions(-) rename homeassistant/components/{fibaro.py => fibaro/__init__.py} (89%) diff --git a/homeassistant/components/binary_sensor/fibaro.py b/homeassistant/components/binary_sensor/fibaro.py index 8af2bde10ad050..1934580c58ea32 100644 --- a/homeassistant/components/binary_sensor/fibaro.py +++ b/homeassistant/components/binary_sensor/fibaro.py @@ -9,7 +9,7 @@ from homeassistant.components.binary_sensor import ( BinarySensorDevice, ENTITY_ID_FORMAT) from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice) + FIBARO_DEVICES, FibaroDevice) from homeassistant.const import (CONF_DEVICE_CLASS, CONF_ICON) DEPENDENCIES = ['fibaro'] @@ -33,17 +33,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return add_entities( - [FibaroBinarySensor(device, hass.data[FIBARO_CONTROLLER]) + [FibaroBinarySensor(device) for device in hass.data[FIBARO_DEVICES]['binary_sensor']], True) class FibaroBinarySensor(FibaroDevice, BinarySensorDevice): """Representation of a Fibaro Binary Sensor.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the binary_sensor.""" self._state = None - super().__init__(fibaro_device, controller) + super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) stype = None devconf = fibaro_device.device_config diff --git a/homeassistant/components/cover/fibaro.py b/homeassistant/components/cover/fibaro.py index dc82087f8029fe..d47dbb20315410 100644 --- a/homeassistant/components/cover/fibaro.py +++ b/homeassistant/components/cover/fibaro.py @@ -9,7 +9,7 @@ from homeassistant.components.cover import ( CoverDevice, ENTITY_ID_FORMAT, ATTR_POSITION, ATTR_TILT_POSITION) from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice) + FIBARO_DEVICES, FibaroDevice) DEPENDENCIES = ['fibaro'] @@ -22,16 +22,16 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return add_entities( - [FibaroCover(device, hass.data[FIBARO_CONTROLLER]) for + [FibaroCover(device) for device in hass.data[FIBARO_DEVICES]['cover']], True) class FibaroCover(FibaroDevice, CoverDevice): """Representation a Fibaro Cover.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the Vera device.""" - super().__init__(fibaro_device, controller) + super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) @staticmethod diff --git a/homeassistant/components/fibaro.py b/homeassistant/components/fibaro/__init__.py similarity index 89% rename from homeassistant/components/fibaro.py rename to homeassistant/components/fibaro/__init__.py index d506f6c471d308..a460ba01a2d892 100644 --- a/homeassistant/components/fibaro.py +++ b/homeassistant/components/fibaro/__init__.py @@ -11,8 +11,8 @@ import voluptuous as vol from homeassistant.const import ( - ATTR_ARMED, ATTR_BATTERY_LEVEL, CONF_DEVICE_CLASS, - CONF_EXCLUDE, CONF_ICON, CONF_PASSWORD, CONF_URL, CONF_USERNAME, + ATTR_ARMED, ATTR_BATTERY_LEVEL, CONF_DEVICE_CLASS, CONF_EXCLUDE, + CONF_ICON, CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_WHITE_VALUE, EVENT_HOMEASSISTANT_STOP) from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -24,10 +24,11 @@ _LOGGER = logging.getLogger(__name__) DOMAIN = 'fibaro' FIBARO_DEVICES = 'fibaro_devices' -FIBARO_CONTROLLER = 'fibaro_controller' +FIBARO_CONTROLLERS = 'fibaro_controllers' ATTR_CURRENT_POWER_W = "current_power_w" ATTR_CURRENT_ENERGY_KWH = "current_energy_kwh" CONF_PLUGINS = "plugins" +CONF_GATEWAYS = 'gateways' CONF_DIMMING = "dimming" CONF_COLOR = "color" CONF_RESET_COLOR = "reset_color" @@ -65,7 +66,7 @@ FIBARO_ID_LIST_SCHEMA = vol.Schema([cv.string]) -CONFIG_SCHEMA = vol.Schema({ +GATEWAY_CONFIG = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_USERNAME): cv.string, @@ -77,18 +78,28 @@ }) }, extra=vol.ALLOW_EXTRA) +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Optional(CONF_GATEWAYS, default={}): + vol.All(cv.ensure_list, [GATEWAY_CONFIG]) + }) +}, extra=vol.ALLOW_EXTRA) + class FibaroController(): """Initiate Fibaro Controller Class.""" - def __init__(self, username, password, url, import_plugins, config): + def __init__(self, config): """Initialize the Fibaro controller.""" from fiblary3.client.v4.client import Client as FibaroClient - self._client = FibaroClient(url, username, password) + + self._client = FibaroClient(config.get(CONF_URL), + config.get(CONF_USERNAME), + config.get(CONF_PASSWORD)) self._scene_map = None # Whether to import devices from plugins - self._import_plugins = import_plugins - self._device_config = config[CONF_DEVICE_CONFIG] + self._import_plugins = config.get(CONF_PLUGINS, False) + self._device_config = config.get(CONF_DEVICE_CONFIG, {}) self._room_map = None # Mapping roomId to room object self._device_map = None # Mapping deviceId to device object self.fibaro_devices = None # List of devices by type @@ -200,6 +211,7 @@ def _read_scenes(self): for device in scenes: if not device.visible: continue + device.fibaro_controller = self if device.roomID == 0: room_name = 'Unknown' else: @@ -220,6 +232,7 @@ def _read_devices(self): self.fibaro_devices = defaultdict(list) for device in devices: try: + device.fibaro_controller = self if device.roomID == 0: room_name = 'Unknown' else: @@ -250,25 +263,36 @@ def _read_devices(self): pass -def setup(hass, config): +def setup(hass, base_config): """Set up the Fibaro Component.""" - hass.data[FIBARO_CONTROLLER] = controller = \ - FibaroController(config[DOMAIN][CONF_USERNAME], - config[DOMAIN][CONF_PASSWORD], - config[DOMAIN][CONF_URL], - config[DOMAIN][CONF_PLUGINS], - config[DOMAIN]) + config = base_config.get(DOMAIN) + gateways = config.get(CONF_GATEWAYS) + hass.data[FIBARO_CONTROLLERS] = {} def stop_fibaro(event): """Stop Fibaro Thread.""" _LOGGER.info("Shutting down Fibaro connection") - hass.data[FIBARO_CONTROLLER].disable_state_handler() - - if controller.connect(): - hass.data[FIBARO_DEVICES] = controller.fibaro_devices + for controller in hass.data[FIBARO_CONTROLLERS].values(): + controller.disable_state_handler() + hass.data[FIBARO_CONTROLLERS] = {} + + hass.data[FIBARO_DEVICES] = {} + for component in FIBARO_COMPONENTS: + hass.data[FIBARO_DEVICES][component] = [] + + for gateway in gateways: + controller = FibaroController(gateway) + if controller.connect(): + hass.data[FIBARO_CONTROLLERS][controller.hub_serial] = controller + for component in FIBARO_COMPONENTS: + hass.data[FIBARO_DEVICES][component].extend( + controller.fibaro_devices[component]) + + if hass.data[FIBARO_CONTROLLERS]: for component in FIBARO_COMPONENTS: discovery.load_platform(hass, component, DOMAIN, {}, config) - controller.enable_state_handler() + for controller in hass.data[FIBARO_CONTROLLERS].values(): + controller.enable_state_handler() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro) return True @@ -278,10 +302,10 @@ def stop_fibaro(event): class FibaroDevice(Entity): """Representation of a Fibaro device entity.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the device.""" self.fibaro_device = fibaro_device - self.controller = controller + self.controller = fibaro_device.fibaro_controller self._name = fibaro_device.friendly_name self.ha_id = fibaro_device.ha_id diff --git a/homeassistant/components/light/fibaro.py b/homeassistant/components/light/fibaro.py index 6f2842524a2758..9b3b3850f39ace 100644 --- a/homeassistant/components/light/fibaro.py +++ b/homeassistant/components/light/fibaro.py @@ -12,7 +12,7 @@ from homeassistant.const import ( CONF_WHITE_VALUE) from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice, + FIBARO_DEVICES, FibaroDevice, CONF_DIMMING, CONF_COLOR, CONF_RESET_COLOR) from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_HS_COLOR, ATTR_WHITE_VALUE, ENTITY_ID_FORMAT, @@ -50,14 +50,14 @@ async def async_setup_platform(hass, return async_add_entities( - [FibaroLight(device, hass.data[FIBARO_CONTROLLER]) + [FibaroLight(device) for device in hass.data[FIBARO_DEVICES]['light']], True) class FibaroLight(FibaroDevice, Light): """Representation of a Fibaro Light, including dimmable.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the light.""" self._brightness = None self._color = (0, 0) @@ -81,7 +81,7 @@ def __init__(self, fibaro_device, controller): if devconf.get(CONF_WHITE_VALUE, supports_white_v): self._supported_flags |= SUPPORT_WHITE_VALUE - super().__init__(fibaro_device, controller) + super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) @property diff --git a/homeassistant/components/scene/fibaro.py b/homeassistant/components/scene/fibaro.py index 7a36900f8842df..a0bd4e7ff40ae0 100644 --- a/homeassistant/components/scene/fibaro.py +++ b/homeassistant/components/scene/fibaro.py @@ -9,7 +9,7 @@ from homeassistant.components.scene import ( Scene) from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice) + FIBARO_DEVICES, FibaroDevice) DEPENDENCIES = ['fibaro'] @@ -23,7 +23,7 @@ async def async_setup_platform(hass, config, async_add_entities, return async_add_entities( - [FibaroScene(scene, hass.data[FIBARO_CONTROLLER]) + [FibaroScene(scene) for scene in hass.data[FIBARO_DEVICES]['scene']], True) diff --git a/homeassistant/components/sensor/fibaro.py b/homeassistant/components/sensor/fibaro.py index e5ed5638c5b39f..e437ef8710d64e 100644 --- a/homeassistant/components/sensor/fibaro.py +++ b/homeassistant/components/sensor/fibaro.py @@ -12,7 +12,7 @@ from homeassistant.helpers.entity import Entity from homeassistant.components.sensor import ENTITY_ID_FORMAT from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice) + FIBARO_DEVICES, FibaroDevice) SENSOR_TYPES = { 'com.fibaro.temperatureSensor': @@ -37,18 +37,18 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return add_entities( - [FibaroSensor(device, hass.data[FIBARO_CONTROLLER]) + [FibaroSensor(device) for device in hass.data[FIBARO_DEVICES]['sensor']], True) class FibaroSensor(FibaroDevice, Entity): """Representation of a Fibaro Sensor.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the sensor.""" self.current_value = None self.last_changed_time = None - super().__init__(fibaro_device, controller) + super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) if fibaro_device.type in SENSOR_TYPES: self._unit = SENSOR_TYPES[fibaro_device.type][1] diff --git a/homeassistant/components/switch/fibaro.py b/homeassistant/components/switch/fibaro.py index d3e96646a4580c..8b59aabec722cd 100644 --- a/homeassistant/components/switch/fibaro.py +++ b/homeassistant/components/switch/fibaro.py @@ -9,7 +9,7 @@ from homeassistant.util import convert from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchDevice from homeassistant.components.fibaro import ( - FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice) + FIBARO_DEVICES, FibaroDevice) DEPENDENCIES = ['fibaro'] _LOGGER = logging.getLogger(__name__) @@ -21,17 +21,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return add_entities( - [FibaroSwitch(device, hass.data[FIBARO_CONTROLLER]) for + [FibaroSwitch(device) for device in hass.data[FIBARO_DEVICES]['switch']], True) class FibaroSwitch(FibaroDevice, SwitchDevice): """Representation of a Fibaro Switch.""" - def __init__(self, fibaro_device, controller): + def __init__(self, fibaro_device): """Initialize the Fibaro device.""" self._state = False - super().__init__(fibaro_device, controller) + super().__init__(fibaro_device) self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id) def turn_on(self, **kwargs): From 4dc95eb9575fc613e44c0328d9911ba2a56585bd Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 1 Jan 2019 23:34:03 +0100 Subject: [PATCH 2/9] Updated coveragerc Added new location of fibaro component --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 7ed4746d1fcaa8..c44c15030118bc 100644 --- a/.coveragerc +++ b/.coveragerc @@ -124,7 +124,7 @@ omit = homeassistant/components/eufy.py homeassistant/components/*/eufy.py - homeassistant/components/fibaro.py + homeassistant/components/fibaro/__init__.py homeassistant/components/*/fibaro.py homeassistant/components/gc100.py From ca565fcf32dfd46aa995db7c6fbf15201ad6a190 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Sun, 6 Jan 2019 18:35:31 +0100 Subject: [PATCH 3/9] Fixes based on code review and extended logging Addressed issues raised by code review Added extended debug logging to get better reports from users if the device type mapping is not perfect --- homeassistant/components/fibaro/__init__.py | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index a460ba01a2d892..1f6d3328826b48 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -67,20 +67,18 @@ FIBARO_ID_LIST_SCHEMA = vol.Schema([cv.string]) GATEWAY_CONFIG = vol.Schema({ - DOMAIN: vol.Schema({ - vol.Required(CONF_PASSWORD): cv.string, - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_URL): cv.url, - vol.Optional(CONF_PLUGINS, default=False): cv.boolean, - vol.Optional(CONF_EXCLUDE, default=[]): FIBARO_ID_LIST_SCHEMA, - vol.Optional(CONF_DEVICE_CONFIG, default={}): - vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}) - }) + vol.Required(CONF_PASSWORD): cv.string, + vol.Required(CONF_USERNAME): cv.string, + vol.Required(CONF_URL): cv.url, + vol.Optional(CONF_PLUGINS, default=False): cv.boolean, + vol.Optional(CONF_EXCLUDE, default=[]): FIBARO_ID_LIST_SCHEMA, + vol.Optional(CONF_DEVICE_CONFIG, default={}): + vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}) }, extra=vol.ALLOW_EXTRA) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ - vol.Optional(CONF_GATEWAYS, default={}): + vol.Optional(CONF_GATEWAYS, default=[{}]): vol.All(cv.ensure_list, [GATEWAY_CONFIG]) }) }, extra=vol.ALLOW_EXTRA) @@ -255,10 +253,10 @@ def _read_devices(self): self.hub_serial, device.id) self._device_map[device.id] = device self.fibaro_devices[device.mapped_type].append(device) - else: - _LOGGER.debug("%s (%s, %s) not used", - device.ha_id, device.type, - device.baseType) + _LOGGER.debug("%s (%s, %s) -> %s. Prop: %s Actions: %s", + device.ha_id, device.type, + device.baseType, device.mapped_type, + str(device.properties), str(device.actions)) except (KeyError, ValueError): pass From d07cff5c55a3ae4e3ac5ce59b8efd403d3aa9b1d Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 8 Jan 2019 15:55:45 +0100 Subject: [PATCH 4/9] Changhes based on code review Changes to how configuration is read and schemas Fix to device type mapping logic --- homeassistant/components/fibaro/__init__.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 1f6d3328826b48..604f235617e184 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -78,7 +78,7 @@ CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ - vol.Optional(CONF_GATEWAYS, default=[{}]): + vol.Required(CONF_GATEWAYS): vol.All(cv.ensure_list, [GATEWAY_CONFIG]) }) }, extra=vol.ALLOW_EXTRA) @@ -91,19 +91,19 @@ def __init__(self, config): """Initialize the Fibaro controller.""" from fiblary3.client.v4.client import Client as FibaroClient - self._client = FibaroClient(config.get(CONF_URL), - config.get(CONF_USERNAME), - config.get(CONF_PASSWORD)) + self._client = FibaroClient(config[CONF_URL], + config[CONF_USERNAME], + config[CONF_PASSWORD]) self._scene_map = None # Whether to import devices from plugins - self._import_plugins = config.get(CONF_PLUGINS, False) - self._device_config = config.get(CONF_DEVICE_CONFIG, {}) + self._import_plugins = config[CONF_PLUGINS] + self._device_config = config[CONF_DEVICE_CONFIG] self._room_map = None # Mapping roomId to room object self._device_map = None # Mapping deviceId to device object self.fibaro_devices = None # List of devices by type self._callbacks = {} # Update value callbacks by deviceId self._state_handler = None # Fiblary's StateHandler object - self._excluded_devices = config.get(CONF_EXCLUDE, []) + self._excluded_devices = config[CONF_EXCLUDE] self.hub_serial = None # Unique serial number of the hub def connect(self): @@ -176,12 +176,11 @@ def register(self, device_id, callback): def _map_device_to_type(device): """Map device to HA device type.""" # Use our lookup table to identify device type + device_type = None if 'type' in device: device_type = FIBARO_TYPEMAP.get(device.type) - elif 'baseType' in device: + if device_type is None and 'baseType' in device: device_type = FIBARO_TYPEMAP.get(device.baseType) - else: - device_type = None # We can also identify device type by its capabilities if device_type is None: From 8e4e15770da7552a389bbcc31869c3b85e76365b Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 8 Jan 2019 16:00:43 +0100 Subject: [PATCH 5/9] simplified reading config --- homeassistant/components/fibaro/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 604f235617e184..90a8e562a41b19 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -262,8 +262,7 @@ def _read_devices(self): def setup(hass, base_config): """Set up the Fibaro Component.""" - config = base_config.get(DOMAIN) - gateways = config.get(CONF_GATEWAYS) + gateways = base_config[DOMAIN][CONF_GATEWAYS] hass.data[FIBARO_CONTROLLERS] = {} def stop_fibaro(event): From 48cff007a1c1f793deb5eecf1cf960652bd92618 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 8 Jan 2019 22:58:16 +0100 Subject: [PATCH 6/9] oops oops --- homeassistant/components/fibaro/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 90a8e562a41b19..7c484cfaaf8429 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -286,7 +286,7 @@ def stop_fibaro(event): if hass.data[FIBARO_CONTROLLERS]: for component in FIBARO_COMPONENTS: - discovery.load_platform(hass, component, DOMAIN, {}, config) + discovery.load_platform(hass, component, DOMAIN, {}, base_config[DOMAIN]) for controller in hass.data[FIBARO_CONTROLLERS].values(): controller.enable_state_handler() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro) From 43adef1009184ae28f38bab94e1f1d267f9a0597 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Tue, 8 Jan 2019 23:28:33 +0100 Subject: [PATCH 7/9] grr grr --- homeassistant/components/fibaro/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 7c484cfaaf8429..f756ca127e2d6d 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -286,7 +286,8 @@ def stop_fibaro(event): if hass.data[FIBARO_CONTROLLERS]: for component in FIBARO_COMPONENTS: - discovery.load_platform(hass, component, DOMAIN, {}, base_config[DOMAIN]) + discovery.load_platform(hass, component, DOMAIN, {}, + base_config[DOMAIN]) for controller in hass.data[FIBARO_CONTROLLERS].values(): controller.enable_state_handler() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro) From 417223438e17dd7ef140f4c871746f63e5e6bdc7 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Wed, 9 Jan 2019 22:58:46 +0100 Subject: [PATCH 8/9] change based on code review --- homeassistant/components/fibaro/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index f756ca127e2d6d..44592f1cdf934f 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -287,7 +287,7 @@ def stop_fibaro(event): if hass.data[FIBARO_CONTROLLERS]: for component in FIBARO_COMPONENTS: discovery.load_platform(hass, component, DOMAIN, {}, - base_config[DOMAIN]) + base_config) for controller in hass.data[FIBARO_CONTROLLERS].values(): controller.enable_state_handler() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro) From d541d17f0d264eb6236c009d3412ec692940bf5c Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Thu, 10 Jan 2019 06:41:36 +0100 Subject: [PATCH 9/9] changes based on code review changes based on code review --- homeassistant/components/fibaro/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 44592f1cdf934f..715cc036265f04 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -270,7 +270,6 @@ def stop_fibaro(event): _LOGGER.info("Shutting down Fibaro connection") for controller in hass.data[FIBARO_CONTROLLERS].values(): controller.disable_state_handler() - hass.data[FIBARO_CONTROLLERS] = {} hass.data[FIBARO_DEVICES] = {} for component in FIBARO_COMPONENTS: