set_fan_speed
Adjust ceiling fan speed levels from 0 (off) to 8 using the Bond Bridge smart home system to control airflow and comfort.
Instructions
Set fan speed for a ceiling fan device.
Args: device_id: The Bond fan device identifier speed: Fan speed level (0-8, where 0 is off)
Returns: Result of the speed change operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | ||
| speed | Yes |
Implementation Reference
- src/bond_mcp/server.py:156-183 (handler)The handler function for the 'set_fan_speed' tool. It is decorated with @mcp.tool(), which registers it in the FastMCP server. The function validates the speed input (0-8), uses BondClient to set the fan speed, and returns the result or error.@mcp.tool() async def set_fan_speed(device_id: str, speed: int) -> Dict[str, Any]: """Set fan speed for a ceiling fan device. Args: device_id: The Bond fan device identifier speed: Fan speed level (0-8, where 0 is off) Returns: Result of the speed change operation. """ if not (0 <= speed <= 8): return {"error": "Fan speed must be between 0 and 8"} try: async with await get_bond_client() as client: result = await client.set_speed(device_id, speed) return { "device_id": device_id, "speed": speed, "action": "off" if speed == 0 else f"set to speed {speed}", "result": result } except BondAPIError as e: return {"error": f"Failed to set fan speed: {str(e)}"} except Exception as e: logger.error(f"Unexpected error setting fan speed: {e}") return {"error": f"Unexpected error: {str(e)}"}