Merge pull request #1084 from molobrakos/tellduslive

handle situation where no name is set yet for the sensor
This commit is contained in:
Paulus Schoutsen 2016-02-01 08:55:39 -08:00
commit 10a41a22dc

View File

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