handle situation where no name is set yet for the sensor

pull/1084/head
Erik 2016-02-01 12:08:08 +01:00
parent e29a2fa45a
commit ac0b6ca50c
1 changed files with 5 additions and 2 deletions

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