Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

get_room_devices

Retrieve all smart home devices and their current states for a specific room by providing its ID 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 main handler function for the 'get_room_devices' tool. It accepts either idx or room_name, resolves room_name to idx by looking up cached plans, then queries Domoticz API for devices in that plan (room). Results are simplified using _simplify_device helper.
    @mcp.tool()
    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 schema/docstring for get_room_devices: takes optional idx (int) or room_name (str) parameters.
    async def get_room_devices(idx: int | None = None, room_name: str | None = None) -> str:
  • Registration via the @mcp.tool() decorator on line 692 marking get_room_devices as an MCP tool.
    @mcp.tool()
  • Helper function _simplify_device used by get_room_devices to reduce device dictionaries 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}
  • Cache _plans_cache used by get_room_devices to store and retrieve room plans data.
    _plans_cache = {"data": None, "timestamp": 0}
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It indicates a read operation with no side effects, but does not mention permissions, error handling, or the nature of the output beyond 'current states.'

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

Conciseness5/5

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

The description is a single, front-loaded sentence containing exactly the information needed. No redundant words or extraneous details.

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 output schema exists (not shown), the description does not need to detail return values. It covers the primary inputs and purpose, but lacks remarks on error conditions or edge cases like calling with both parameters or none.

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 parameter names alone are ambiguous. The description adds critical meaning by stating that either idx or room_name can be used to identify the room, aiding the agent in parameter selection.

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 action ('Get all devices and their current states') and the scope ('in a specific room'). It distinguishes from siblings like 'get_all_devices' and 'get_device' by specifying the room constraint.

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, but does not explicitly state when to use this tool over alternatives or when not to use it. No exclusions or fallback guidance is given.

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