Avoid update calls in state writes when attributes are empty (#115624)
This commit is contained in:
parent
9f852c6a58
commit
dbc5109fd8
1 changed files with 4 additions and 2 deletions
|
@ -1052,8 +1052,10 @@ class Entity(
|
|||
available = self.available # only call self.available once per update cycle
|
||||
state = self._stringify_state(available)
|
||||
if available:
|
||||
attr.update(self.state_attributes or {})
|
||||
attr.update(self.extra_state_attributes or {})
|
||||
if state_attributes := self.state_attributes:
|
||||
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:
|
||||
attr[ATTR_UNIT_OF_MEASUREMENT] = unit_of_measurement
|
||||
|
|
Loading…
Add table
Reference in a new issue