From 9d1ee5e0cd7ca51721741c550846fae3911d02e1 Mon Sep 17 00:00:00 2001 From: John Gibbons Date: Tue, 10 Mar 2026 00:16:03 -0700 Subject: [PATCH] Added send_command to support hass-control4 send command action feature --- pyControl4/director.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyControl4/director.py b/pyControl4/director.py index fce307d..83d9a00 100644 --- a/pyControl4/director.py +++ b/pyControl4/director.py @@ -228,6 +228,24 @@ async def get_item_commands(self, item_id: int) -> list[dict[str, Any]]: result: list[dict[str, Any]] = json.loads(data) return result + async def send_command( + self, item_id: int, command: str, params: dict[str, Any] | None = None + ) -> str: + """Sends a command to the specified item. + + Parameters: + `item_id` - The Control4 item ID. + + `command` - The Control4 command to send. + + `params` - The parameters of the command, provided as a dictionary. + """ + if params is None: + params = {} + return await self.send_post_request( + f"/api/v1/items/{item_id}/commands", command, params + ) + async def get_item_network(self, item_id: int) -> list[dict[str, Any]]: """Returns the network information for the specified item.