From d0160d135be84c27ff72c09aae86ed2a126a5fd1 Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Sat, 2 Sep 2023 13:31:43 +0200 Subject: [PATCH] client: Add refresh_device_states This method can be used to refresh all states of a single device. It's mostly useful for devices that don't automatically send state updates such as gate or garage door motors. --- pyoverkiz/client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pyoverkiz/client.py b/pyoverkiz/client.py index 672214aa..187f3f94 100644 --- a/pyoverkiz/client.py +++ b/pyoverkiz/client.py @@ -533,6 +533,17 @@ async def refresh_states(self) -> None: """ await self.__post("setup/devices/states/refresh") + @backoff.on_exception( + backoff.expo, NotAuthenticatedException, max_tries=2, on_backoff=relogin + ) + async def refresh_device_states(self, deviceurl: str) -> None: + """ + Ask the box to refresh all states of the given device for protocols supporting that operation + """ + await self.__post( + f"setup/devices/{urllib.parse.quote_plus(deviceurl)}/states/refresh" + ) + @backoff.on_exception(backoff.expo, TooManyConcurrentRequestsException, max_tries=5) async def register_event_listener(self) -> str: """