diff --git a/DoHome_HassAssistant_Component/custom_components/dohome/sensor.py b/DoHome_HassAssistant_Component/custom_components/dohome/sensor.py index 52f6ae3..d4e6f8a 100644 --- a/DoHome_HassAssistant_Component/custom_components/dohome/sensor.py +++ b/DoHome_HassAssistant_Component/custom_components/dohome/sensor.py @@ -9,7 +9,7 @@ from datetime import timedelta from homeassistant.helpers.event import track_time_interval -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from . import (DOHOME_GATEWAY, DoHomeDevice) @@ -84,7 +84,7 @@ def state(self): def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" if self._is_temperature and self.current_value != 100: - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS elif self._is_humidity and self.current_value != 0: return '%' elif self._is_illumination and self.current_value != -1: diff --git a/DoHome_HassAssistant_Component/custom_components/dohome/switch.py b/DoHome_HassAssistant_Component/custom_components/dohome/switch.py index c12fca8..783b800 100644 --- a/DoHome_HassAssistant_Component/custom_components/dohome/switch.py +++ b/DoHome_HassAssistant_Component/custom_components/dohome/switch.py @@ -56,6 +56,10 @@ def is_on(self): """Return true if plug is on.""" return self._state + @property + def unique_id(self): + return self._device["name"] + def turn_on(self, **kwargs): """Turn the switch on.""" self._state = True @@ -116,4 +120,4 @@ def _send_cmd(self, device, cmd, rtn_cmd): return resp else: _LOGGER.debug("Non matching response. device %s, but got %s", device["sid"], dic["dev"][8:12]) - return None \ No newline at end of file + return None