# SwitchBot

> Control your SwitchBot smart home: turn devices on or off, press a Bot, lock or unlock a door, move curtains, send any command to a device or infrared remote, read a device's status and run scenes. Start a workflow when a device's status changes.

App · 9 actions. Web page: https://docs.lodol.com/docs/integrations/switchbot

## Actions

### Get device status

Read a device's current status: whether it is on, its battery, a lock's state, a curtain's position, a sensor's temperature and humidity, and whatever else it reports. Infrared remotes have no status.

**Inputs**

- Device (`device_id`, text, required): The SwitchBot device. Pick one, or give its ID from an earlier step.

**Outputs**

- `device_id` (text): The device's ID
- `device_type` (text): Its type, such as Bot or Meter
- `hub_device_id` (text): The ID of the hub it connects through, if any
- `power` (text): on or off, for a device that reports it; empty otherwise
- `status` (object): Every value SwitchBot reports for it, such as power, battery, lockState, slidePosition, temperature or humidity

**Example output**

```json
{
  "device_id": "C271111EC0AB",
  "device_type": "Curtain3",
  "hub_device_id": "FA7310762361",
  "power": "",
  "status": {
    "battery": 80,
    "calibrate": true,
    "deviceId": "C271111EC0AB",
    "deviceType": "Curtain3",
    "group": false,
    "hubDeviceId": "FA7310762361",
    "moving": false,
    "slidePosition": 0,
    "version": "V4.2"
  }
}
```

### List devices

List the devices in your SwitchBot account (Bots, plugs, curtains, locks, hubs, sensors) and the infrared remotes set up in the app, with their IDs and types.

**Inputs**

- Type (`device_type`, text): Only devices and remotes whose type contains this, such as Plug, Curtain, Lock or TV. Leave blank for all.

**Outputs**

- `device_count` (number): How many devices
- `devices` (list): The devices
- `remote_count` (number): How many remotes
- `remotes` (list): The infrared remotes

**Example output**

```json
{
  "device_count": 1,
  "devices": [
    {
      "cloud_service_enabled": true,
      "details": {
        "calibrate": true,
        "deviceId": "C271111EC0AB",
        "deviceName": "Living room curtain",
        "deviceType": "Curtain3",
        "enableCloudService": true,
        "group": false,
        "hubDeviceId": "FA7310762361",
        "master": true
      },
      "device_id": "C271111EC0AB",
      "hub_device_id": "FA7310762361",
      "name": "Living room curtain",
      "type": "Curtain3"
    }
  ],
  "remote_count": 1,
  "remotes": [
    {
      "device_id": "02-202008110034-13",
      "hub_device_id": "FA7310762361",
      "name": "Living room TV",
      "type": "TV"
    }
  ]
}
```

### List scenes

List the manual scenes in your SwitchBot account with their IDs.

**Inputs**: None.

**Outputs**

- `count` (number): How many
- `scenes` (list): The scenes

**Example output**

```json
{
  "count": 1,
  "scenes": [
    {
      "name": "Movie night",
      "scene_id": "T02-202009221414-48924101"
    }
  ]
}
```

### Lock or unlock

Lock or unlock a SwitchBot Lock.

**Inputs**

- Device (`device_id`, text, required): The lock. Pick one, or give its ID from an earlier step.
- Lock or unlock (`operation`, text, required): Whether to lock or unlock the door. One of: `lock`, `unlock`.

**Outputs**: The command sent

- `command` (text): The command, such as turnOn, press or setPosition
- `command_type` (text): command, or customize for a custom button
- `device_id` (text): The device the command went to
- `parameter` (text): The command's parameter, default when it takes none
- `response` (object): Anything SwitchBot sent back, often empty
- `summary` (text): What was done, in words

**Example output**

```json
{
  "command": "lock",
  "command_type": "command",
  "device_id": "C271111EC0AB",
  "parameter": "default",
  "response": {},
  "summary": "Locked"
}
```

### Press bot

Have a SwitchBot Bot press its button once. Each run presses again.

**Inputs**

- Device (`device_id`, text, required): The Bot. Pick one, or give its ID from an earlier step.

**Outputs**: The command sent

- `command` (text): The command, such as turnOn, press or setPosition
- `command_type` (text): command, or customize for a custom button
- `device_id` (text): The device the command went to
- `parameter` (text): The command's parameter, default when it takes none
- `response` (object): Anything SwitchBot sent back, often empty
- `summary` (text): What was done, in words

