Call async_write_ha_state after ring update (#125096)

Use async_write_ha_state after ring update
This commit is contained in:
Steven B. 2024-09-02 17:03:58 +01:00 committed by GitHub
parent df4bd721b5
commit 1b1c1c2a55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -81,6 +81,8 @@ class RingCam(RingEntity[RingDoorBell], Camera):
history_data = self._device.last_history
if history_data:
self._last_event = history_data[0]
# will call async_update to update the attributes and get the
# video url from the api
self.async_schedule_update_ha_state(True)
else:
self._last_event = None
@ -183,7 +185,7 @@ class RingCam(RingEntity[RingDoorBell], Camera):
await self._device.async_set_motion_detection(new_state)
self._attr_motion_detection_enabled = new_state
self.async_schedule_update_ha_state(False)
self.async_write_ha_state()
async def async_enable_motion_detection(self) -> None:
"""Enable motion detection in the camera."""

View File

@ -86,7 +86,7 @@ class RingLight(RingEntity[RingStickUpCam], LightEntity):
self._attr_is_on = new_state == OnOffState.ON
self._no_updates_until = dt_util.utcnow() + SKIP_UPDATES_DELAY
self.async_schedule_update_ha_state()
self.async_write_ha_state()
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the light on for 30 seconds."""

View File

@ -87,7 +87,7 @@ class SirenSwitch(BaseRingSwitch):
self._attr_is_on = new_state > 0
self._no_updates_until = dt_util.utcnow() + SKIP_UPDATES_DELAY
self.async_schedule_update_ha_state()
self.async_write_ha_state()
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the siren on for 30 seconds."""