Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pyoverkiz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
UnknownUserException,
)
from pyoverkiz.models import (
Action,
Command,
Device,
Event,
Expand Down Expand Up @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions pyoverkiz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down