From eb2e2a116e64e6d80a097128a5f11cba5b8d6161 Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Tue, 27 Nov 2018 15:35:51 +0100 Subject: [PATCH] Add unique_id for tellduslive (#18744) --- homeassistant/components/sensor/tellduslive.py | 5 +++++ homeassistant/components/tellduslive.py | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/tellduslive.py b/homeassistant/components/sensor/tellduslive.py index 4676e08a247..9bd5a1d8413 100644 --- a/homeassistant/components/sensor/tellduslive.py +++ b/homeassistant/components/sensor/tellduslive.py @@ -127,3 +127,8 @@ class TelldusLiveSensor(TelldusLiveEntity): """Return the device class.""" return SENSOR_TYPES[self._type][3] \ if self._type in SENSOR_TYPES else None + + @property + def unique_id(self) -> str: + """Return a unique ID.""" + return "-".join(self._id[0:2]) diff --git a/homeassistant/components/tellduslive.py b/homeassistant/components/tellduslive.py index c2b7ba9ba0f..a6ba248b99b 100644 --- a/homeassistant/components/tellduslive.py +++ b/homeassistant/components/tellduslive.py @@ -9,12 +9,11 @@ import logging import voluptuous as vol +from homeassistant.components.discovery import SERVICE_TELLDUSLIVE from homeassistant.const import ( - ATTR_BATTERY_LEVEL, DEVICE_DEFAULT_NAME, - CONF_TOKEN, CONF_HOST, + ATTR_BATTERY_LEVEL, CONF_HOST, CONF_TOKEN, DEVICE_DEFAULT_NAME, EVENT_HOMEASSISTANT_START) from homeassistant.helpers import discovery -from homeassistant.components.discovery import SERVICE_TELLDUSLIVE import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import track_point_in_utc_time @@ -360,3 +359,8 @@ class TelldusLiveEntity(Entity): """Return the last update of a device.""" return str(datetime.fromtimestamp(self.device.lastUpdated)) \ if self.device.lastUpdated else None + + @property + def unique_id(self) -> str: + """Return a unique ID.""" + return self._id