A Home Assistant custom integration that provides direct access to the SwitchBot Cloud API. Control all your SwitchBot devices—including infrared remotes and devices not supported by the official SwitchBot Cloud integration—via a single service action.
This integration connects Home Assistant to the SwitchBot Open API using your token and secret from the SwitchBot app. It provides:
- Device discovery – Fetch and view all devices in your SwitchBot account with a device name dropdown
- Device control – Send commands to any device via
switchbot_api.send_commandwith automatic command type detection - Full API access – Use the same API that powers the SwitchBot app, including infrared remotes and 50+ device types
- API status monitoring – Validates your credentials every 10 minutes and shows
connected,authentication_failed, orconnection_error - Credential management – Update your token and secret via Reconfigure without removing the integration
The official SwitchBot Cloud integration only supports a limited set of device types. Many SwitchBot products—including infrared remotes (IR remotes), some smart plugs, and newer devices—are not exposed as entities in the official integration.
This integration gives you direct API access, so you can:
- Control infrared remotes (TVs, air conditioners, set-top boxes, etc.)
- Use devices not yet supported by the official integration
- Build automations with any SwitchBot device
- Access the full SwitchBot API without waiting for official support
- Authentication – You provide your SwitchBot Open API token and secret (from the SwitchBot app's Developer Options). The integration uses HMAC-SHA256 signing for each request.
- Device list – The integration fetches your devices from
GET /v1.1/deviceson startup and caches them. Both physical devices and infrared remotes are included. - Device selection – When using
switchbot_api.send_command, select your device by name from a dropdown. The device ID, type, and command type are resolved automatically. - Commands – Commands are sent via
POST /v1.1/devices/{deviceId}/commands. For most commands, the parameter defaults todefaultand the command type is auto-detected based on the device type.
-
Download the integration
- Download the latest release zip or clone this repository.
-
Install in Home Assistant
- Copy the
switchbot_apifolder into your Home Assistantcustom_componentsdirectory:config/custom_components/switchbot_api/ - The folder name must be
switchbot_api(matching the integration domain).
- Copy the
-
Restart Home Assistant
- Restart Home Assistant so it loads the new integration.
-
Configure
- Go to Settings → Devices & Services → Add Integration
- Search for SwitchBot API and add it
- Enter your token and secret from the SwitchBot app
- Open HACS → Integrations
- Click the ⋮ menu (top right) → Custom repositories
- Add this repository URL and select Integration
- Search for SwitchBot API and install
- Restart Home Assistant and add the integration via Settings → Devices & Services
- Open the SwitchBot app
- Go to Profile → Preferences (or Preferences → About on app 9.0+)
- Tap the App Version number 10 times to reveal Developer Options
- Tap Developer Options, then Get Token
- Copy your token and secret and enter them in the integration setup
To see your devices and their IDs:
The Refresh device list button on the SwitchBot API device page fetches the latest device list from the API. Click into the button entity to see all devices in the attributes panel, grouped by physical devices and infrared remotes, with names, types, and IDs.
- Go to Settings → Devices & Services
- Find SwitchBot API and click Configure
- The options screen shows all devices grouped by type with their IDs
Call the service to fetch the device list programmatically:
action: switchbot_api.get_devicesThe response includes:
{
"devices": [
{
"device_id": "C271111EC0AB",
"device_name": "Living Room Bot",
"device_type": "Bot"
},
{
"device_id": "02-202312011234-00",
"device_name": "TV Remote",
"device_type": "Others"
}
],
"device_count": 2,
"physical_device_count": 1,
"infrared_remote_count": 1
}Use switchbot_api.send_command to control any device:
| Parameter | Required | Default | Description |
|---|---|---|---|
device_name |
No* | — | Select from the dropdown (e.g. Door [Smart Lock]) |
device_id |
No* | — | Raw device ID for YAML automations (e.g. C271111EC0AB) |
command |
No | turnOn |
The command to send |
parameter |
No | default |
Command parameter (string or JSON object) |
command_type |
No | auto | Auto-detected: command for physical devices, customize for IR "Others" |
*Either device_name or device_id must be provided.
The command_type is automatically determined based on the device type — you typically don't need to set it.
Turn on a Bot or Plug (using device name from dropdown):
action: switchbot_api.send_command
data:
device_name: "Plug Mini [Plug Mini (JP)]"
command: "turnOn"Lock a Smart Lock (using device ID):
action: switchbot_api.send_command
data:
device_id: "C77BA846E246"
command: "lock"Set curtain position:
action: switchbot_api.send_command
data:
device_id: "E3D02BF388C7"
command: "setPosition"
parameter: "0,ff,50"Set AC temperature (IR Air Conditioner):
action: switchbot_api.send_command
data:
device_id: "02-202406031344-38077653"
command: "setAll"
parameter: "26,2,3,on"Infrared remote – custom button (IR "Others"):
action: switchbot_api.send_command
data:
device_id: "03-202603050254-93377662"
command: "Power"
command_type: "customize"automation:
- alias: "Lock door at night"
trigger:
- platform: time
at: "23:00:00"
action:
- action: switchbot_api.send_command
data:
device_id: "C77BA846E246"
command: "lock"| Device Type | Command | Parameter | Notes |
|---|---|---|---|
| Bot, Plug | turnOn |
default |
Turn on |
| Bot, Plug | turnOff |
default |
Turn off |
| Bot | press |
default |
Momentary press |
| Curtain | turnOn |
default |
Open |
| Curtain | turnOff |
default |
Close |
| Curtain | setPosition |
0,ff,50 |
index,mode,position |
| Lock | lock |
default |
Lock |
| Lock | unlock |
default |
Unlock |
| IR AC | setAll |
26,2,3,on |
temp,mode,fan,power |
| IR Remote | turnOn |
default |
Turn on (standard) |
| IR Others | (button name) | default |
command_type: customize |
For the full command reference for all 50+ device types, see the SwitchBot Open API documentation.
The integration creates the following entities on the SwitchBot API device:
| Entity | Category | Description |
|---|---|---|
| API status | Diagnostic | Shows connected, authentication_failed, or connection_error. Validates credentials every 10 minutes. Auth headers are available in the entity attributes. |
| Refresh device list | Configuration | Press to refresh the cached device list from the API. The full device list is visible in the entity's attributes. |
If your SwitchBot token or secret changes:
- Go to Settings → Devices & Services
- Find SwitchBot API, click the ⋮ menu
- Select Reconfigure
- Enter your new token and secret
- The integration validates the new credentials and reloads automatically
The API status sensor will show authentication_failed within 10 minutes if credentials become invalid.
- Go to the Releases page
- Download the latest
switchbot_api.zip - Extract the
switchbot_apifolder - Copy it to
config/custom_components/switchbot_api/
- Home Assistant 2024.1.0 or later
- SwitchBot account with Open API token and secret
- Internet access (API is cloud-based)
- Invalid token or secret – Regenerate your token in the SwitchBot app. Use Reconfigure (⋮ menu on the integration card) to update credentials without removing the integration.
- Device not responding – Confirm the device is online in the SwitchBot app and that you're using the correct
device_id. - Command not working – Check the SwitchBot API docs for your device type and supported commands.
- Device dropdown is empty – Press the Refresh device list button on the device page, then reload the integration.
- API status shows
authentication_failed– Your token or secret has changed. Use Reconfigure to update them. - API status shows
connection_error– Check your internet connection. The SwitchBot API is cloud-based and requires internet access.
MIT License (or your preferred license)