Skip to main content
Glama
madorn
by madorn

control_shades

Control motorized shades by opening, closing, or setting precise positions to manage light and privacy in smart homes.

Instructions

Control motorized shades.

Args: device_id: The Bond shade device identifier action: Action to perform ("open", "close", or "set_position") position: Position percentage (0-100) when action is "set_position"

Returns: Result of the shade control operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYes
actionYes
positionNo

Implementation Reference

  • The handler function for the 'control_shades' MCP tool. It is decorated with @mcp.tool(), which also serves as the registration. Validates inputs and calls the Bond client to open, close, or set position of shades.
    @mcp.tool()
    async def control_shades(device_id: str, action: str, position: Optional[int] = None) -> Dict[str, Any]:
        """Control motorized shades.
        
        Args:
            device_id: The Bond shade device identifier
            action: Action to perform ("open", "close", or "set_position")
            position: Position percentage (0-100) when action is "set_position"
            
        Returns:
            Result of the shade control operation.
        """
        valid_actions = ["open", "close", "set_position"]
        if action.lower() not in valid_actions:
            return {"error": f"Action must be one of: {', '.join(valid_actions)}"}
        
        if action.lower() == "set_position" and (position is None or not (0 <= position <= 100)):
            return {"error": "Position must be between 0 and 100 when setting position"}
        
        try:
            async with await get_bond_client() as client:
                if action.lower() == "open":
                    result = await client.open_shades(device_id)
                elif action.lower() == "close":
                    result = await client.close_shades(device_id)
                else:  # set_position
                    result = await client.set_position(device_id, position)
                
                return {
                    "device_id": device_id,
                    "action": action.lower(),
                    "position": position if action.lower() == "set_position" else None,
                    "result": result
                }
        except BondAPIError as e:
            return {"error": f"Failed to control shades: {str(e)}"}
        except Exception as e:
            logger.error(f"Unexpected error controlling shades: {e}")
            return {"error": f"Unexpected error: {str(e)}"}

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/madorn/bond-mcp-server'

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