Merge pull request #1076 from MartinHjelmare/add-entity-online-prop

Fix 'unavailable' entity
pull/1030/merge
Paulus Schoutsen 2016-01-31 17:26:12 -08:00
commit 2f4e40db27
1 changed files with 7 additions and 7 deletions

View File

@ -135,17 +135,17 @@ class Entity(object):
state = str(self.state)
attr = self.state_attributes or {}
if not self.available:
state = STATE_UNAVAILABLE
return self.hass.states.set(self.entity_id, state)
if ATTR_FRIENDLY_NAME not in attr and self.name is not None:
attr[ATTR_FRIENDLY_NAME] = str(self.name)
if ATTR_UNIT_OF_MEASUREMENT not in attr and \
self.unit_of_measurement is not None:
attr[ATTR_UNIT_OF_MEASUREMENT] = str(self.unit_of_measurement)
if not self.available:
state = STATE_UNAVAILABLE
attr = {}
if ATTR_FRIENDLY_NAME not in attr and self.name is not None:
attr[ATTR_FRIENDLY_NAME] = str(self.name)
if ATTR_ICON not in attr and self.icon is not None:
attr[ATTR_ICON] = str(self.icon)