From 1b1c1c2a55173e6e4dba6acff9a30f58bd89728d Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:03:58 +0100 Subject: [PATCH] Call async_write_ha_state after ring update (#125096) Use async_write_ha_state after ring update --- homeassistant/components/ring/camera.py | 4 +++- homeassistant/components/ring/light.py | 2 +- homeassistant/components/ring/switch.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/ring/camera.py b/homeassistant/components/ring/camera.py index b45803f3618..df71de29089 100644 --- a/homeassistant/components/ring/camera.py +++ b/homeassistant/components/ring/camera.py @@ -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.""" diff --git a/homeassistant/components/ring/light.py b/homeassistant/components/ring/light.py index f7f7f9b44ae..99c4105f4e9 100644 --- a/homeassistant/components/ring/light.py +++ b/homeassistant/components/ring/light.py @@ -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.""" diff --git a/homeassistant/components/ring/switch.py b/homeassistant/components/ring/switch.py index 810011d68c8..effb43cedbe 100644 --- a/homeassistant/components/ring/switch.py +++ b/homeassistant/components/ring/switch.py @@ -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."""