wyze_set_color
Set custom RGB colors for Wyze smart lights using hex values (e.g., 'ff0000' for red) via the MCP Wyze Server. Control and personalize lighting for connected devices directly through AI assistants.
Instructions
Set RGB color for a Wyze light (hex format like 'ff0000' for red)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| color | Yes | ||
| device_mac | Yes |
Implementation Reference
- src/mcp_wyze_server/server.py:440-480 (handler)The complete implementation of the wyze_set_color MCP tool. The @mcp.tool() decorator registers the function as a tool and uses the signature/docstring for input schema. The handler validates hex color input, retrieves Wyze client, finds the light device by MAC, and calls the wyze-sdk bulbs.set_color method to apply the color.@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:21-45 (helper)Helper function used by wyze_set_color to obtain the authenticated Wyze SDK client instance from environment variables.def get_wyze_client() -> Client: """Get or create Wyze client instance with auto-login if credentials available""" global _wyze_client if _wyze_client is None: # Get credentials from environment email = os.getenv("WYZE_EMAIL") password = os.getenv("WYZE_PASSWORD") key_id = os.getenv("WYZE_KEY_ID") api_key = os.getenv("WYZE_API_KEY") if not all([email, password, key_id, api_key]): raise WyzeClientConfigurationError( "Missing required environment variables: WYZE_EMAIL, WYZE_PASSWORD, WYZE_KEY_ID, WYZE_API_KEY" ) _wyze_client = Client( email=email, password=password, key_id=key_id, api_key=api_key ) return _wyze_client