wyze_set_light_sun_match
Adjust Wyze light color temperature to match the time of day by enabling or disabling sun matching. Control smart lighting for natural illumination based on daylight.
Instructions
Enable or disable sun matching for a Wyze light (adjusts color temperature based on time of day)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_mac | Yes | ||
| enabled | No |
Implementation Reference
- src/mcp_wyze_server/server.py:507-530 (handler)The handler function decorated with @mcp.tool() that implements the wyze_set_light_sun_match tool. It finds the device by MAC, checks if it's a light, and calls client.bulbs.set_sun_match(enabled) via Wyze SDK.@mcp.tool() def wyze_set_light_sun_match(device_mac: str, enabled: bool = True) -> Dict[str, str]: """Enable or disable sun matching for a Wyze light (adjusts color temperature based on time of day)""" try: client = get_wyze_client() devices = client.devices_list() for device in devices: if device.mac == device_mac and getattr(device, 'product_type', 'Unknown') in ['Light', 'Bulb', 'MeshLight', 'LightStrip']: client.bulbs.set_sun_match( device_mac=device_mac, device_model=getattr(device, 'product_model', 'Unknown'), sun_match=enabled ) status = "enabled" if enabled else "disabled" return {"status": "success", "message": f"Sun matching {status} for {device.nickname}"} 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:507-507 (registration)The @mcp.tool() decorator registers the wyze_set_light_sun_match function as an MCP tool.@mcp.tool()
- Function signature defines input schema: device_mac (str), enabled (bool, default True); returns Dict[str, str]. Docstring provides description.def wyze_set_light_sun_match(device_mac: str, enabled: bool = True) -> Dict[str, str]:
- src/mcp_wyze_server/server.py:21-44 (helper)Shared helper function to get or initialize the Wyze Client instance used by the tool.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