**Example output**

```json
{
  "command": "press",
  "command_type": "command",
  "device_id": "C271111EC0AB",
  "parameter": "default",
  "response": {},
  "summary": "Pressed"
}
```

### Run scene

Run one of your manual scenes, doing everything it is set up to do in the SwitchBot app.

**Inputs**

- Scene (`scene_id`, text, required): The manual scene. Pick one, or give its ID from an earlier step.

**Outputs**

- `ran` (true/false): Always true once it ran
- `scene_id` (text): The scene run

**Example output**

```json
{
  "ran": true,
  "scene_id": "T02-202009221414-48924101"
}
```

### Send command

Send any command a device or infrared remote takes, by SwitchBot's name for it, such as turnOn, setColor, setAll or a custom button.

**Inputs**

- Device (`device_id`, text, required): The SwitchBot device or infrared remote. Pick one, or give its ID from an earlier step.
- Command (`command`, text, required): SwitchBot's name for the command, exactly as its API documentation spells it (such as turnOn, setBrightness or volumeAdd), or the name of a custom button.
- Parameter (`parameter`, text): What the command takes, such as 122:80:20 for setColor or 26,1,3,on for an air conditioner's setAll. Leave blank for a command that takes nothing. A JSON object is sent as JSON.
- Command type (`command_type`, text): A built-in command, or a custom button you made for a remote in the SwitchBot app. Defaults to a built-in command. One of: `command` (A built-in command), `customize` (A custom button made in the SwitchBot app). Default: `command`.

**Outputs**: The command sent

- `command` (text): The command, such as turnOn, press or setPosition
- `command_type` (text): command, or customize for a custom button
- `device_id` (text): The device the command went to
- `parameter` (text): The command's parameter, default when it takes none
- `response` (object): Anything SwitchBot sent back, often empty
- `summary` (text): What was done, in words

**Example output**

```json
{
  "command": "setColor",
  "command_type": "command",
  "device_id": "C271111EC0AB",
  "parameter": "122:80:20",
  "response": {},
  "summary": "Sent setColor with \"122:80:20\""
}
```

### Set curtain position

Move a SwitchBot Curtain or Roller Shade to a position, from 0 (open) to 100 (closed).

**Inputs**

- Device (`device_id`, text, required): The Curtain or Roller Shade. Pick one, or give its ID from an earlier step.
- Position (`position`, number, required): How far closed, from 0 (fully open) to 100 (fully closed). From 0 to 100.
- Speed (`mode`, text): How a Curtain moves: faster, quieter, or as set in the app. A Roller Shade has no choice. Defaults to the curtain's own setting. One of: `default` (The curtain's own setting), `performance` (Performance (faster)), `silent` (Silent (quieter)). Default: `default`.

**Outputs**: The command sent

- `command` (text): The command, such as turnOn, press or setPosition
- `command_type` (text): command, or customize for a custom button
- `device_id` (text): The device the command went to
- `parameter` (text): The command's parameter, default when it takes none
- `response` (object): Anything SwitchBot sent back, often empty
- `summary` (text): What was done, in words

**Example output**

```json
{
  "command": "setPosition",
  "command_type": "command",
  "device_id": "C271111EC0AB",
  "parameter": "0,ff,50",
  "response": {},
  "summary": "Moved to 50% closed"
}
```

### Turn device on or off

Turn a Bot, plug, light, fan, appliance or infrared remote's appliance on or off.

**Inputs**

- Device (`device_id`, text, required): The SwitchBot device or infrared remote. Pick one, or give its ID from an earlier step.
- Turn (`power`, text, required): On or off. One of: `on`, `off`.

**Outputs**: The command sent

- `command` (text): The command, such as turnOn, press or setPosition
- `command_type` (text): command, or customize for a custom button
- `device_id` (text): The device the command went to
- `parameter` (text): The command's parameter, default when it takes none
- `response` (object): Anything SwitchBot sent back, often empty
- `summary` (text): What was done, in words

**Example output**

```json
{
  "command": "turnOn",
  "command_type": "command",
  "device_id": "C271111EC0AB",
  "parameter": "default",
  "response": {},
  "summary": "Turned on"
}
```
