From 028689d6bd6de6777166b880840377d7b04abb7a Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Fri, 16 Oct 2020 18:54:48 +0200 Subject: [PATCH] Remove update on add signalling in Axis integration (#41956) Minor clean up of the integration --- homeassistant/components/axis/__init__.py | 2 +- homeassistant/components/axis/binary_sensor.py | 2 +- homeassistant/components/axis/device.py | 8 ++++++++ homeassistant/components/axis/light.py | 2 +- homeassistant/components/axis/switch.py | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/axis/__init__.py b/homeassistant/components/axis/__init__.py index b757f787088..f25348b44cd 100644 --- a/homeassistant/components/axis/__init__.py +++ b/homeassistant/components/axis/__init__.py @@ -49,7 +49,7 @@ async def async_migrate_entry(hass, config_entry): """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) - # Flatten configuration but keep old data if user rollbacks HASS + # Flatten configuration but keep old data if user rollbacks HASS prior to 0.106 if config_entry.version == 1: config_entry.data = {**config_entry.data, **config_entry.data[CONF_DEVICE]} diff --git a/homeassistant/components/axis/binary_sensor.py b/homeassistant/components/axis/binary_sensor.py index dcdf440a472..1881fe887f9 100644 --- a/homeassistant/components/axis/binary_sensor.py +++ b/homeassistant/components/axis/binary_sensor.py @@ -49,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if event.CLASS != CLASS_OUTPUT and not ( event.CLASS == CLASS_LIGHT and event.TYPE == "Light" ): - async_add_entities([AxisBinarySensor(event, device)], True) + async_add_entities([AxisBinarySensor(event, device)]) device.listeners.append( async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor) diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index a22fea23e79..2d1a784dc66 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -77,6 +77,8 @@ class AxisNetworkDevice: """Return the serial number of this device.""" return self.config_entry.unique_id + # Options + @property def option_events(self): """Config entry option defining if platforms based on events should be created.""" @@ -94,6 +96,8 @@ class AxisNetworkDevice: """Config entry option defining minimum number of seconds to keep trigger high.""" return self.config_entry.options.get(CONF_TRIGGER_TIME, DEFAULT_TRIGGER_TIME) + # Signals + @property def signal_reachable(self): """Device specific event to signal a change in connection status.""" @@ -109,6 +113,8 @@ class AxisNetworkDevice: """Device specific event to signal a change in device address.""" return f"axis_new_address_{self.serial}" + # Callbacks + @callback def async_connection_status_callback(self, status): """Handle signals of device connection status. @@ -175,6 +181,8 @@ class AxisNetworkDevice: event = mqtt_json_to_event(message.payload) self.api.event.process_event(event) + # Setup and teardown methods + async def async_setup(self): """Set up the device.""" try: diff --git a/homeassistant/components/axis/light.py b/homeassistant/components/axis/light.py index 3ae15a46244..55c498b8b42 100644 --- a/homeassistant/components/axis/light.py +++ b/homeassistant/components/axis/light.py @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): event = device.api.event[event_id] if event.CLASS == CLASS_LIGHT and event.TYPE == "Light": - async_add_entities([AxisLight(event, device)], True) + async_add_entities([AxisLight(event, device)]) device.listeners.append( async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor) diff --git a/homeassistant/components/axis/switch.py b/homeassistant/components/axis/switch.py index 256a22db114..85a2237fd28 100644 --- a/homeassistant/components/axis/switch.py +++ b/homeassistant/components/axis/switch.py @@ -20,7 +20,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): event = device.api.event[event_id] if event.CLASS == CLASS_OUTPUT: - async_add_entities([AxisSwitch(event, device)], True) + async_add_entities([AxisSwitch(event, device)]) device.listeners.append( async_dispatcher_connect(hass, device.signal_new_event, async_add_switch)