mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Avoid update calls in state writes when attributes are empty (#115624)
This commit is contained in:
parent
9f852c6a58
commit
dbc5109fd8
@ -1052,8 +1052,10 @@ class Entity(
|
|||||||
available = self.available # only call self.available once per update cycle
|
available = self.available # only call self.available once per update cycle
|
||||||
state = self._stringify_state(available)
|
state = self._stringify_state(available)
|
||||||
if available:
|
if available:
|
||||||
attr.update(self.state_attributes or {})
|
if state_attributes := self.state_attributes:
|
||||||
attr.update(self.extra_state_attributes or {})
|
attr.update(state_attributes)
|
||||||
|
if extra_state_attributes := self.extra_state_attributes:
|
||||||
|
attr.update(extra_state_attributes)
|
||||||
|
|
||||||
if (unit_of_measurement := self.unit_of_measurement) is not None:
|
if (unit_of_measurement := self.unit_of_measurement) is not None:
|
||||||
attr[ATTR_UNIT_OF_MEASUREMENT] = unit_of_measurement
|
attr[ATTR_UNIT_OF_MEASUREMENT] = unit_of_measurement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user