Skip to main content
Glama

toggle_device_power

Control power states for smart home devices by turning them on or off using device identifiers. This tool manages Bond Bridge-connected devices through toggle commands.

Instructions

Toggle power state of a Bond device (on/off).

Args: device_id: The Bond device identifier

Returns: Result of the toggle operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYes

Implementation Reference

  • The async handler function decorated with @mcp.tool(), which registers and implements the toggle_device_power tool. It fetches the current device state, determines if it's on or off, calls the appropriate BondClient method (turn_on or turn_off), and returns the action performed and result.
    @mcp.tool() async def toggle_device_power(device_id: str) -> Dict[str, Any]: """Toggle power state of a Bond device (on/off). Args: device_id: The Bond device identifier Returns: Result of the toggle operation. """ try: async with await get_bond_client() as client: # Get current state to determine action current_state = await client.get_device_state(device_id) power = current_state.get("power", 0) if power == 1: result = await client.turn_off(device_id) action = "turned off" else: result = await client.turn_on(device_id) action = "turned on" return { "device_id": device_id, "action": action, "result": result } except BondAPIError as e: return {"error": f"Failed to toggle device power: {str(e)}"} except Exception as e: logger.error(f"Unexpected error toggling device power: {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