create_event
Create a new event script in Domoticz by specifying name, language, trigger type, and source code to automate smart home actions based on device changes, time events, or user variables.
Instructions
Create a new event script in Domoticz.
Args: name: Name of the event script. interpreter: The language (e.g., 'Lua', 'Blockly', 'dzVents', 'Python'). event_type: Trigger type (e.g., 'All', 'Device', 'Security', 'Time', 'UserVariable'). xmlstatement: The source code (or XML for Blockly) of the script. eventstatus: '1' for enabled, '0' for disabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| interpreter | Yes | ||
| event_type | Yes | ||
| xmlstatement | Yes | ||
| eventstatus | No | 1 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:837-859 (handler)The create_event MCP tool handler function. It sends a POST request to the Domoticz API to create a new event script with a given name, interpreter (e.g., Lua, Blockly, dzVents, Python), event type (e.g., All, Device, Security, Time, UserVariable), XML/source statement, and enabled/disabled status.
@mcp.tool() async def create_event(name: str, interpreter: str, event_type: str, xmlstatement: str, eventstatus: str = "1") -> str: """Create a new event script in Domoticz. Args: name: Name of the event script. interpreter: The language (e.g., 'Lua', 'Blockly', 'dzVents', 'Python'). event_type: Trigger type (e.g., 'All', 'Device', 'Security', 'Time', 'UserVariable'). xmlstatement: The source code (or XML for Blockly) of the script. eventstatus: '1' for enabled, '0' for disabled. """ async with create_client() as client: data = { "evparam": "create", "name": name, "eventstatus": eventstatus, "interpreter": interpreter, "xml": xmlstatement, "eventtype": event_type, "logicarray": "" } response = await _do_request(client, "POST", f"{DOMOTICZ_API_URL}?type=command¶m=events", data=data) return response.text - src/domoticz_mcp/server.py:837-837 (registration)The create_event tool is registered as an MCP tool via the @mcp.tool() decorator on the FastMCP instance 'mcp'. This is the registration mechanism.
@mcp.tool()