A TypeScript-based Model Context Protocol (MCP) server for Plugwise smart home integration with automatic network discovery. - ๐ค AI Agent Mode: Natural language control via built-in AI agent - ๐ก JSON-RPC Support: Programmatic API for scripting and automation - ๐ Automatic Network Scanning: Discovers all Plugwise hubs on your network - ๐ Credential Management: Stores hub passwords securely from
Add this skill
npx mdskills install Tommertom/plugwise-mcpComprehensive smart home integration with excellent docs, multi-mode operation, and robust discovery features
1# Plugwise MCP Server23A TypeScript-based Model Context Protocol (MCP) server for Plugwise smart home integration with automatic network discovery.45## โจ Key Features67- ๐ค **AI Agent Mode**: Natural language control via built-in AI agent8- ๐ก **JSON-RPC Support**: Programmatic API for scripting and automation9- ๐ **Automatic Network Scanning**: Discovers all Plugwise hubs on your network10- ๐ **Credential Management**: Stores hub passwords securely from .env file11- ๐ **Device Control**: Control thermostats, switches, and smart plugs12- ๐ก๏ธ **Temperature Management**: Set temperatures, presets, and schedules13- ๐ **Energy Monitoring**: Read power consumption and sensor data14- ๐ **Multi-Hub Support**: Manage multiple gateways simultaneously15- ๐ **Real-time Updates**: Get current device states and measurements1617## ๐ Quick Start1819### Installation via npm (Recommended)2021Install globally to use with any MCP client:2223```bash24npm install -g plugwise-mcp-server25```2627Or use directly with npx (no installation needed):2829```bash30npx plugwise-mcp-server31```3233### Installation from Source3435```bash36git clone https://github.com/Tommertom/plugwise-mcp-server.git37cd plugwise-mcp-server38npm install39npm run build40```4142### Prerequisites43- Node.js 17 or higher44- npm or yarn45- Plugwise gateway (Adam, Anna, Smile P1, or Stretch)4647### Quick Test4849Test the installation without real hardware using mock mode:5051```bash52# Test all read operations53npm run test:read-only -- --mock5455# Test protocol features56npm run test:features -- --mock57```5859Or with real hardware:6061```bash62# Set up gateway credentials63echo "PLUGWISE_HOST=192.168.1.100" > .env64echo "PLUGWISE_PASSWORD=your-gateway-password" >> .env6566# Run tests67npm run test:read-only68```6970See [Quick Test Guide](docs/quick-test-guide.md) for more options.7172### Start the Server7374**Option 1: Standard MCP Server** (15+ specialized tools)7576When installed via npm:7778```bash79plugwise-mcp-server80```8182When running from source:8384```bash85npm start86```8788**Option 2: AI Agent Mode** (Single natural language tool)8990```bash91# Interactive mode with prompt92npm run agent "List my devices"93npm run agent "Set living room to 21 degrees"9495# Interactive with verbose debugging96npm run agent "What's the power usage?" -- -v9798# MCP server mode (no arguments)99npm run agent100101# JSON-RPC mode (for scripting)102npm run agent -- --jsonrpc103echo '{"jsonrpc":"2.0","method":"execute","params":{"instruction":"List devices"},"id":1}' | npm run agent -- --jsonrpc104```105106See [Agent Documentation](docs/agent-mcp-server.md) and [JSON-RPC Mode](docs/jsonrpc-mode.md) for details.107108## ๐ Adding the MCP Server to Your Client109110The Plugwise MCP server can work with any MCP client that supports standard I/O (stdio) as the transport medium. Choose between:111112- **Standard Mode**: 15+ specialized tools for direct device control113- **Agent Mode**: Single `manage_plugwise` tool with natural language interface114115### Claude Desktop116117**Standard Mode** (15+ tools):118119```json120{121 "mcpServers": {122 "plugwise": {123 "command": "npx",124 "args": ["-y", "plugwise-mcp-server@latest"],125 "env": {126 "HUB1": "abc12345",127 "HUB1IP": "192.168.1.100",128 "HUB2": "def67890",129 "HUB2IP": "192.168.1.101"130 }131 }132 }133}134```135136**Agent Mode** (natural language):137138```json139{140 "mcpServers": {141 "plugwise-agent": {142 "command": "node",143 "args": ["/path/to/plugwise/dist/cli/plugwise-agent-cli.js"],144 "env": {145 "OPENAI_API_KEY": "sk-...",146 "PLUGWISE_AGENT_MODEL": "gpt-4o-mini"147 }148 }149 }150}151```152153### Cline154155To configure Cline to use the Plugwise MCP server, edit the `cline_mcp_settings.json` file. You can open or create this file by clicking the MCP Servers icon at the top of the Cline pane, then clicking the Configure MCP Servers button.156157```json158{159 "mcpServers": {160 "plugwise": {161 "command": "npx",162 "args": ["-y", "plugwise-mcp-server@latest"],163 "disabled": false,164 "env": {165 "HUB1": "abc12345",166 "HUB1IP": "192.168.1.100",167 "HUB2": "def67890",168 "HUB2IP": "192.168.1.101"169 }170 }171 }172}173```174175### Cursor176177To configure Cursor to use the Plugwise MCP server, edit either the file `.cursor/mcp.json` (to configure only a specific project) or the file `~/.cursor/mcp.json` (to make the MCP server available in all projects):178179```json180{181 "mcpServers": {182 "plugwise": {183 "command": "npx",184 "args": ["-y", "plugwise-mcp-server@latest"],185 "env": {186 "HUB1": "abc12345",187 "HUB1IP": "192.168.1.100",188 "HUB2": "def67890",189 "HUB2IP": "192.168.1.101"190 }191 }192 }193}194```195196### Visual Studio Code Copilot197198To configure a single project, edit the `.vscode/mcp.json` file in your workspace:199200```json201{202 "servers": {203 "plugwise": {204 "type": "stdio",205 "command": "npx",206 "args": ["-y", "plugwise-mcp-server@latest"],207 "env": {208 "HUB1": "abc12345",209 "HUB1IP": "192.168.1.100",210 "HUB2": "def67890",211 "HUB2IP": "192.168.1.101"212 }213 }214 }215}216```217218To make the server available in every project you open, edit your user settings:219220```json221{222 "mcp": {223 "servers": {224 "plugwise": {225 "type": "stdio",226 "command": "npx",227 "args": ["-y", "plugwise-mcp-server@latest"],228 "env": {229 "HUB1": "abc12345",230 "HUB1IP": "192.168.1.100",231 "HUB2": "def67890",232 "HUB2IP": "192.168.1.101"233 }234 }235 }236 }237}238```239240### Windsurf Editor241242To configure Windsurf Editor, edit the file `~/.codeium/windsurf/mcp_config.json`:243244```json245{246 "mcpServers": {247 "plugwise": {248 "command": "npx",249 "args": ["-y", "plugwise-mcp-server@latest"],250 "env": {251 "HUB1": "abc12345",252 "HUB1IP": "192.168.1.100",253 "HUB2": "def67890",254 "HUB2IP": "192.168.1.101"255 }256 }257 }258}259```260261### Environment Variables262263The server reads hub passwords from environment variables. You can provide these in two ways:264265**Option 1: MCP Configuration (Recommended)**266Add the `env` field directly to your MCP client configuration as shown in the examples above.267268**Option 2: .env File**269Create a `.env` file in your project root or set system-wide environment variables:270271```env272# Hub passwords (8-character codes from gateway stickers)273HUB1=abc12345274HUB2=def67890275276# Optional: Known IP addresses for faster discovery and auto-loading277HUB1IP=192.168.1.100278HUB2IP=192.168.1.101279```280281**Security Note**: When using the MCP configuration `env` field, credentials are passed securely to the server process. For enhanced security, consider using `.env` files which are typically excluded from version control.282283### Quick Test284285```bash286# Automatically discover and connect to your hubs287node scripts/workflow-demo.js288```289290## ๐ก MCP Tools291292### Network Discovery293294#### `connect`295Connect to a Plugwise gateway.296297```javascript298// Connect to specific hub299await mcpClient.callTool('connect', { host: '192.168.1.100' });300301// Manual connection302await mcpClient.callTool('connect', {303 host: '192.168.1.100',304 password: 'abc12345'305});306```307308### Device Management309310#### `get_devices`311Get all devices and their current states.312313```javascript314const result = await mcpClient.callTool('get_devices', {});315// Returns all devices, zones, sensors, and their current values316```317318### Climate Control319320#### `set_temperature`321Set thermostat temperature setpoint.322323```javascript324await mcpClient.callTool('set_temperature', {325 location_id: 'zone123',326 setpoint: 21.0327});328```329330#### `set_preset`331Change thermostat preset mode.332333```javascript334await mcpClient.callTool('set_preset', {335 location_id: 'zone123',336 preset: 'away' // Options: home, away, sleep, vacation337});338```339340### Device Control341342#### `control_switch`343Turn switches/plugs on or off.344345```javascript346await mcpClient.callTool('control_switch', {347 appliance_id: 'plug123',348 state: 'on' // 'on' or 'off'349});350```351352### Gateway Management353354- **`set_gateway_mode`**: Set gateway mode (home, away, vacation)355- **`set_dhw_mode`**: Set domestic hot water mode (auto, boost, comfort, off)356- **`set_regulation_mode`**: Set heating regulation mode357- **`delete_notification`**: Clear gateway notifications358- **`reboot_gateway`**: Reboot the gateway (use with caution)359360### MCP Resources361362- **`plugwise://devices`**: Access current state of all devices as a resource363364### MCP Prompts365366- **`setup_guide`**: Get comprehensive step-by-step setup instructions367368## ๐งช Testing369370### Comprehensive Read-Only Test Suite371372```bash373npm run test:all374```375376This runs a complete test of all read-only MCP operations:377- โ Server health check378- โ MCP protocol initialization379- โ Network scanning for hubs380- โ Gateway connection and info retrieval381- โ Device state reading382- โ Resources and prompts383384**Safe**: Only tests read operations, never changes device states.385386See [Test Documentation](docs/test-all-script.md) for details.387388### Complete Workflow Demo389390```bash391node scripts/workflow-demo.js392```393394This demonstrates:3951. โ Network scanning with .env passwords3962. โ Auto-connection without credentials3973. โ Device discovery and listing3984. โ Multi-hub management399400### Network Scanning Test401402```bash403node scripts/test-network-scan.js404```405406### Full MCP Test Suite407408```bash409node scripts/test-mcp-server.js410```411412### Bash Script for Hub Discovery413414```bash415./scripts/find-plugwise-hub.sh416```417418## ๐๏ธ Supported Devices419420### Gateways421- **Adam**: Smart home hub with OpenTherm support (thermostat control, floor heating)422- **Anna**: Standalone thermostat gateway423- **Smile P1**: Energy monitoring gateway (electricity, gas, solar)424- **Stretch**: Legacy hub for connecting Circle smart plugs425426### Connected Devices427- **Jip**: Motion sensor with illuminance detection428- **Lisa**: Radiator valve (requires hub)429- **Tom/Floor**: Floor heating controller430- **Koen**: Radiator valve (requires a Plug as intermediary)431- **Plug**: Smart plug with power monitoring (Zigbee)432- **Aqara Plug**: Third-party Zigbee smart plug433- **Circle**: Legacy Circle/Circle+ plugs (via Stretch only)434435## ๐ Documentation436437- **[Setup Guide](docs/setup.md)** - Detailed setup instructions438- **[MCP Server Documentation](docs/plugwise-mcp-server.md)** - Complete API reference439- **[Network Scanning Guide](docs/network-scanning.md)** - Network discovery deep dive440- **[Network Scanning Summary](docs/network-scanning-summary.md)** - Feature overview441442## ๐ง Development443444### Development Mode445446Run with hot-reload:447448```bash449npm run dev450```451452### Build453454Compile TypeScript to JavaScript:455456```bash457npm run build458```459460### Project Structure461462```463plugwise/464โโโ src/mcp/ # TypeScript source465โ โโโ server.ts # MCP server with tools466โ โโโ plugwise-client.ts # Plugwise API client467โ โโโ plugwise-types.ts # Type definitions468โโโ build/mcp/ # Compiled JavaScript469โโโ docs/ # Documentation470โโโ scripts/ # Test scripts471โ โโโ workflow-demo.js472โ โโโ test-network-scan.js473โ โโโ test-mcp-server.js474โ โโโ find-plugwise-hub.sh475โโโ .env # Hub credentials476โโโ package.json477โโโ tsconfig.json478```479480## ๐ Security4814821. **Password Storage**: Store passwords in `.env` file only (never in code)4832. **Git Ignore**: `.env` is in `.gitignore` to prevent committing secrets4843. **Network Security**: Plugwise uses HTTP Basic Auth (not HTTPS)485 - Keep gateways on secure local network486 - Use VPN for remote access487 - Consider separate VLAN for IoT devices4884. **API Access**: The API has full control over your heating system - restrict access accordingly489490## ๐ Troubleshooting491492### No Hubs Found During Scan4934941. Check `.env` file has `HUB1`, `HUB2`, etc. defined4952. Verify passwords are correct (case-sensitive, check gateway sticker)4963. Ensure gateways are powered on and connected to network4974. Confirm you're on the same network as the hubs4985. Try: `ping <gateway_ip>` to test connectivity499500### Connection Errors5015021. Verify IP address is correct5032. Check firewall isn't blocking port 805043. Test with manual connection: `curl http://<ip>/core/domain_objects`5054. Ensure gateway isn't overloaded with requests506507## ๐ค Integration Examples508509### Using with Claude Code510511```bash512claude mcp add --transport http plugwise-server http://localhost:3000/mcp513```514515### Using with VS Code Copilot516517Add to `.vscode/mcp.json`:518519```json520{521 "mcpServers": {522 "plugwise": {523 "type": "http",524 "url": "http://localhost:3000/mcp"525 }526 }527}528```529530### Using MCP Inspector531532```bash533npx @modelcontextprotocol/inspector534```535536Connect to: `http://localhost:3000/mcp`537538## ๐ Example Workflows539540### Morning Routine541542```javascript543// Connect to hub544await mcpClient.callTool('connect', { host: '192.168.1.100' });545546// Set home mode547await mcpClient.callTool('set_preset', {548 location_id: 'living_room',549 preset: 'home'550});551552// Warm up bathroom553await mcpClient.callTool('set_temperature', {554 location_id: 'bathroom',555 setpoint: 22.0556});557```558559### Energy Monitoring560561```javascript562const devices = await mcpClient.callTool('get_devices', {});563564for (const [id, device] of Object.entries(devices.data)) {565 if (device.sensors?.electricity_consumed) {566 console.log(`${device.name}: ${device.sensors.electricity_consumed}W`);567 }568}569```570571### Multi-Hub Management572573```javascript574// List all hubs575const hubsList = await mcpClient.callTool('list_hubs', {});576577// Get devices from each hub578for (const hub of hubsList.hubs) {579 await mcpClient.callTool('connect', { host: hub.ip });580 const devices = await mcpClient.callTool('get_devices', {});581 console.log(`Hub ${hub.ip}: ${Object.keys(devices.data).length} devices`);582}583```584585## ๐ Documentation586587### Migration Guides588589- **[Structure Migration Plan](docs/STRUCTURE-MIGRATION-PLAN.md)** - Complete plan for restructuring project590- **[Structure Comparison](docs/structure-comparison-diagram.md)** - Visual comparison of architectures591- **[Migration Checklist](docs/migration-checklist.md)** - Step-by-step migration checklist592- **[Migration Summary](docs/migration-summary.md)** - Quick reference summary593594### Architecture & Design595596- **[Architecture Diagram](docs/architecture-diagram.md)** - System architecture overview597- **[Code Organization](docs/code-organization.md)** - Project structure and conventions598- **[Reorganization Overview](docs/reorganization-overview.md)** - Historical reorganization notes599600### Implementation Guides601602- **[Autoload Hubs](docs/autoload-hubs.md)** - Automatic hub loading implementation603- **[Network Scanning](docs/network-scanning.md)** - Network discovery implementation604- **[Temperature Tools](docs/temperature-tools-implementation.md)** - Temperature control features605- **[Sensor & Switch Parsing](docs/sensor-switch-parsing-implementation.md)** - Device parsing logic606607### Quick References608609- **[Quick Reference](docs/quick-reference.md)** - Common commands and patterns610- **[Autoload Quick Reference](docs/autoload-quickref.md)** - Autoload feature guide611- **[Temperature Tools Quick Reference](docs/temperature-tools-quick-reference.md)** - Temperature API guide612613### Testing & Development614615- **[Quick Test Guide](docs/quick-test-guide.md)** - Fast start testing guide616- **[Test Scripts Documentation](docs/test-scripts.md)** - Comprehensive testing documentation617- **[Test All Script](docs/test-all-script.md)** - HTTP-based testing guide618- **[Multi-Hub Testing](docs/multi-hub-testing.md)** - Testing with multiple hubs619- **[List Devices Script](docs/list-devices-script.md)** - Device enumeration guide620621### Publishing & Setup622623- **[Publishing Guide](docs/publishing-guide.md)** - How to publish to npm624- **[Setup Guide](docs/setup.md)** - Initial setup instructions625- **[Publish Checklist](docs/PUBLISH-CHECKLIST.md)** - Pre-publish verification626627## ๐ Credits628629Based on the excellent [python-plugwise](https://github.com/plugwise/python-plugwise) library.630631Architectural patterns inspired by [sonos-ts-mcp](https://github.com/Tommertom/sonos-ts-mcp).632633## ๐ License634635MIT License - See LICENSE file for details636637## ๐ Version638639Current version: **1.0.2**640641- โ Full MCP protocol support642- โ Automatic network scanning643- โ Multi-hub management644- โ Complete device control645- โ Comprehensive documentation646- โ Structure migration planning647
Full transparency โ inspect the skill content before installing.