Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

create_virtual_sensor

Create a virtual sensor in Domoticz by providing the hardware index, sensor name, and sensor type (e.g., temperature, humidity).

Instructions

Create a virtual sensor.

hw_idx: IDX of the dummy hardware.

sensortype (Sensor Type): 1: Temperature 2: Humidity 3: Temp + Humidity 4: Barometer 5: Temp + Hum + Baro 6: Rain 7: UV 8: Wind 10: Lux 11: Voltage 12: Current 13: Distance 14: Text 15: Alert 17: Percentage 19: Counter 113: kWh (Energy)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hw_idxYes
sensornameYes
sensortypeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler for the create_virtual_sensor tool. It is decorated with @mcp.tool() and registers itself as an MCP tool. It takes hw_idx (dummy hardware IDX), sensorname (sensor name), and sensortype (integer code for sensor type), then calls the Domoticz JSON API endpoint 'createvirtualsensor'. It also invalidates the device cache after creation.
    @mcp.tool()
    async def create_virtual_sensor(hw_idx: int, sensorname: str, sensortype: int) -> str:
        """Create a virtual sensor. 
        
        hw_idx: IDX of the dummy hardware.
        
        sensortype (Sensor Type):
        1: Temperature
        2: Humidity
        3: Temp + Humidity
        4: Barometer
        5: Temp + Hum + Baro
        6: Rain
        7: UV
        8: Wind
        10: Lux
        11: Voltage
        12: Current
        13: Distance
        14: Text
        15: Alert
        17: Percentage
        19: Counter
        113: kWh (Energy)
        """
        async with create_client() as client:
            response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=createvirtualsensor&idx={hw_idx}&sensorname={urllib.parse.quote(sensorname)}&sensortype={sensortype}")
            _device_cache["timestamp"] = 0 # Invalidate cache
            return response.text
  • Registration via the @mcp.tool() decorator on line 1033 registers 'create_virtual_sensor' as an MCP tool in the FastMCP server instance.
    @mcp.tool()
    async def create_virtual_sensor(hw_idx: int, sensorname: str, sensortype: int) -> str:
  • Input schema defined via the docstring and type annotations: hw_idx (int), sensorname (str), sensortype (int). The docstring also documents the valid sensortype integer codes.
    """Create a virtual sensor. 
    
    hw_idx: IDX of the dummy hardware.
    
    sensortype (Sensor Type):
    1: Temperature
    2: Humidity
    3: Temp + Humidity
    4: Barometer
    5: Temp + Hum + Baro
    6: Rain
    7: UV
    8: Wind
    10: Lux
    11: Voltage
    12: Current
    13: Distance
    14: Text
    15: Alert
    17: Percentage
    19: Counter
    113: kWh (Energy)
    """
Behavior1/5

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

With no annotations, the description must disclose behavioral traits. It only states 'create' but gives no information about side effects, authorization needs, rate limits, or what happens after creation. This is minimal transparency.

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 short and front-loaded with the purpose. The parameter mappings are listed clearly. The extra line breaks could be trimmed, but overall it is efficient.

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

Completeness2/5

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

Given the tool has three required parameters and no annotations, the description should cover all aspects. It lacks explanation for 'sensorname', does not mention output or errors, and provides no prerequisites. This is insufficient for complete understanding.

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 explains 'hw_idx' and 'sensortype' with a mapping, adding value beyond the schema. However, 'sensorname' is left without explanation, leaving a gap.

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 ('Create a virtual sensor') and lists the specific resource. It distinguishes itself from siblings like 'create_event' by focusing on virtual sensors. The inclusion of sensortype mappings further clarifies the tool's purpose.

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, nor does it mention prerequisites or exclusions. It implicitly assumes the user knows when to create a virtual sensor, but lacks explicit usage context.

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