set_temperature_setpoint
Set a thermostat's target temperature to a specified Celsius setpoint. Provide the temperature value and optionally the device index or name.
Instructions
Set the temperature setpoint for a thermostat.
Args: setpoint: Target temperature in Celsius (e.g., 21.5). idx: Device index. name: Device name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| setpoint | Yes | ||
| idx | No | ||
| name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:626-642 (handler)The `set_temperature_setpoint` tool handler function. It accepts a `setpoint` (float, Celsius), optional `idx` or `name`, resolves the device index, and sends a request to the Domoticz API with param=setsetpoint to set the thermostat temperature.
@mcp.tool() async def set_temperature_setpoint(setpoint: float, idx: int | None = None, name: str | None = None) -> str: """Set the temperature setpoint for a thermostat. Args: setpoint: Target temperature in Celsius (e.g., 21.5). idx: Device index. name: Device name. """ 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"}' response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=setsetpoint&idx={resolved_idx}&setpoint={setpoint}") return response.text - src/domoticz_mcp/server.py:626-627 (registration)The tool is registered with MCP via the `@mcp.tool()` decorator on the `set_temperature_setpoint` function. No separate registration file exists; the decorator registers it automatically.
@mcp.tool() async def set_temperature_setpoint(setpoint: float, idx: int | None = None, name: str | None = None) -> str: - src/domoticz_mcp/server.py:628-634 (schema)The input schema is defined by the function signature and docstring: `setpoint` (float, required), `idx` (int, optional), `name` (str, optional). The docstring describes the parameters.
"""Set the temperature setpoint for a thermostat. Args: setpoint: Target temperature in Celsius (e.g., 21.5). idx: Device index. name: Device name. """ - src/domoticz_mcp/server.py:373-375 (helper)`_resolve_device_idx` is the helper function used by `set_temperature_setpoint` to resolve a device name or idx to its numeric idx for the API call.
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") - src/domoticz_mcp/server.py:354-370 (helper)The generic `_resolve_idx` helper used by `_resolve_device_idx` to look up an entity by name in cached device data.
async def _resolve_idx( client: "httpx.AsyncClient", idx: Optional[int], name: Optional[str], cache: Dict[str, Any], api_url: str ) -> Optional[int]: """Resolve an entity to its idx by either using the provided idx or looking up by name.""" if idx is not None: return idx if not name: return None items = await _get_cached_data(client, cache, api_url) for item in items: if item.get("Name", "").lower() == name.lower(): return int(str(item.get("idx"))) return None