Axis change how new event is signalled (#23152)
This commit is contained in:
parent
e114ae9b53
commit
0b7e62f737
6 changed files with 10 additions and 9 deletions
|
@ -18,8 +18,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
device = hass.data[AXIS_DOMAIN][serial_number]
|
||||
|
||||
@callback
|
||||
def async_add_sensor(event):
|
||||
def async_add_sensor(event_id):
|
||||
"""Add binary sensor from Axis device."""
|
||||
event = device.api.event.events[event_id]
|
||||
async_add_entities([AxisBinarySensor(event, device)], True)
|
||||
|
||||
device.listeners.append(async_dispatcher_connect(
|
||||
|
@ -83,12 +84,12 @@ class AxisBinarySensor(BinarySensorDevice):
|
|||
def name(self):
|
||||
"""Return the name of the event."""
|
||||
return '{} {} {}'.format(
|
||||
self.device.name, self.event.event_type, self.event.id)
|
||||
self.device.name, self.event.TYPE, self.event.id)
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of the event."""
|
||||
return self.event.event_class
|
||||
return self.event.CLASS
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -140,10 +140,10 @@ class AxisNetworkDevice:
|
|||
return 'axis_add_sensor_{}'.format(self.serial)
|
||||
|
||||
@callback
|
||||
def async_event_callback(self, action, event):
|
||||
def async_event_callback(self, action, event_id):
|
||||
"""Call to configure events when initialized on event stream."""
|
||||
if action == 'add':
|
||||
async_dispatcher_send(self.hass, self.event_new_sensor, event)
|
||||
async_dispatcher_send(self.hass, self.event_new_sensor, event_id)
|
||||
|
||||
@callback
|
||||
def start(self, fut):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "axis",
|
||||
"name": "Axis",
|
||||
"documentation": "https://www.home-assistant.io/components/axis",
|
||||
"requirements": ["axis==21"],
|
||||
"requirements": ["axis==22"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@kane610"]
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ av==6.1.2
|
|||
# avion==0.10
|
||||
|
||||
# homeassistant.components.axis
|
||||
axis==21
|
||||
axis==22
|
||||
|
||||
# homeassistant.components.baidu
|
||||
baidu-aip==1.6.6
|
||||
|
|
|
@ -61,7 +61,7 @@ apns2==0.3.0
|
|||
av==6.1.2
|
||||
|
||||
# homeassistant.components.axis
|
||||
axis==21
|
||||
axis==22
|
||||
|
||||
# homeassistant.components.zha
|
||||
bellows-homeassistant==0.7.2
|
||||
|
|
|
@ -167,7 +167,7 @@ async def test_new_event_sends_signal(hass):
|
|||
axis_device = device.AxisNetworkDevice(hass, entry)
|
||||
|
||||
with patch.object(device, 'async_dispatcher_send') as mock_dispatch_send:
|
||||
axis_device.async_event_callback(action='add', event='event')
|
||||
axis_device.async_event_callback(action='add', event_id='event')
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_dispatch_send.mock_calls) == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue