Skip to main content
Glama

get_device_status

Retrieve the current state and information for a WeMo smart home device using its name or IP address to monitor power status and device details.

Instructions

Get the current status of a WeMo device.

Retrieves the current state and information for a device by name or IP address. The device must have been discovered via scan_network first.

Args:

device_identifier: Device name (e.g., "Office Light") or IP address (e.g., "192.168.1.100")

Returns:

Dictionary containing:
- device_name: Name of the device
- state: Current state ("on" or "off")
- Additional device information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_identifierYes

Implementation Reference

  • The handler for the 'get_device_status' MCP tool, which validates input, retrieves a device object from cache, and fetches status/state.
    async def get_device_status(device_identifier: str) -> dict[str, Any]:
        """Get the current status of a WeMo device.
    
        Retrieves the current state and information for a device by name or IP address.
        The device must have been discovered via scan_network first.
    
        Args:
        ----
            device_identifier: Device name (e.g., "Office Light") or IP address (e.g., "192.168.1.100")
    
        Returns:
        -------
            Dictionary containing:
            - device_name: Name of the device
            - state: Current state ("on" or "off")
            - Additional device information
    
        """
        # Validate input
        try:
            param = DeviceIdentifierParam(device_identifier=device_identifier)
        except ValidationError as e:
            return {
                "error": ERR_INVALID_PARAMS,
                "validation_errors": [
                    {"field": err["loc"][0], "message": err["msg"], "input": err["input"]}
                    for err in e.errors()
                ],
            }
    
        try:
            # Try to find device in memory cache, then reconnect from file cache if needed
            device = _device_cache.get(param.device_identifier)
            if not device:
                device = await _reconnect_device_from_cache(param.device_identifier)
    
            if not device:
                return {
                    "error": f"Device '{param.device_identifier}' not found in cache",
                    "suggestion": ERR_RUN_SCAN_FIRST,
                    "available_devices": [
                        k
                        for k in _device_cache
                        if isinstance(k, str) and not k.replace(".", "").isdigit()
                    ],
                }
    
            # Get device state with retry
            state = await _get_device_state_with_retry(device)
    
            # Extract full device info
            device_info = extract_device_info(device)
            device_info["state"] = "on" if state else "off"
            device_info["status_retrieved_at"] = time.time()
    
            # Add brightness for dimmer devices
            if hasattr(device, "get_brightness"):
                brightness = await _get_device_brightness_with_retry(device)
                device_info["brightness"] = brightness
                device_info["is_dimmer"] = True
            else:
                device_info["is_dimmer"] = False
    
            logger.info(
                f"Status retrieved for {device.name}: {device_info['state']}"
                + (
                    f" Brightness: {device_info.get('brightness')}"
                    if device_info.get("is_dimmer")
                    else ""
                ),
            )
            return device_info
    
        except Exception as e:
            logger.error(f"Error getting device status: {e}", exc_info=True)
            return build_error_response(
                e,
                "Get device status",
                context={"device_identifier": device_identifier},
            )

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/apiarya/wemo-mcp-server'

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