mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use config_entry.on_unload rather than local listener implementation in Axis (#49495)
This commit is contained in:
@@ -58,8 +58,6 @@ class AxisNetworkDevice:
|
||||
self.fw_version = None
|
||||
self.product_type = None
|
||||
|
||||
self.listeners = []
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""Return the host address of this device."""
|
||||
@@ -190,7 +188,7 @@ class AxisNetworkDevice:
|
||||
status = {}
|
||||
|
||||
if status.get("data", {}).get("status", {}).get("state") == "active":
|
||||
self.listeners.append(
|
||||
self.config_entry.async_on_unload(
|
||||
await mqtt.async_subscribe(
|
||||
hass, f"{self.api.vapix.serial_number}/#", self.mqtt_message
|
||||
)
|
||||
@@ -279,9 +277,6 @@ class AxisNetworkDevice:
|
||||
if not unload_ok:
|
||||
return False
|
||||
|
||||
for unsubscribe_listener in self.listeners:
|
||||
unsubscribe_listener()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user