get_rooms
Retrieve all room plans from your Domoticz home automation system to manage smart home configurations.
Instructions
Get all rooms (Room Plans) 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:679-684 (handler)The 'get_rooms' MCP tool handler. It is decorated with @mcp.tool(), calls _get_cached_data to fetch room plans from Domoticz API (param=getplans), and returns the result as JSON.
@mcp.tool() async def get_rooms() -> str: """Get all rooms (Room Plans) from Domoticz.""" async with create_client() as client: plans = await _get_cached_data(client, _plans_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getplans&order=name&used=true") return json.dumps({"status": "OK", "result": plans}) - src/domoticz_mcp/server.py:679-679 (registration)The @mcp.tool() decorator on line 679 registers 'get_rooms' as an MCP tool with the FastMCP server instance.
@mcp.tool() - src/domoticz_mcp/server.py:346-352 (helper)The _get_cached_data helper function that get_rooms relies on to fetch and cache the room plans data from the Domoticz API.
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:89-89 (helper)The _plans_cache global variable used by get_rooms and related functions to cache room plans data (TTL: 300 seconds).
_plans_cache = {"data": None, "timestamp": 0} - src/domoticz_mcp/server.py:1200-1205 (handler)The get_rooms_resource() - a parallel MCP resource handler at 'domoticz://rooms' that provides the same room plans data, using identical logic to the get_rooms tool.
@mcp.resource("domoticz://rooms") async def get_rooms_resource() -> str: """Read the list of all Domoticz rooms (Room Plans).""" async with create_client() as client: plans = await _get_cached_data(client, _plans_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getplans&order=name&used=true") return json.dumps({"status": "OK", "result": plans})