node-red-contrib-switchbot-openapi 1.0.3
SwitchBot device control and status nodes for Node-RED
node-red-contrib-switchbot-openapi
SwitchBot device control and status nodes for Node-RED.
Features
- 📊 SwitchBot Status - Get device status (temperature, humidity, CO2, motion detection, etc.)
- 🎮 SwitchBot Command - Send commands to devices (turn on/off, set temperature, etc.)
- 🔐 Shared Credentials - Configure API credentials once, use across all nodes
- 📋 Device Picker - Select devices from a dropdown list (no manual ID entry needed)
- 🔄 Dynamic Commands - Command options change based on selected device type
Supported Devices
Status (SwitchBot Status node)
| Device Type | Available Data |
|---|---|
| Presence Sensor / Motion Sensor | Motion detection, light level |
| Meter / Meter Plus / Outdoor Meter | Temperature, humidity, battery |
| CO2 Sensor (Hub 2) | CO2, temperature, humidity |
| Curtain / Curtain 3 | Position, calibration status |
| Robot Vacuum | Working status, online status |
| Plug / Plug Mini | Power, voltage, current |
Commands (SwitchBot Command node)
| Device Type | Available Commands |
|---|---|
| Bot | turnOn, turnOff, press |
| Curtain / Curtain 3 | setPosition, turnOn, turnOff |
| Plug / Plug Mini | turnOn, turnOff, toggle |
| Color Bulb | turnOn, turnOff, setBrightness, setColor |
| Strip Light | turnOn, turnOff, setBrightness, setColor |
| Air Conditioner (IR) | setAll (temperature, mode, fan speed, power) |
| Humidifier | turnOn, turnOff, setMode |
| Lock / Lock Pro | lock, unlock |
| Blind Tilt | setPosition, fullyOpen, closeUp, closeDown |
| And more... | See SwitchBot API documentation |
Installation
Via Node-RED Palette Manager (Recommended)
- Open Node-RED
- Go to Menu → Manage palette → Install
- Search for
node-red-contrib-switchbot-openapi - Click Install
Via npm
cd ~/.node-red
npm install node-red-contrib-switchbot-openapi
Then restart Node-RED.
Setup
1. Get SwitchBot API Credentials
- Open SwitchBot app on your phone
- Go to Profile → Preferences
- Tap App Version 10 times to enable Developer Options
- Go to Developer Options
- Copy your Token and Secret Key
2. Configure Credentials in Node-RED
- Drag any SwitchBot node to your flow
- Double-click to open settings
- Click the pencil icon next to "認証" (Authentication)
- Enter your Token and Secret
- Click Add then Deploy
3. Select Your Device
- Click the 🔄 button to fetch your device list
- Select a device from the dropdown
- For SwitchBot Command: available commands will appear based on device type
Usage Examples
Get Sensor Data Every 5 Minutes
[Inject (5min interval)] → [SwitchBot Status] → [Debug]
Turn On Air Conditioner
[Inject] → [SwitchBot Command (setAll)] → [Debug]
Motion-Triggered Automation
[Inject (30s interval)] → [SwitchBot Status] → [Switch (msg.payload.detected)] → [Your Action]
API Rate Limits
SwitchBot API has a limit of 10,000 requests per day. Plan your polling intervals accordingly:
| Interval | Requests/Day (1 device) |
|---|---|
| 1 min | 1,440 |
| 5 min | 288 |
| 15 min | 96 |
Troubleshooting
"Token/Secret not configured"
Make sure you've added and deployed the credentials config node before fetching devices.
"Device not found"
Ensure the device is registered in your SwitchBot account and the API credentials are correct.
"API error: 401"
Your Token or Secret is invalid or expired. Regenerate them in the SwitchBot app.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE for details.