mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Do not call state if device isn't available (#5835)
This commit is contained in:
parent
0b5191a247
commit
c7c3b30e0a
@ -210,26 +210,24 @@ class Entity(object):
|
|||||||
|
|
||||||
start = timer()
|
start = timer()
|
||||||
|
|
||||||
state = self.state
|
|
||||||
|
|
||||||
if state is None:
|
|
||||||
state = STATE_UNKNOWN
|
|
||||||
else:
|
|
||||||
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:
|
if not self.available:
|
||||||
state = STATE_UNAVAILABLE
|
state = STATE_UNAVAILABLE
|
||||||
attr = {}
|
attr = {}
|
||||||
|
else:
|
||||||
|
state = self.state
|
||||||
|
|
||||||
|
if state is None:
|
||||||
|
state = STATE_UNKNOWN
|
||||||
|
else:
|
||||||
|
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)
|
||||||
|
|
||||||
self._attr_setter('name', str, ATTR_FRIENDLY_NAME, attr)
|
self._attr_setter('name', str, ATTR_FRIENDLY_NAME, attr)
|
||||||
self._attr_setter('icon', str, ATTR_ICON, attr)
|
self._attr_setter('icon', str, ATTR_ICON, attr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user