File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 6969 UnknownUserException ,
7070)
7171from pyoverkiz .models import (
72+ Action ,
7273 Command ,
7374 Device ,
7475 Event ,
@@ -735,6 +736,28 @@ async def execute_commands(
735736 response : dict = await self .__post ("exec/apply" , payload )
736737 return cast (str , response ["execId" ])
737738
739+ @backoff .on_exception (
740+ backoff .expo ,
741+ (NotAuthenticatedException , ServerDisconnectedError , ClientConnectorError ),
742+ max_tries = 2 ,
743+ on_backoff = relogin ,
744+ )
745+ async def execute_actions (
746+ self ,
747+ actions : list [Action ],
748+ label : str | None = "python-overkiz-api" ,
749+ ) -> str :
750+ """Send several commands to different devices in one call"""
751+ payload = {
752+ "label" : label ,
753+ "actions" : [
754+ {"deviceURL" : action .device_url , "commands" : action .commands }
755+ for action in actions
756+ ],
757+ }
758+ response : dict = await self .__post ("exec/apply" , payload )
759+ return cast (str , response ["execId" ])
760+
738761 @backoff .on_exception (
739762 backoff .expo ,
740763 (NotAuthenticatedException , ServerDisconnectedError , ClientConnectorError ),
Original file line number Diff line number Diff line change @@ -430,6 +430,18 @@ def __init__(
430430 dict .__init__ (self , name = name , parameters = parameters )
431431
432432
433+ @define (init = False )
434+ class Action :
435+ """Represents OverKiz Action (multiple commands for specific device URL)."""
436+
437+ device_url : str
438+ commands : list [Command ]
439+
440+ def __init__ (self , device_url : str , commands : list [Command ]):
441+ self .device_url = device_url
442+ self .commands = commands
443+
444+
433445@define (init = False , kw_only = True )
434446class Event :
435447 name : EventName
You can’t perform that action at this time.
0 commit comments