wyze_set_color
Change the color of Wyze smart lights using hex codes to customize lighting for different moods, tasks, or automation scenarios.
Instructions
Set RGB color for a Wyze light (hex format like 'ff0000' for red)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_mac | Yes | ||
| color | Yes |
Implementation Reference
- src/mcp_wyze_server/server.py:440-479 (handler)The handler function for the 'wyze_set_color' tool. Decorated with @mcp.tool() which registers the tool. Validates hex color input, finds the device by MAC, and calls the Wyze API to set the color on compatible light devices.@mcp.tool() def wyze_set_color(device_mac: str, color: str) -> Dict[str, str]: """Set RGB color for a Wyze light (hex format like 'ff0000' for red)""" try: # Validate hex color format if not color.startswith('#'): color = '#' + color if len(color) != 7 or not all(c in '0123456789abcdefABCDEF' for c in color[1:]): return {"status": "error", "message": "Color must be in hex format (e.g., 'ff0000' or '#ff0000')"} client = get_wyze_client() devices = client.devices_list() for device in devices: if device.mac == device_mac: # Get device type from multiple possible attributes device_type = (getattr(device, 'product_type', None) or getattr(device, 'type', None) or (hasattr(device, 'product') and getattr(device.product, 'type', None)) or 'Unknown') device_model = (getattr(device, 'product_model', None) or (hasattr(device, 'product') and getattr(device.product, 'model', None)) or 'Unknown') if device_type in ['Light', 'Bulb', 'MeshLight', 'LightStrip']: client.bulbs.set_color( device_mac=device_mac, device_model=device_model, color=color ) return {"status": "success", "message": f"Set {device.nickname} color to {color}"} return {"status": "error", "message": f"Light with MAC {device_mac} not found"} except WyzeClientConfigurationError as e: return {"status": "error", "message": f"Configuration error: {str(e)}"} except WyzeRequestError as e: return {"status": "error", "message": f"API error: {str(e)}"} except Exception as e: return {"status": "error", "message": f"Unexpected error: {str(e)}"}
- src/mcp_wyze_server/server.py:440-441 (registration)The @mcp.tool() decorator registers the wyze_set_color function as an MCP tool, with type hints serving as the input schema.@mcp.tool() def wyze_set_color(device_mac: str, color: str) -> Dict[str, str]: