Do not call state if device isn't available (#5835)

This commit is contained in:
Erik Eriksson 2017-02-10 17:59:58 +01:00 committed by Paulus Schoutsen
parent 0b5191a247
commit c7c3b30e0a

View File

@ -210,6 +210,10 @@ class Entity(object):
start = timer()
if not self.available:
state = STATE_UNAVAILABLE
attr = {}
else:
state = self.state
if state is None:
@ -218,19 +222,13 @@ class Entity(object):
state = str(state)
attr = self.state_attributes or {}
device_attr = self.device_state_attributes
if device_attr is not None:
attr.update(device_attr)
self._attr_setter('unit_of_measurement', str, ATTR_UNIT_OF_MEASUREMENT,
attr)
if not self.available:
state = STATE_UNAVAILABLE
attr = {}
self._attr_setter('name', str, ATTR_FRIENDLY_NAME, attr)
self._attr_setter('icon', str, ATTR_ICON, attr)
self._attr_setter('entity_picture', str, ATTR_ENTITY_PICTURE, attr)