get_scene_devices
Retrieve all devices assigned to a specific scene or group by providing its IDX or name for home automation management.
Instructions
List all devices belonging to a specific scene/group by IDX or Name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| idx | No | ||
| name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:1062-1072 (handler)The tool handler function for 'get_scene_devices'. It resolves a scene by idx or name, then fetches all devices belonging to that scene via the Domoticz API endpoint 'getscenedevices'.
@mcp.tool() async def get_scene_devices(idx: int | None = None, name: str | None = None) -> str: """List all devices belonging to a specific scene/group by IDX or Name.""" if idx is None and name is None: return '{"status": "error", "message": "Must provide either idx or name"}' async with create_client() as client: resolved_idx = await _resolve_scene_idx(client, idx, name) if resolved_idx is None: return '{"status": "error", "message": "Scene not found"}' response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=getscenedevices&idx={resolved_idx}&isscene=true") return response.text - src/domoticz_mcp/server.py:1061-1062 (registration)The tool is registered with the MCP server via the @mcp.tool() decorator on line 1061.
@mcp.tool() - src/domoticz_mcp/server.py:378-380 (helper)Helper used by get_scene_devices to resolve a scene's idx by name or direct idx, using the _resolve_idx shared utility with the scene cache.
async def _resolve_scene_idx(client: "httpx.AsyncClient", idx: Optional[int] = None, name: Optional[str] = None) -> Optional[int]: """Resolve a scene to its idx.""" return await _resolve_idx(client, idx, name, _scene_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getscenes") - src/domoticz_mcp/server.py:354-370 (helper)Shared helper used by _resolve_scene_idx to lookup items by name in cached data.
async def _resolve_idx( client: "httpx.AsyncClient", idx: Optional[int], name: Optional[str], cache: Dict[str, Any], api_url: str ) -> Optional[int]: """Resolve an entity to its idx by either using the provided idx or looking up by name.""" if idx is not None: return idx if not name: return None items = await _get_cached_data(client, cache, api_url) for item in items: if item.get("Name", "").lower() == name.lower(): return int(str(item.get("idx"))) return None