add entity support to hive (#19879)
This commit is contained in:
parent
b4c657a39c
commit
6d9fda04ac
5 changed files with 85 additions and 6 deletions
|
@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/binary_sensor.hive/
|
||||
"""
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.components.hive import DATA_HIVE
|
||||
from homeassistant.components.hive import DATA_HIVE, DOMAIN
|
||||
|
||||
DEPENDENCIES = ['hive']
|
||||
|
||||
|
@ -35,9 +35,24 @@ class HiveBinarySensorEntity(BinarySensorDevice):
|
|||
self.attributes = {}
|
||||
self.data_updatesource = '{}.{}'.format(self.device_type,
|
||||
self.node_id)
|
||||
|
||||
self._unique_id = '{}-{}'.format(self.node_id, self.device_type)
|
||||
self.session.entities.append(self)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique ID of entity."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return device information."""
|
||||
return {
|
||||
'identifiers': {
|
||||
(DOMAIN, self.unique_id)
|
||||
},
|
||||
'name': self.name
|
||||
}
|
||||
|
||||
def handle_update(self, updatesource):
|
||||
"""Handle the new update request."""
|
||||
if '{}.{}'.format(self.device_type, self.node_id) not in updatesource:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue