get_rooms
Retrieve a list of all rooms and room plans from your Domoticz home automation system.
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:685-690 (handler)The tool handler function 'get_rooms' decorated with @mcp.tool(). It fetches room plans from the Domoticz API using cached data and returns them 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:346-352 (helper)Helper function '_get_cached_data' used to fetch and cache data from the Domoticz API. Used by get_rooms to retrieve plans with caching (5 min TTL).
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:70-70 (registration)The FastMCP server instance. The get_rooms function is registered as an MCP tool via the @mcp.tool() decorator on line 685.
mcp = FastMCP("Domoticz", transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False), stateless_http=True) - src/domoticz_mcp/server.py:89-89 (helper)The cache variable '_plans_cache' used by get_rooms (and get_rooms_resource) to cache room plans data to avoid redundant API calls.
_plans_cache = {"data": None, "timestamp": 0}