Skip to main content
Glama
mvellayan

MCP Blinds Controller

by mvellayan
README.md
# MCP Blinds Controller

Control motorized window blinds through Bond Bridge API using Model Context Protocol (MCP).

## Features

- Open, close, or stop blinds movement
- Filter blinds by name, location, or row
- Async HTTP API integration
- MCP server for AI assistant integration

## Setup

1. Install dependencies:
```bash
pip install aiohttp mcp
```

2. Set environment variables:
```bash
export MY_TOKEN="your_bond_token"
export MY_IP="192.168.x.x"
```

3. Configure devices in `data/devices.json`:
```json
[
  {
    "id": "device_id",
    "name": "front",
    "location": "foyer", 
    "row": "top"
  }
]
```

## Usage

### As MCP Server
```bash
python blinds.py
```

### Direct Function Call
```python
from blinds import set_blinds_state

# Open all blinds
await set_blinds_state("Open")

# Close office blinds
await set_blinds_state("Close", blind_location="office")
```

## API Reference

### set_blinds_state(action, blind_name="all", blind_location="all", blind_row="all")

**Parameters:**
- `action`: "Open", "Close", or "Hold"
- `blind_name`: "all", "front", "sunrise", "sunset"
- `blind_location`: "all", "foyer", "office"  
- `blind_row`: "all", "top", "bottom"

## Testing

Run tests:
```bash
pytest test_blinds.py -v
```