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,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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user