wyze_set_brightness
Adjust the brightness level of a Wyze smart light using a device MAC address and a specified brightness value (0-100) through the MCP Wyze Server.
Instructions
Set brightness for a Wyze light (0-100)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| brightness | Yes | ||
| device_mac | Yes |
Implementation Reference
- src/mcp_wyze_server/server.py:192-231 (handler)The main handler function for the 'wyze_set_brightness' tool. It validates input, finds the device, checks compatibility, and calls the Wyze SDK to set brightness. Registered automatically via the @mcp.tool() decorator.@mcp.tool() def wyze_set_brightness(device_mac: str, brightness: int) -> Dict[str, str]: """Set brightness for a Wyze light (0-100)""" try: if not 0 <= brightness <= 100: return {"status": "error", "message": "Brightness must be between 0 and 100"} client = get_wyze_client() devices = client.devices_list() for device in devices: if device.mac == device_mac: # Get device type - try multiple approaches 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 getattr(device, '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_brightness( device_mac=device_mac, device_model=device_model, brightness=brightness ) return {"status": "success", "message": f"Set {device.nickname} brightness to {brightness}%"} else: return {"status": "error", "message": f"Device {device.nickname} does not support brightness control"} return {"status": "error", "message": f"Device 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)}"}