Axis devices support device registry (#22367)

* Add support for device registry

* Fix test
This commit is contained in:
Robert Svensson 2019-03-27 18:25:01 +01:00 committed by Martin Hjelmare
parent 646c4a7137
commit 52437f6246
5 changed files with 44 additions and 1 deletions

View file

@ -81,7 +81,20 @@ class AxisBinarySensor(BinarySensorDevice):
"""Return the class of the event."""
return self.event.event_class
@property
def unique_id(self):
"""Return a unique identifier for this device."""
return '{}-{}-{}'.format(
self.device.serial, self.event.topic, self.event.id)
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def device_info(self):
"""Return a device description for device registry."""
return {
'identifiers': {(AXIS_DOMAIN, self.device.serial)}
}