Update attributes in Entity.__init__ in matter (#108877)

This commit is contained in:
Erik Montnemery 2024-01-29 10:32:15 +01:00 committed by GitHub
parent 95aea1488d
commit fd87fd9559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,6 +82,9 @@ class MatterEntity(Entity):
self._attr_should_poll = entity_info.should_poll self._attr_should_poll = entity_info.should_poll
self._extra_poll_timer_unsub: CALLBACK_TYPE | None = None self._extra_poll_timer_unsub: CALLBACK_TYPE | None = None
# make sure to update the attributes once
self._update_from_device()
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Handle being added to Home Assistant.""" """Handle being added to Home Assistant."""
await super().async_added_to_hass() await super().async_added_to_hass()
@ -115,9 +118,6 @@ class MatterEntity(Entity):
) )
) )
# make sure to update the attributes once
self._update_from_device()
async def async_will_remove_from_hass(self) -> None: async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass.""" """Run when entity will be removed from hass."""
if self._extra_poll_timer_unsub: if self._extra_poll_timer_unsub: