wyze_turn_on_device
Activate a Wyze smart light device by providing its MAC address. This tool enables control of connected lighting through the MCP Wyze Server for smart home automation.
Instructions
Turn on a Wyze light device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_mac | Yes |
Implementation Reference
- src/mcp_wyze_server/server.py:120-153 (handler)The core handler function for the 'wyze_turn_on_device' tool, decorated with @mcp.tool() for automatic registration in FastMCP. It authenticates the Wyze client, lists all devices to find the one matching the provided MAC address, determines the device model and type, and calls the wyze-sdk's bulbs.turn_on method if it's a supported light device. Returns status dictionary.@mcp.tool() def wyze_turn_on_device(device_mac: str) -> Dict[str, str]: """Turn on a Wyze light device""" try: 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.turn_on(device_mac=device_mac, device_model=device_model) else: return {"status": "error", "message": f"Device type '{device_type}' is not a supported light device"} return {"status": "success", "message": f"Device {device.nickname} turned on"} 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)}"}
- src/mcp_wyze_server/server.py:21-44 (helper)Helper function used by the wyze_turn_on_device handler (and other tools) to obtain or create the singleton Wyze SDK client instance, loading credentials 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