Axis discovery updates host address (#22632)
* Discovery can update host on existing entries * Add support in device to update host on entry update * Fix tests and listener * Fix hound comment * Fix failing tests from cleanup
This commit is contained in:
1 parent
6c14e7afa7
commit
8a0b210f87
7 files changed
+104
-49
No files matched your search
@@ -101,8 +101,26 @@ class AxisNetworkDevice:
|
||||
self.api.enable_events(event_callback=self.async_event_callback)
|
||||
self.api.start()
|
||||
|
||||
self.config_entry.add_update_listener(self.async_new_address_callback)
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def event_new_address(self):
|
||||
"""Device specific event to signal new device address."""
|
||||
return 'axis_new_address_{}'.format(self.serial)
|
||||
|
||||
@staticmethod
|
||||
async def async_new_address_callback(hass, entry):
|
||||
"""Handle signals of device getting new address.
|
||||
|
||||
This is a static method because a class method (bound method),
|
||||
can not be used with weak references.
|
||||
"""
|
||||
device = hass.data[DOMAIN][entry.data[CONF_MAC]]
|
||||
device.api.config.host = device.host
|
||||
async_dispatcher_send(hass, device.event_new_address)
|
||||
|
||||
@property
|
||||
def event_reachable(self):
|
||||
"""Device specific event to signal a change in connection status."""
|
||||
@@ -110,7 +128,7 @@ class AxisNetworkDevice:
|
||||
|
||||
@callback
|
||||
def async_connection_status_callback(self, status):
|
||||
"""Handle signals of gateway connection status.
|
||||
"""Handle signals of device connection status.
|
||||
|
||||
This is called on every RTSP keep-alive message.
|
||||
Only signal state change if state change is true.
|
||||
|
||||
Reference in new issue
Block a user