Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

get_device_history

Retrieve historical log or graph data for a smart home device, with options for sensor type (light, text, temp, percentage, counter) and time range (day, month, year).

Instructions

Get history log or graph for a device. sensor_type: 'light', 'text', 'temp', 'percentage', 'counter'. time_range (for graphs): 'day', 'month', 'year'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idxNo
nameNo
sensor_typeNolight
time_rangeNoday

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_device_history' tool handler function. It fetches history logs or graphs for a device by idx or name, supporting sensor types: 'light', 'text', 'temp', 'percentage', 'counter', and time_range: 'day', 'month', 'year'. Registered via @mcp.tool() decorator on line 787.
    @mcp.tool()
    async def get_device_history(idx: int | None = None, name: str | None = None, sensor_type: str = "light", time_range: str = "day") -> str:
        """Get history log or graph for a device. sensor_type: 'light', 'text', 'temp', 'percentage', 'counter'. time_range (for graphs): 'day', 'month', 'year'."""
        if idx is None and name is None:
            return '{"status": "error", "message": "Must provide either idx or name"}'
        async with create_client() as client:
            resolved_idx = await _resolve_device_idx(client, idx, name)
            if resolved_idx is None:
                return '{"status": "error", "message": "Device not found"}'
                
            url = f"{DOMOTICZ_API_URL}?type=command"
            if sensor_type == "light":
                url += f"¶m=getlightlog&idx={resolved_idx}"
            elif sensor_type == "text":
                url += f"¶m=gettextlog&idx={resolved_idx}"
            else:
                url += f"¶m=graph&sensor={sensor_type}&idx={resolved_idx}&range={time_range}"
                
            response = await _do_request(client, "GET", url)
            return response.text
  • The tool is registered using the @mcp.tool() decorator on line 787, which is the standard FastMCP registration mechanism for tools.
    @mcp.tool()
    async def get_device_history(idx: int | None = None, name: str | None = None, sensor_type: str = "light", time_range: str = "day") -> str:
  • Input schema/parameters: idx (int, optional), name (str, optional), sensor_type (str, default 'light'), time_range (str, default 'day'). The docstring serves as the tool description.
    async def get_device_history(idx: int | None = None, name: str | None = None, sensor_type: str = "light", time_range: str = "day") -> str:
        """Get history log or graph for a device. sensor_type: 'light', 'text', 'temp', 'percentage', 'counter'. time_range (for graphs): 'day', 'month', 'year'."""
  • Helper function _resolve_device_idx used by get_device_history to resolve device idx from name.
    async def _resolve_device_idx(client: "httpx.AsyncClient", idx: Optional[int] = None, name: Optional[str] = None) -> Optional[int]:
        """Resolve a device to its idx."""
        return await _resolve_idx(client, idx, name, _device_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getdevices&filter=all&used=true")
Behavior2/5

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

With no annotations, the description fails to disclose behavioral traits like read-only nature or side effects. It mentions 'log or graph' but does not explain what determines the output format, leaving ambiguity about behavior.

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 concise with two sentences. The purpose is front-loaded. The second sentence provides parameter values without extra fluff, earning its place.

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

Completeness3/5

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

The description partially covers the tool: it explains two parameters but omits 'idx' and 'name'. Despite the output schema existing, the description lacks clarity on how to specify the device and how parameters affect log vs graph output.

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

Parameters3/5

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

Schema coverage is 0%, so the description must compensate. It lists allowed values for 'sensor_type' and 'time_range', adding meaning. However, 'idx' and 'name' are left unexplained, and their role in identifying the device is implied but not explicit.

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

Purpose4/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 ('history log or graph for a device'), making the purpose understandable. However, it does not differentiate from sibling tools like 'get_log' or 'get_device', which could lead to confusion.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as 'get_log' for system logs or 'get_device' for current state. No contexts or exclusions are mentioned.

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