Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

get_room_devices

Retrieves all devices and their current states for a specific room using either the room index or name.

Instructions

Get all devices and their current states in a specific room. Provide either idx or room_name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idxNo
room_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual handler function for the get_room_devices tool. It accepts an idx or room_name, resolves the room name to an idx via the plans cache if needed, then fetches devices for that room plan, simplifies the device data, and returns JSON.
    async def get_room_devices(idx: int | None = None, room_name: str | None = None) -> str:
        """Get all devices and their current states in a specific room. Provide either idx or room_name."""
        if idx is None and room_name is None:
            return '{"status": "error", "message": "Must provide either idx or room_name"}'
            
        async with create_client() as client:
            if idx is None:
                plans = await _get_cached_data(client, _plans_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getplans&order=name&used=true")
                for plan in plans:
                    if plan.get("Name", "").lower() == str(room_name).lower():
                        idx = plan.get("idx")
                        break
                
                if idx is None:
                    return f'{{"status": "error", "message": "Room \'{room_name}\' not found"}}'
    
            # Using plan=idx returns the full status of all devices in the room, rather than just their IDs
            response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=getdevices&plan={idx}")
            data = response.json()
            if "result" in data:
                data["result"] = [_simplify_device(d) for d in data["result"]]
            return json.dumps(data)
  • The @mcp.tool() decorator registers get_room_devices as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • The _simplify_device helper function used within get_room_devices to reduce device data to essential fields.
    def _simplify_device(dev: Dict[str, Any]) -> Dict[str, Any]:
        """Reduce device dictionary to essential fields to save context space."""
        keys_to_keep = [
            "idx", "Name", "Type", "SubType", "Data", "Status", 
            "BatteryLevel", "Favorite", "HardwareName", "LastUpdate", 
            "TypeImg", "Usage", "CounterToday", "Temp", "Humidity"
        ]
        return {k: dev[k] for k in keys_to_keep if k in dev}
  • The function signature defines the input schema: idx (optional int) and room_name (optional str). Output is a JSON string.
    async def get_room_devices(idx: int | None = None, room_name: str | None = None) -> str:
        """Get all devices and their current states in a specific room. Provide either idx or room_name."""
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses that the tool returns devices and their states for a specific room. Without annotations, it implies a read operation but does not state side effects, permissions, or response structure (though output schema exists). This is adequate but not thorough.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single clear sentence with no wasted words. It could be slightly more structured (e.g., separating purpose and parameter guidelines), but is already efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple tool with two optional parameters and an output schema, the description covers the essential functionality. It is complete enough for an agent to understand the tool's purpose and basic usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description compensates by explaining that idx and room_name identify the room and are alternatives. This adds meaning beyond the schema's types and nullability.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'all devices and their current states in a specific room'. It distinguishes from sibling tools like get_all_devices (returns all devices) and get_device (single device) by specifying the room context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description advises to 'Provide either idx or room_name', which guides parameter usage. However, it does not provide when to use this tool over alternatives (e.g., get_all_devices) or any exclusion conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/adrighem/domoticz-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server