From 0b7e62f737c5fb337bbb5f54f7aec0106f0badcf Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 17 Apr 2019 15:21:42 +0200 Subject: [PATCH] Axis change how new event is signalled (#23152) --- homeassistant/components/axis/binary_sensor.py | 7 ++++--- homeassistant/components/axis/device.py | 4 ++-- homeassistant/components/axis/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/axis/test_device.py | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/axis/binary_sensor.py b/homeassistant/components/axis/binary_sensor.py index 5af3cbac942..e9ef9f63710 100644 --- a/homeassistant/components/axis/binary_sensor.py +++ b/homeassistant/components/axis/binary_sensor.py @@ -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): diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index 48577799a13..1595dde4cba 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -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): diff --git a/homeassistant/components/axis/manifest.json b/homeassistant/components/axis/manifest.json index 4d102590184..f87718bfddd 100644 --- a/homeassistant/components/axis/manifest.json +++ b/homeassistant/components/axis/manifest.json @@ -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"] } diff --git a/requirements_all.txt b/requirements_all.txt index 93fb390a7b6..dab68d42d80 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 1487dd87d76..95d899d06fb 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/axis/test_device.py b/tests/components/axis/test_device.py index d95352abe9c..23714e51c88 100644 --- a/tests/components/axis/test_device.py +++ b/tests/components/axis/test_device.py @@ -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