diff --git a/homeassistant/components/binary_sensor/hive.py b/homeassistant/components/binary_sensor/hive.py index 68f32641872..e114e67f90f 100644 --- a/homeassistant/components/binary_sensor/hive.py +++ b/homeassistant/components/binary_sensor/hive.py @@ -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: diff --git a/homeassistant/components/climate/hive.py b/homeassistant/components/climate/hive.py index 37289d45c45..87d426d6f05 100644 --- a/homeassistant/components/climate/hive.py +++ b/homeassistant/components/climate/hive.py @@ -8,7 +8,7 @@ from homeassistant.components.climate import ( ClimateDevice, STATE_AUTO, STATE_HEAT, STATE_OFF, STATE_ON, SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS -from homeassistant.components.hive import DATA_HIVE +from homeassistant.components.hive import DATA_HIVE, DOMAIN DEPENDENCIES = ['hive'] HIVE_TO_HASS_STATE = {'SCHEDULE': STATE_AUTO, 'MANUAL': STATE_HEAT, @@ -44,6 +44,7 @@ class HiveClimateEntity(ClimateDevice): self.attributes = {} self.data_updatesource = '{}.{}'.format(self.device_type, self.node_id) + self._unique_id = '{}-{}'.format(self.node_id, self.device_type) if self.device_type == "Heating": self.modes = [STATE_AUTO, STATE_HEAT, STATE_OFF] @@ -52,6 +53,21 @@ class HiveClimateEntity(ClimateDevice): 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 + } + @property def supported_features(self): """Return the list of supported features.""" diff --git a/homeassistant/components/light/hive.py b/homeassistant/components/light/hive.py index eada16bbab9..c2bb95f40da 100644 --- a/homeassistant/components/light/hive.py +++ b/homeassistant/components/light/hive.py @@ -4,7 +4,7 @@ Support for the Hive devices. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.hive/ """ -from homeassistant.components.hive import DATA_HIVE +from homeassistant.components.hive import DATA_HIVE, DOMAIN from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_HS_COLOR, SUPPORT_BRIGHTNESS, @@ -37,8 +37,24 @@ class HiveDeviceLight(Light): 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: diff --git a/homeassistant/components/sensor/hive.py b/homeassistant/components/sensor/hive.py index 3f900320801..e989074fb4b 100644 --- a/homeassistant/components/sensor/hive.py +++ b/homeassistant/components/sensor/hive.py @@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.hive/ """ from homeassistant.const import TEMP_CELSIUS -from homeassistant.components.hive import DATA_HIVE +from homeassistant.components.hive import DATA_HIVE, DOMAIN from homeassistant.helpers.entity import Entity DEPENDENCIES = ['hive'] @@ -38,8 +38,24 @@ class HiveSensorEntity(Entity): self.session = hivesession 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: diff --git a/homeassistant/components/switch/hive.py b/homeassistant/components/switch/hive.py index 1927df28e97..a50323f0a4e 100644 --- a/homeassistant/components/switch/hive.py +++ b/homeassistant/components/switch/hive.py @@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.hive/ """ from homeassistant.components.switch import SwitchDevice -from homeassistant.components.hive import DATA_HIVE +from homeassistant.components.hive import DATA_HIVE, DOMAIN DEPENDENCIES = ['hive'] @@ -31,8 +31,24 @@ class HiveDevicePlug(SwitchDevice): 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: