get_scenes
Retrieve all scenes and groups from your Domoticz system to monitor and manage smart home configurations.
Instructions
Get all scenes and groups from Domoticz.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:658-663 (handler)The `get_scenes` tool handler: decorated with @mcp.tool(), fetches all scenes/groups from Domoticz using cached API call and returns them as JSON.
@mcp.tool() async def get_scenes() -> str: """Get all scenes and groups from Domoticz.""" async with create_client() as client: scenes = await _get_cached_data(client, _scene_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getscenes") return json.dumps({"status": "OK", "result": scenes}) - src/domoticz_mcp/server.py:658-659 (registration)The tool is registered via @mcp.tool() decorator on line 658.
@mcp.tool() async def get_scenes() -> str: - src/domoticz_mcp/server.py:378-380 (helper)_resolve_scene_idx helper resolves a scene name or idx, used for scene-related operations.
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:346-352 (helper)_get_cached_data helper fetches and caches API data, used by get_scenes to avoid repeated calls.
async def _get_cached_data(client: "httpx.AsyncClient", cache_obj: Dict[str, Any], api_url: str, key_path: str = "result") -> List[Dict[str, Any]]: now = time.time() if cache_obj["data"] is None or (now - cache_obj["timestamp"]) > CACHE_TTL: response = await _do_request(client, "GET", api_url) cache_obj["data"] = response.json().get(key_path, []) cache_obj["timestamp"] = now return cache_obj["data"] - src/domoticz_mcp/server.py:658-659 (schema)The get_scenes function has no parameters - the type signature () -> str defines its schema implicitly.
@mcp.tool() async def get_scenes() -> str: