set_fan_direction
Control ceiling fan airflow direction to optimize comfort and energy efficiency. Change fan rotation between forward (cooling) and reverse (winter) modes for your Bond Bridge device.
Instructions
Set fan direction for a ceiling fan device.
Args: device_id: The Bond fan device identifier direction: Fan direction ("forward" or "reverse")
Returns: Result of the direction change operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | ||
| direction | Yes |
Implementation Reference
- src/bond_mcp/server.py:186-215 (handler)The complete implementation of the 'set_fan_direction' tool handler, including the @mcp.tool() decorator for automatic registration in FastMCP. It validates the direction input, maps 'forward'/'reverse' to 1/-1, calls BondClient.set_direction, and handles errors.@mcp.tool() async def set_fan_direction(device_id: str, direction: str) -> Dict[str, Any]: """Set fan direction for a ceiling fan device. Args: device_id: The Bond fan device identifier direction: Fan direction ("forward" or "reverse") Returns: Result of the direction change operation. """ direction_map = {"forward": 1, "reverse": -1} if direction.lower() not in direction_map: return {"error": "Direction must be 'forward' or 'reverse'"} try: async with await get_bond_client() as client: dir_value = direction_map[direction.lower()] result = await client.set_direction(device_id, dir_value) return { "device_id": device_id, "direction": direction.lower(), "result": result } except BondAPIError as e: return {"error": f"Failed to set fan direction: {str(e)}"} except Exception as e: logger.error(f"Unexpected error setting fan direction: {e}") return {"error": f"Unexpected error: {str(e)}"}