mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove update on add signalling in Axis integration (#41956)
Minor clean up of the integration
This commit is contained in:
parent
cb60905415
commit
028689d6bd
@ -49,7 +49,7 @@ async def async_migrate_entry(hass, config_entry):
|
|||||||
"""Migrate old entry."""
|
"""Migrate old entry."""
|
||||||
_LOGGER.debug("Migrating from version %s", config_entry.version)
|
_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:
|
if config_entry.version == 1:
|
||||||
config_entry.data = {**config_entry.data, **config_entry.data[CONF_DEVICE]}
|
config_entry.data = {**config_entry.data, **config_entry.data[CONF_DEVICE]}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
if event.CLASS != CLASS_OUTPUT and not (
|
if event.CLASS != CLASS_OUTPUT and not (
|
||||||
event.CLASS == CLASS_LIGHT and event.TYPE == "Light"
|
event.CLASS == CLASS_LIGHT and event.TYPE == "Light"
|
||||||
):
|
):
|
||||||
async_add_entities([AxisBinarySensor(event, device)], True)
|
async_add_entities([AxisBinarySensor(event, device)])
|
||||||
|
|
||||||
device.listeners.append(
|
device.listeners.append(
|
||||||
async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor)
|
async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor)
|
||||||
|
@ -77,6 +77,8 @@ class AxisNetworkDevice:
|
|||||||
"""Return the serial number of this device."""
|
"""Return the serial number of this device."""
|
||||||
return self.config_entry.unique_id
|
return self.config_entry.unique_id
|
||||||
|
|
||||||
|
# Options
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def option_events(self):
|
def option_events(self):
|
||||||
"""Config entry option defining if platforms based on events should be created."""
|
"""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."""
|
"""Config entry option defining minimum number of seconds to keep trigger high."""
|
||||||
return self.config_entry.options.get(CONF_TRIGGER_TIME, DEFAULT_TRIGGER_TIME)
|
return self.config_entry.options.get(CONF_TRIGGER_TIME, DEFAULT_TRIGGER_TIME)
|
||||||
|
|
||||||
|
# Signals
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def signal_reachable(self):
|
def signal_reachable(self):
|
||||||
"""Device specific event to signal a change in connection status."""
|
"""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."""
|
"""Device specific event to signal a change in device address."""
|
||||||
return f"axis_new_address_{self.serial}"
|
return f"axis_new_address_{self.serial}"
|
||||||
|
|
||||||
|
# Callbacks
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_connection_status_callback(self, status):
|
def async_connection_status_callback(self, status):
|
||||||
"""Handle signals of device connection status.
|
"""Handle signals of device connection status.
|
||||||
@ -175,6 +181,8 @@ class AxisNetworkDevice:
|
|||||||
event = mqtt_json_to_event(message.payload)
|
event = mqtt_json_to_event(message.payload)
|
||||||
self.api.event.process_event(event)
|
self.api.event.process_event(event)
|
||||||
|
|
||||||
|
# Setup and teardown methods
|
||||||
|
|
||||||
async def async_setup(self):
|
async def async_setup(self):
|
||||||
"""Set up the device."""
|
"""Set up the device."""
|
||||||
try:
|
try:
|
||||||
|
@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
event = device.api.event[event_id]
|
event = device.api.event[event_id]
|
||||||
|
|
||||||
if event.CLASS == CLASS_LIGHT and event.TYPE == "Light":
|
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(
|
device.listeners.append(
|
||||||
async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor)
|
async_dispatcher_connect(hass, device.signal_new_event, async_add_sensor)
|
||||||
|
@ -20,7 +20,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
event = device.api.event[event_id]
|
event = device.api.event[event_id]
|
||||||
|
|
||||||
if event.CLASS == CLASS_OUTPUT:
|
if event.CLASS == CLASS_OUTPUT:
|
||||||
async_add_entities([AxisSwitch(event, device)], True)
|
async_add_entities([AxisSwitch(event, device)])
|
||||||
|
|
||||||
device.listeners.append(
|
device.listeners.append(
|
||||||
async_dispatcher_connect(hass, device.signal_new_event, async_add_switch)
|
async_dispatcher_connect(hass, device.signal_new_event, async_add_switch)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user