The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit with Homebridge.
- Search for "SwitchBot" on the plugin screen of Homebridge Config UI X
- Find:
@switchbot/homebridge-switchbot- See noble prerequisites for your OS. (This is used for BLE connection.)
- Click Install
You can now configure global OpenAPI polling and rate-limiting options directly from the Homebridge UI:
- Go to the SwitchBot plugin settings in Homebridge Config UI X.
- Scroll to the Advanced Settings section at the bottom of the page.
- Adjust the following options as needed:
- OpenAPI Polling Interval (seconds): How often to poll devices via OpenAPI for status. Default: 300 (5 min). Min: 30. Can be overridden per device.
- Enable Batched OpenAPI Polling: Poll all OpenAPI devices in a single batch at the configured interval. Devices with per-device refreshRate are excluded from the batch.
- OpenAPI Batch Polling Interval (seconds): Interval for batched OpenAPI polling. Falls back to OpenAPI Polling Interval if not set. Default: 300.
- OpenAPI Daily Request Limit: Maximum OpenAPI requests per day allowed by the plugin. Default: 10000.
- OpenAPI Reserve for Commands: Requests reserved for user actions. When remaining budget reaches this value, background polling pauses. Default: 1000.
- Reset OpenAPI Counter at Local Midnight: If true, resets the daily OpenAPI request counter at local midnight. If false, resets at UTC midnight.
- Only Allow Webhooks on Reserve: When remaining OpenAPI budget reaches the reserve, only webhooks and user commands are allowed. Background polling/discovery pauses.
- OpenAPI Batch Concurrency: Maximum number of parallel OpenAPI status calls during a batch. Default: 5.
- OpenAPI Batch Jitter (seconds): Random startup delay before the first batch to reduce synchronized spikes. Default: 0.
Click Save Advanced Settings to apply changes. These settings match the options available in config.schema.json and can be overridden per device.
-
- Download SwitchBot App on App Store or Google Play Store
- Register a SwitchBot account and log in into your account
- Generate an Token within the App
- Click Bottom Profile Tab
- Click Preference
- Click App version 10 Times, this will enable Developer Options
- Click Developer Options
- Click Copy
tokento Clipboard
- Input your
tokeninto the config parameter - Generate an Secret within the App
- Click Bottom Profile Tab
- Click Preference
- Click App version 10 Times, this will enable Developer Options
- Click Developer Options
- Click Copy
secretto Clipboard
- Input your
secretinto the config parameter
-
- Download SwitchBot App on App Store or Google Play Store
- Register a SwitchBot account and log in into your account
- Click on Device wanting to connect too plugin
- Click the Settings Gear
- Click Device Info
- Copy BLE Mac aka
deviceId
- Input your
deviceIdinto the Device Config
-
-
bluetoothctlmust be installed on the device, otherwise it cannot communicate via Bluetooth. Enable it withsudo bluetoothctl power on. -
If errors occur, while enabling it, restart the process:
rfkill block bluetoothrfkill unblock bluetooth
-
Also make sure, that the computer can discover the SwitchBot device:
sudo bluetoothctlscan on
This lists all discovered Bluetooth devices. The BLE address of the SwitchBot device should be included in this list, otherwise your computer does not discover it.
-
-
- Manually grant Bluetooth access in System Settings UI for
Security & Privacy -> Privacyto the node executable, eg/usr/local/bin/node
(This is what is intended in documentation for the noble bluetooth package prerequisites by "Add terminal app", however for HomeBridge it is nodethat needs the permission granted, notterminal. Without this step, then you will receive the following error when the swichbot plugin launches, which will cause Homebridge or the child bridge process to restart:
Error: Failed to initialize the Noble object: unauthorized at Noble.<anonymous> (file:///usr/local/lib/node_modules/@switchbot/homebridge-switchbot/node_modules/node-switchbot/src/switchbot.ts:244:19) at Object.onceWrapper (node:events:629:26) at Noble.emit (node:events:514:28) at Noble.onStateChange (/usr/local/lib/node_modules/@switchbot/homebridge-switchbot/node_modules/@stoprocent/noble/lib/noble.js:92:8) at NobleMac.emit (node:events:514:28) - Manually grant Bluetooth access in System Settings UI for
- SwitchBot Humidifier
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- Can Push Updates over OpenAPI
- Can Receive Updates over BLE and OpenAPI
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- SwitchBot Evaporative Humidifier (Auto-refill)
- SwitchBot Meter
- SwitchBot Meter Plus (US)
- SwitchBot Meter Plus (JP)
- SwitchBot Indoor/Outdoor Thermo-Hygrometer
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- If using Bluetooth Low Energy (BLE) only:
- Must supply
deviceId&deviceNameto Device Config - Check
Enable Bluetooth Low Energy (BLE) Connectionon Device Config
- Must supply
- SwitchBot Motion Sensor
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- If using Bluetooth Low Energy (BLE) only:
- Must supply
deviceId&deviceNameto Device Config - Check
Enable Bluetooth Low Energy (BLE) Connectionon Device Config
- Must supply
- SwitchBot Contact Sensor
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- If using Bluetooth Low Energy (BLE) only:
- Must supply
deviceId&deviceNameto Device Config - Check
Enable Bluetooth Low Energy (BLE) Connectionon Device Config
- Must supply
- SwitchBot Curtain
- SwitchBot Curtain 3
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- If using Bluetooth Low Energy (BLE) only:
- Must supply
deviceId&deviceNameto Device Config - Check
Enable Bluetooth Low Energy (BLE) Connectionon Device Config
- Must supply
- SwitchBot Blind Tilt
- Supports OpenAPI & partial Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- SwitchBot Bulb
- SwitchBot Ceiling Light
- SwitchBot Ceiling Light Pro
- SwitchBot Light Strip
- Supports OpenAPI & partial Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- SwitchBot Lock
- SwitchBot Lock Pro
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- US: SwitchBot Mini Robot Vacuum K10+
- US: SwitchBot Floor Cleaning Robot S10
- JP: SwitchBot Robot Vacuum Cleaner S1
- JP: SwitchBot Robot Vacuum Cleaner S1 Plus
- Supports OpenAPI Connection Only
- SwitchBot Plug
- SwitchBot Plug Mini (US)
- SwitchBot Plug Mini (JP)
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- SwitchBot Bot
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- If using OpenAPI:
- SwitchBot Hub Mini, SwitchBot Hub 2, or SwitchBot Hub 3 Required
- Enable Cloud Services for Device on SwitchBot App
- You must set your Bot's Device ID for either Press Mode or Switch Mode in Plugin Config (SwitchBot Device Settings > Bot Settings)
- Press Mode - Turns on then instantly turn it off
- Switch Mode - Turns on and keep it on until it is turned off
- This can get out of sync, since API doesn't give me a status
- To Correct you must go into the SwitchBot App and correct the status of either
OnorOff
- If using Bluetooth Low Energy (BLE) only:
- Must supply
deviceId&deviceNameto Device Config - Check
Enable Bluetooth Low Energy (BLE) Connectionon Device Config
- Must supply
- SwitchBot Hub 2
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- Enables Humidity, Temperature, and Light Sensor
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- SwitchBot Hub Mini 2
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- Enables Humidity, Temperature, and Light Sensor
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- SwitchBot Hub 3
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- Enables Humidity, Temperature, and Light Sensor
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
- SwitchBot Battery Circulator Fan
- Supports OpenAPI Connection Only
- SwitchBot Water Leak Detector
- Supports OpenAPI & Bluetooth Low Energy (BLE) Connections
Some SwitchBot devices (notably newer locks, curtains, and select sensors) require a BLE encryption key and keyId for secure Bluetooth communication. This plugin supports configuring these fields for each device.
- Open the SwitchBot App and select your device.
- Go to Device Settings (gear icon).
- Tap Device Info.
- If your device supports BLE encryption, you will see fields for Encryption Key and Key ID. (If not visible, your device may not require encryption or may need a firmware update.)
- Copy the Encryption Key and Key ID values.
In the Homebridge UI, when adding or editing a SwitchBot device, enter the Encryption Key and Key ID in the provided fields. These values will be securely used for BLE communication with your device.
Example device config excerpt:
{
"deviceId": "E7F8A1B2C3D4",
"deviceName": "SwitchBot Lock",
"enableBLE": true,
"encryptionKey": "0123456789abcdef0123456789abcdef",
"keyId": "01"
}- SwitchBot Lock (and Lock Pro)
- SwitchBot Curtain 3 (and some Curtain 2 with updated firmware)
- Some sensors and new device models (see device info in app)
If you are unsure, check your device's info in the SwitchBot app. If the fields are present, copy them into the plugin config.
Note: If you enter an incorrect key or keyId, BLE communication will fail for that device. Double-check values if you encounter connection issues.
(All IR Devices require SwitchBot Hub 2, SwitchBot Hub Mini 2, SwitchBot Hub 3, or Hub Mini)
- TV
- Allows for On/Off and Volume Controls
- Optional Disable Sending Power Command
- Projector (Displayed as TV)
- Allows for On/Off and Volume Controls
- Set Top Box (Displayed as Set Top Box)
- Allows for On/Off and Volume Controls
- DVD (Displayed as Set Top Box)
- Allows for On/Off and Volume Controls
- Streamer (Displayed as Streaming Stick)
- Allows for On/Off and Volume Controls
- Speaker (Displayed as Speaker)
- Allows for On/Off and Volume Controls
- Fans
- Allows for On/Off Controls
- Optional Rotation Speed
- Optional Swing Mode
- Lights
- Allows for On/Off Controls
- Air Purifiers
- Allows for On/Off Controls
- Air Conditioners
- Allows for On/Off, Tempeture, and Mode Controls
- Optional Disable Auto Mode
- Cameras
- Allows for On/Off Controls
- Vacuum Cleaners
- Allows for On/Off Controls
- Water Heaters
- Allows for On/Off Controls
- Others
- Option to Display as differenet Device Type
- Supports Fan Device Type
- Allows for On/Off Controls
- Option to Display as differenet Device Type
By default, the Matter platform uses a single batched refresh to update device status. You can tune or override this behavior with the following options under options:
matterBatchEnabled(boolean, default true): enable/disable platform-level batched refresh. Devices with a per-devicerefreshRatestill run their own timers.matterBatchRefreshRate(number, seconds): batch interval (falls back tooptions.refreshRate, then 300 if not set).matterBatchConcurrency(number): limit of parallel OpenAPI status calls during a batch (default 5).matterBatchJitter(number, seconds): random startup delay before the first batch to reduce synchronized spikes.
Device-level override:
- If a device sets
refreshRatein its config, it uses a per-device timer and is excluded from the platform batch.
Reliability and rate-limiting:
- Each device status call retries with exponential backoff on non-success responses.
- After exhausting retries, the device enters a short cooldown before being retried; cooldowns are persisted across restarts.
- The batch worklist is randomized every cycle to further distribute API load.
These controls keep API usage smooth and predictable while preserving per-device control when needed.
-
Matter-first: when Homebridge Matter is available the plugin now prefers registering Matter accessories (with HAP fallback).
-
Hybrid client: the plugin uses
node-switchbot@^4.0.0with BLE + OpenAPI discovery and OpenAPI fallback. -
OpenAPI credentials: cloud discovery and cloud fallback paths require both
openApiTokenandopenApiSecret. -
UI always served: the plugin UI is packaged into
dist/homebridge-uiand is always served when Homebridge UI support is present; there is no platform-level opt-out. -
OpenAPI hardening: OpenAPI calls have AbortController timeouts, jittered exponential backoff, per-device retry limits and cooldowns, and safe response parsing for resilient behavior.
-
v4 resilience enabled in discovery: plugin discovery enables retry, circuit-breaker, and connection-intelligence flags from
node-switchbotv4. -
Write coalescing (debounce): command writes to the same device are coalesced by default to avoid command floods. Configure with
writeDebounceMs(milliseconds, default 100). Set to0to disable coalescing.
See MIGRATION.md for migration notes and recommended upgrade steps.
To prevent hitting SwitchBot’s daily OpenAPI limit, the plugin provides several platform-level options under options:
dailyApiLimit(number, default 10000): maximum OpenAPI requests per day that the plugin will allow.dailyApiReserveForCommands(number, default 1000): requests reserved for user actions so background polling pauses before the hard limit.webhookOnlyOnReserve(boolean, default false): when remaining budget reaches the reserve, pause background polling/discovery; webhooks and commands continue until the hard limit.dailyApiResetLocalMidnight(boolean, default false): if true, resets the daily counter at local midnight; when false, resets at UTC midnight.
Example (excerpt):
{
"options": {
"dailyApiLimit": 10000,
"dailyApiReserveForCommands": 1000,
"webhookOnlyOnReserve": false,
"dailyApiResetLocalMidnight": true
}
}-
Run unit tests:
npm run test -
Notes:
- Added Lock Ultra (Cloud + BLE) support with
node-switchbotv4.
- Added Lock Ultra (Cloud + BLE) support with