1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00
This commit is contained in:
Paulus Schoutsen
2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View File

@@ -3,10 +3,7 @@ from homeassistant.components.binary_sensor import BinarySensorDevice
from . import DATA_HIVE, DOMAIN
DEVICETYPE_DEVICE_CLASS = {
'motionsensor': 'motion',
'contactsensor': 'opening',
}
DEVICETYPE_DEVICE_CLASS = {"motionsensor": "motion", "contactsensor": "opening"}
def setup_platform(hass, config, add_entities, discovery_info=None):
@@ -29,9 +26,8 @@ class HiveBinarySensorEntity(BinarySensorDevice):
self.node_device_type = hivedevice["Hive_DeviceType"]
self.session = hivesession
self.attributes = {}
self.data_updatesource = '{}.{}'.format(self.device_type,
self.node_id)
self._unique_id = '{}-{}'.format(self.node_id, self.device_type)
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
@@ -42,16 +38,11 @@ class HiveBinarySensorEntity(BinarySensorDevice):
@property
def device_info(self):
"""Return device information."""
return {
'identifiers': {
(DOMAIN, self.unique_id)
},
'name': self.name
}
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:
if "{}.{}".format(self.device_type, self.node_id) not in updatesource:
self.schedule_update_ha_state()
@property
@@ -72,11 +63,9 @@ class HiveBinarySensorEntity(BinarySensorDevice):
@property
def is_on(self):
"""Return true if the binary sensor is on."""
return self.session.sensor.get_state(
self.node_id, self.node_device_type)
return self.session.sensor.get_state(self.node_id, self.node_device_type)
def update(self):
"""Update all Node data from Hive."""
self.session.core.update_data(self.node_id)
self.attributes = self.session.attributes.state_attributes(
self.node_id)
self.attributes = self.session.attributes.state_attributes(self.node_id)