Skip to main content
Glama

wyze_turn_on_device

Turn on a Wyze light device using its MAC address. Part of the MCP Wyze Server, enabling control of smart home devices via AI assistants for real-time management.

Instructions

Turn on a Wyze light device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_macYes

Implementation Reference

  • The wyze_turn_on_device tool handler. This function is decorated with @mcp.tool(), registering it as an MCP tool. It retrieves the Wyze client, lists devices, finds the specified device by MAC address, verifies it's a light device, and calls the Wyze SDK's bulbs.turn_on method to turn it on.
    @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)}"}
  • The @mcp.tool() decorator registers the wyze_turn_on_device function as an MCP tool.
    @mcp.tool()
  • Helper function get_wyze_client() used by the tool to obtain the authenticated Wyze SDK client instance.
    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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aldilaff/mcp-wyze-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server