rename_device
Rename a Domoticz device by specifying its IDX or current name.
Instructions
Rename a device by IDX or its old Name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new_name | Yes | ||
| idx | No | ||
| old_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:1007-1018 (handler)The handler function for the 'rename_device' tool. It takes a new_name and either idx or old_name, resolves the device index, calls the Domoticz API 'renamedevice' command, and invalidates the device cache.
@mcp.tool() async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str: """Rename a device by IDX or its old Name.""" if idx is None and old_name is None: return '{"status": "error", "message": "Must provide either idx or old_name"}' async with create_client() as client: resolved_idx = await _resolve_device_idx(client, idx, old_name) if resolved_idx is None: return '{"status": "error", "message": "Device not found"}' response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=renamedevice&name={urllib.parse.quote(new_name)}&idx={resolved_idx}") _device_cache["timestamp"] = 0 # Invalidate cache return response.text - src/domoticz_mcp/server.py:1007-1008 (registration)The tool is registered with the FastMCP instance via the @mcp.tool() decorator on line 1007.
@mcp.tool() async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str: - src/domoticz_mcp/server.py:1008-1008 (schema)Type annotations define the input schema: new_name (required str), idx (optional int), old_name (optional str). Returns a str (JSON).
async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str: