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

@ -23,9 +23,8 @@ class HiveDevicePlug(SwitchDevice):
self.device_type = hivedevice["HA_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
@ -36,16 +35,11 @@ class HiveDevicePlug(SwitchDevice):
@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
@ -83,5 +77,4 @@ class HiveDevicePlug(SwitchDevice):
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)