From 6370901c0785eca54c4c049f48a8fa7191a22821 Mon Sep 17 00:00:00 2001 From: CZDave Date: Fri, 12 Sep 2025 10:45:33 +0000 Subject: [PATCH 1/3] Added support to send multiple commands to multiple devices at once --- pyoverkiz/client.py | 23 +++++++++++++++++++++++ pyoverkiz/models.py | 12 ++++++++++++ 2 files changed, 35 insertions(+) diff --git a/pyoverkiz/client.py b/pyoverkiz/client.py index c4f5c99a..480f3043 100644 --- a/pyoverkiz/client.py +++ b/pyoverkiz/client.py @@ -69,6 +69,7 @@ UnknownUserException, ) from pyoverkiz.models import ( + Action, Command, Device, Event, @@ -735,6 +736,28 @@ async def execute_commands( response: dict = await self.__post("exec/apply", payload) return cast(str, response["execId"]) + @backoff.on_exception( + backoff.expo, + (NotAuthenticatedException, ServerDisconnectedError, ClientConnectorError), + max_tries=2, + on_backoff=relogin, + ) + async def execute_actions( + self, + actions: list[Action], + label: str | None = "python-overkiz-api", + ) -> str: + """Send several commands to different devices in one call""" + payload = { + "label": label, + "actions": [ + {"deviceURL": action.device_url, "commands": action.commands} + for action in actions + ], + } + response: dict = await self.__post("exec/apply", payload) + return cast(str, response["execId"]) + @backoff.on_exception( backoff.expo, (NotAuthenticatedException, ServerDisconnectedError, ClientConnectorError), diff --git a/pyoverkiz/models.py b/pyoverkiz/models.py index a7344ab2..31cac973 100644 --- a/pyoverkiz/models.py +++ b/pyoverkiz/models.py @@ -430,6 +430,18 @@ def __init__( dict.__init__(self, name=name, parameters=parameters) +@define(init=False) +class Action: + """Represents OverKiz Action (multiple commands for specific device URL).""" + + device_url: str + commands: list[Command] + + def __init__(self, device_url: str, commands: list[Command]): + self.device_url = device_url + self.commands = commands + + @define(init=False, kw_only=True) class Event: name: EventName From e80237682f35f0fab4eb3861c407bc362633231d Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Sun, 28 Dec 2025 14:24:30 +0000 Subject: [PATCH 2/3] Remove duplicate Action --- pyoverkiz/models.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pyoverkiz/models.py b/pyoverkiz/models.py index efb7e364..286351c9 100644 --- a/pyoverkiz/models.py +++ b/pyoverkiz/models.py @@ -432,18 +432,6 @@ def __init__( dict.__init__(self, name=name, parameters=parameters) -@define(init=False) -class Action: - """Represents OverKiz Action (multiple commands for specific device URL).""" - - device_url: str - commands: list[Command] - - def __init__(self, device_url: str, commands: list[Command]): - self.device_url = device_url - self.commands = commands - - @define(init=False, kw_only=True) class Event: name: EventName From ab7088d1575e692ee8c072c044b897ee2e236479 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Sun, 28 Dec 2025 14:25:33 +0000 Subject: [PATCH 3/3] Fix formatting by removing trailing whitespace in OverkizClient methods --- pyoverkiz/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyoverkiz/client.py b/pyoverkiz/client.py index b18d8838..28860b27 100644 --- a/pyoverkiz/client.py +++ b/pyoverkiz/client.py @@ -679,7 +679,7 @@ async def execute_commands( } response: dict = await self.__post("exec/apply", payload) return cast(str, response["execId"]) - + @retry_on_auth_error async def execute_actions( self, @@ -696,7 +696,7 @@ async def execute_actions( } response: dict = await self.__post("exec/apply", payload) return cast(str, response["execId"]) - + @retry_on_auth_error async def get_scenarios(self) -> list[Scenario]: """List the scenarios"""