Add unique_id for tellduslive (#18744)

This commit is contained in:
Fredrik Erlandsson 2018-11-27 15:35:51 +01:00 committed by Paulus Schoutsen
parent 392898e694
commit eb2e2a116e
2 changed files with 12 additions and 3 deletions

View File

@ -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])

View File

@ -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