{"_id":"@caseman72/switchr-mcp","_rev":"3-3e17c03997eb565b3ced36f937c7d228","name":"@caseman72/switchr-mcp","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.1":{"name":"@caseman72/switchr-mcp","version":"1.0.1","keywords":["switch-bot","mcp","smart-home","home-assistant"],"license":"MIT","_id":"@caseman72/switchr-mcp@1.0.1","maintainers":[{"name":"caseman72","email":"casey@manion.com"}],"dist":{"shasum":"f5a6cbde0ad0dd40131650d4ab9b79e178a41751","tarball":"https://registry.npmjs.org/@caseman72/switchr-mcp/-/switchr-mcp-1.0.1.tgz","fileCount":15,"integrity":"sha512-ka2j8Lz3Fr50vTzT9lu+1eboyqufsT4ytvyNrEShnEjrEtjdyHLdTXJj5nMbf7IR711iC8Y5VyLRSkzIZqj8Ug==","signatures":[{"sig":"MEQCIDC4DG13zfPJUWA5kI6R84KvCAMptvcPiEKV4/moaghuAiAhpK7Aw4VulJe6lXQJ9r44t7jSMtkUz072fMw1JgHwnQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30504},"main":"src/index.js","type":"module","gitHead":"bd17389e3d2cc018026febed54f73aff96ad4755","scripts":{"start":"node src/index.js","start:http":"node src/index.js --http"},"_npmUser":{"name":"caseman72","email":"casey@manion.com"},"_npmVersion":"11.11.0","description":"MCP server for Switch Bot temperature sensors","directories":{},"_nodeVersion":"25.8.1","dependencies":{"zod":"^3.25.0","@caseman72/switchr-api":"^1.0.2","@modelcontextprotocol/sdk":"^1.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/switchr-mcp_1.0.1_1773913754630_0.003143159574310106","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@caseman72/switchr-mcp","version":"1.1.0","keywords":["switch-bot","mcp","smart-home","home-assistant"],"license":"MIT","_id":"@caseman72/switchr-mcp@1.1.0","maintainers":[{"name":"caseman72","email":"casey@manion.com"}],"dist":{"shasum":"0bb6f668c7232fb6acd665c5eeffb8b69e86e298","tarball":"https://registry.npmjs.org/@caseman72/switchr-mcp/-/switchr-mcp-1.1.0.tgz","fileCount":15,"integrity":"sha512-isCch5gui09ycN+0s1IMG3pnWgm0/ZLhE6JjfopSetYCfmEE61pP9QjkXF/N66cKS+kxZPThiphV4jVDg3zq9Q==","signatures":[{"sig":"MEUCIQCAg/GLden5R5R2nc/ZztEcqmgVsl6HNMPZSChp43X5DwIgeOGqUZx5n74KAbSGW9n/DD2hwT1in0xlhSy4Za7DkME=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42348},"main":"src/index.js","type":"module","gitHead":"091d5275cf880d30803205ad9747dc9db6446105","scripts":{"start":"node src/index.js","start:http":"node src/index.js --http"},"_npmUser":{"name":"caseman72","email":"casey@manion.com"},"_npmVersion":"11.3.0","description":"MCP server for Switch Bot temperature sensors","directories":{},"_nodeVersion":"24.0.2","dependencies":{"zod":"^3.25.0","@caseman72/switchr-api":"^1.1.0","@modelcontextprotocol/sdk":"^1.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/switchr-mcp_1.1.0_1777589065466_0.3962090017439597","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@caseman72/switchr-mcp","version":"1.1.1","description":"MCP server for Switch Bot temperature sensors","type":"module","main":"src/index.js","scripts":{"start":"node src/index.js","start:http":"node src/index.js --http"},"keywords":["switch-bot","mcp","smart-home","home-assistant"],"license":"MIT","dependencies":{"@caseman72/switchr-api":"^1.1.0","@modelcontextprotocol/sdk":"^1.0.0","zod":"^3.25.0"},"_id":"@caseman72/switchr-mcp@1.1.1","gitHead":"5805dc397ec2e7ebdca0730873e33b234962e6ce","_nodeVersion":"24.0.2","_npmVersion":"11.3.0","dist":{"integrity":"sha512-F/6GHr7sKHNprXsZVNKk0TdKAWBrTIi/2btR0+fMlVxfrrtkkT2fi7g1KLMze+gEX8jZq2UNOXxvCXqwESJnNw==","shasum":"a080855028aee6a91ad3b735612785d44380933a","tarball":"https://registry.npmjs.org/@caseman72/switchr-mcp/-/switchr-mcp-1.1.1.tgz","fileCount":18,"unpackedSize":47416,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCMS3PB+rqq2HdNI6fdFAxzATia5yLKHK46ZgzuLZ/YvgIgPqTQqfl98TU6zrRxgWiKIXvhy17sBFtgYxReUIQTMN4="}]},"_npmUser":{"name":"caseman72","email":"casey@manion.com"},"directories":{},"maintainers":[{"name":"caseman72","email":"casey@manion.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/switchr-mcp_1.1.1_1777590155593_0.5450314458905372"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-19T09:49:14.532Z","modified":"2026-04-30T23:02:35.821Z","1.0.1":"2026-03-19T09:49:14.784Z","1.1.0":"2026-04-30T22:44:25.651Z","1.1.1":"2026-04-30T23:02:35.720Z"},"license":"MIT","keywords":["switch-bot","mcp","smart-home","home-assistant"],"description":"MCP server for Switch Bot temperature sensors","maintainers":[{"name":"caseman72","email":"casey@manion.com"}],"readme":"# Switchr MCP Server\n\nA Node.js MCP (Model Context Protocol) server that exposes SwitchBot temperature sensors for monitoring via Claude Desktop or Home Assistant.\n\n## Features\n\n- **Device Discovery**: Automatically discovers all SwitchBot devices (Meter, MeterPlus, WoIOSensor, Plug Mini, Bot)\n- **Temperature Monitoring**: Read temperature and humidity from any sensor\n- **Energy Monitoring**: Read power, voltage, and current from Plug Mini devices (UPS/load monitoring)\n- **Switching**: Turn plugs on/off, press Bot finger simulators\n- **Flexible Units**: Support for both Fahrenheit and Celsius\n- **Device Lookup**: Find devices by ID or nickname (case-insensitive)\n- **Dual Transport**: Supports both stdio (Claude Desktop) and HTTP/SSE (Home Assistant)\n- **Request Logging**: Optional logging of all tool calls for debugging\n\n## Installation\n\n```bash\ncd switchr-mcp\nnpm install\n```\n\n## Configuration\n\n### SwitchBot Credentials\n\nSwitchBot API credentials are managed by [@caseman72/switchr-api](https://github.com/caseman72/switchr-api) via `.env.local`. The file is searched in:\n\n1. Current working directory\n2. `~/.config/switchr-api/.env.local`\n3. `~/.switchbot.env.local`\n\nCreate a `.env.local` file with your SwitchBot credentials:\n\n```bash\nSWITCHBOT_TOKEN=your-switchbot-token\nSWITCHBOT_SECRET=your-switchbot-secret\n```\n\nVisit the [SwitchBot Developer Portal](https://support.switch-bot.com/hc/en-us/articles/12822710195351-How-to-obtain-a-Token) to obtain your API credentials.\n\n### Server Configuration (Optional)\n\nCopy `config.example.json` to `config.json` to customize server settings:\n\n```json\n{\n  \"server\": {\n    \"transport\": \"stdio\",\n    \"httpPort\": 8001,\n    \"httpHost\": \"127.0.0.1\"\n  },\n  \"devices\": {\n    \"refreshIntervalMinutes\": 60\n  },\n  \"monitoring\": {\n    \"enabled\": false,\n    \"logFile\": \"./switchr-mcp-requests.log\"\n  }\n}\n```\n\n## Usage\n\n### stdio Transport (Claude Desktop)\n\n```bash\nnode src/index.js\n```\n\n### HTTP Transport (Home Assistant)\n\nThe HA custom component requires the MCP server to be exposed over HTTP/SSE. Use `mcp-proxy` to bridge the stdio server.\n\n#### Install mcp-proxy\n\n```bash\nbrew install mcp-proxy\n```\n\n#### Start the proxy\n\n```bash\n# Binds to all interfaces so Docker can reach it\nmcp-proxy --port 8082 --host 0.0.0.0 -- node /path/to/switchr-mcp/src/index.js\n```\n\n### Home Assistant Integration\n\n1. Copy the custom component to your HA config directory:\n   ```bash\n   cp -r custom_components/switchr_mcp ~/.home-assistant/custom_components/\n   ```\n\n2. Restart Home Assistant\n\n3. Add the integration: Settings → Devices & Services → Add Integration → \"Switchr MCP\"\n\n4. Enter connection details:\n   - Host: `host.docker.internal` (for Docker) or your Mac's IP\n   - Port: `8082`\n\n#### Entities created\n\n- **Temperature sensors** (`Meter`, `MeterPlus`, `WoIOSensor`): one combined entity per device with temperature as the native value and humidity/battery as attributes.\n- **Plug Mini**: four sensors plus a switch — `<name> Power` (W), `<name> Voltage` (V), `<name> Current` (mA), `<name> Energy` (kWh), and `switch.<name>` (on/off control). The Energy entity integrates instantaneous power between polls and persists across HA restarts via `RestoreEntity`, so it can be used directly in the HA Energy dashboard with no Riemann helper.\n- **Bot** (finger simulator): `button.<name>_press` — sends a momentary press (extend then retract). Suitable for `pressMode` Bots.\n\n#### Auto-start mcp-proxy with launchd\n\nCreate `~/Library/LaunchAgents/com.switchr.mcp-proxy.plist`:\n\n```xml\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n    <key>Label</key>\n    <string>com.switchr.mcp-proxy</string>\n    <key>ProgramArguments</key>\n    <array>\n        <string>/opt/homebrew/bin/mcp-proxy</string>\n        <string>--port</string>\n        <string>8082</string>\n        <string>--host</string>\n        <string>0.0.0.0</string>\n        <string>--</string>\n        <string>/opt/homebrew/bin/node</string>\n        <string>/path/to/switchr-mcp/src/index.js</string>\n    </array>\n    <key>WorkingDirectory</key>\n    <string>/path/to/switchr-mcp</string>\n    <key>RunAtLoad</key>\n    <true/>\n    <key>KeepAlive</key>\n    <true/>\n    <key>StandardOutPath</key>\n    <string>/tmp/switchr-mcp-proxy.log</string>\n    <key>StandardErrorPath</key>\n    <string>/tmp/switchr-mcp-proxy.err</string>\n</dict>\n</plist>\n```\n\nThen load it:\n```bash\nlaunchctl load ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist\n```\n\nTo stop/unload:\n```bash\nlaunchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist\n```\n\n#### Managing the service\n\n```bash\n# Check status\nlaunchctl list | grep switchr\n\n# View logs\ntail -f /tmp/switchr-mcp-proxy.err\n\n# Restart\nlaunchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist\nlaunchctl load ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist\n\n# Stop\nlaunchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist\n```\n\n### Claude Desktop Integration\n\nAdd to `~/.claude/claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"switchr\": {\n      \"command\": \"node\",\n      \"args\": [\"/path/to/switchr-mcp/src/index.js\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n## MCP Tools\n\n### `list_devices`\n\nList all discovered SwitchBot devices. Optionally filter to show only temperature sensors.\n\n**Parameters:**\n- `sensorsOnly` (optional): If true, only return temperature sensors (Meter, MeterPlus, WoIOSensor)\n- `refresh` (optional): Force refresh device list from SwitchBot API\n\n### `get_device_status`\n\nGet detailed status of any SwitchBot device. Returns device-specific properties like power state, battery level, etc.\n\n**Parameters:**\n- `deviceId`: Device ID or device name\n\n### `get_temperature`\n\nGet temperature and humidity reading from a specific SwitchBot temperature sensor.\n\n**Parameters:**\n- `deviceId`: Device ID or device name of the temperature sensor\n- `unit` (optional): Temperature unit - `F` for Fahrenheit (default), `C` for Celsius\n\n**Response includes:**\n- `temperature`: Current temperature in requested unit\n- `humidity`: Current humidity percentage\n- `battery`: Battery level percentage\n\n### `get_all_temperatures`\n\nGet temperature and humidity readings from all SwitchBot temperature sensors at once.\n\n**Parameters:**\n- `unit` (optional): Temperature unit - `F` for Fahrenheit (default), `C` for Celsius\n\n### `get_plug_status`\n\nGet power state and energy data from a SwitchBot Plug Mini. Use for UPS/energy monitoring.\n\n**Parameters:**\n- `deviceId`: Device ID or device name of the plug\n\n**Response includes:**\n- `power`: `\"on\"` or `\"off\"`\n- `voltage`: Volts\n- `watts`: Instantaneous power draw (W)\n- `currentMilliamps`: Current draw (mA)\n- `electricityOfDay`: Today's on-time accumulator from the device\n\n### `get_all_plugs`\n\nGet power and energy readings from all SwitchBot Plug Mini devices at once.\n\n### `turn_on` / `turn_off`\n\nTurn a SwitchBot Plug Mini (or a Bot in switch mode) on/off.\n\n**Parameters:**\n- `deviceId`: Device ID or device name\n\n### `press_bot`\n\nSend a momentary press to a SwitchBot Bot (finger simulator). The finger extends then retracts.\n\n**Parameters:**\n- `deviceId`: Device ID or device name of the Bot\n\n### `get_api_status`\n\nGet SwitchBot API rate limit status. Returns remaining calls, reset time, and cache info.\n\n**Response includes:**\n- `rate_limit.remaining`: API calls remaining\n- `rate_limit.reset_by`: When the rate limit resets\n- `cache.last_refresh`: When devices were last refreshed\n- `cache.device_count`: Total devices discovered\n- `cache.sensor_count`: Temperature sensors discovered\n\n## Request Monitoring\n\nEnable request logging in config.json:\n\n```json\n{\n  \"monitoring\": {\n    \"enabled\": true,\n    \"logFile\": \"./switchr-mcp-requests.log\"\n  }\n}\n```\n\nLogs are written in JSON Lines format with timestamps, tool names, parameters, and results.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}