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
16 changes: 16 additions & 0 deletions pyControl4/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ 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 get_browse_items(self, path: str) -> list[dict[str, Any]]:
"""Returns browseable media items for the specified Control4 browse path.

Parameters:
`path` - The browse API path from a command's value source.
"""
data = await self.send_get_request(path)
payload: Any = json.loads(data)
if isinstance(payload, list):
return [item for item in payload if isinstance(item, dict)]
if isinstance(payload, dict):
visible = payload.get("visible")
if isinstance(visible, list):
return [item for item in visible if isinstance(item, dict)]
return []

async def get_item_network(self, item_id: int) -> list[dict[str, Any]]:
"""Returns the network information for the specified item.

Expand Down
30 changes: 30 additions & 0 deletions pyControl4/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,36 @@ async def set_stop(self) -> None:
{},
)

async def get_commands(self) -> list[dict[str, Any]]:
"""Returns the commands available for this room."""
return await self.director.get_item_commands(self.item_id)

async def get_browse_items(self, path: str) -> list[dict[str, Any]]:
"""Returns browseable media items for the specified room browse path.

Parameters:
`path` - The Control4 API path from a command parameter's value source.
"""
return await self.director.get_browse_items(path)

async def play_browse_item(
self,
command: str,
params: dict[str, Any],
) -> str:
"""Sends a browse selection command to this room.

Parameters:
`command` - The Control4 command to send.

`params` - The command parameters, typically including the selected media ID.
"""
return await self.director.send_post_request(
f"/api/v1/items/{self.item_id}/commands",
command,
params,
)

async def get_audio_devices(self) -> dict[str, Any]:
"""
Note: As tested in OS 3.2.3 this doesn't work, but may work in previous versions
Expand Down
Loading