From ac0b6ca50c7388f86a60a303757651a43bc2de22 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 1 Feb 2016 12:08:08 +0100 Subject: [PATCH] handle situation where no name is set yet for the sensor --- homeassistant/components/sensor/tellduslive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/tellduslive.py b/homeassistant/components/sensor/tellduslive.py index 364b790ce6f..c9afbf24eae 100644 --- a/homeassistant/components/sensor/tellduslive.py +++ b/homeassistant/components/sensor/tellduslive.py @@ -11,7 +11,9 @@ import logging from datetime import datetime -from homeassistant.const import TEMP_CELCIUS, ATTR_BATTERY_LEVEL +from homeassistant.const import (TEMP_CELCIUS, + ATTR_BATTERY_LEVEL, + DEVICE_DEFAULT_NAME) from homeassistant.helpers.entity import Entity from homeassistant.components import tellduslive @@ -64,7 +66,8 @@ class TelldusLiveSensor(Entity): self._sensor_id = sensor_id self._sensor_type = sensor_type self._state = None - self._name = sensor_name + ' ' + SENSOR_TYPES[sensor_type][0] + self._name = "{} {}".format(sensor_name or DEVICE_DEFAULT_NAME, + SENSOR_TYPES[sensor_type][0]) self._last_update = None self._battery_level = None self.update()