This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+12 -16
View File
@@ -5,13 +5,13 @@ from homeassistant.helpers.entity import Entity
from . import DATA_HIVE, DOMAIN
FRIENDLY_NAMES = {
'Hub_OnlineStatus': 'Hive Hub Status',
'Hive_OutsideTemperature': 'Outside Temperature',
"Hub_OnlineStatus": "Hive Hub Status",
"Hive_OutsideTemperature": "Outside Temperature",
}
DEVICETYPE_ICONS = {
'Hub_OnlineStatus': 'mdi:switch',
'Hive_OutsideTemperature': 'mdi:thermometer',
"Hub_OnlineStatus": "mdi:switch",
"Hive_OutsideTemperature": "mdi:thermometer",
}
@@ -21,8 +21,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return
session = hass.data.get(DATA_HIVE)
if (discovery_info["HA_DeviceType"] == "Hub_OnlineStatus" or
discovery_info["HA_DeviceType"] == "Hive_OutsideTemperature"):
if (
discovery_info["HA_DeviceType"] == "Hub_OnlineStatus"
or discovery_info["HA_DeviceType"] == "Hive_OutsideTemperature"
):
add_entities([HiveSensorEntity(session, discovery_info)])
@@ -35,9 +37,8 @@ class HiveSensorEntity(Entity):
self.device_type = hivedevice["HA_DeviceType"]
self.node_device_type = hivedevice["Hive_DeviceType"]
self.session = hivesession
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
@@ -48,16 +49,11 @@ class HiveSensorEntity(Entity):
@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