Remove update on add signalling in Axis integration (#41956)

Minor clean up of the integration
This commit is contained in:
Robert Svensson 2020-10-16 18:54:48 +02:00 committed by GitHub
parent cb60905415
commit 028689d6bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 4 deletions

View File

@ -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]}

View File

@ -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)

View File

@ -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:

View File

@ -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)

View File

@ -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)