Switch-Bot API integration

Alright, I managed to get my SwitchBot Curtains hooked up through the API. Here’s is a quick tutorial for anyone that’s interested.

  1. Start by getting an API key.
  2. If you have two curtains opposite each other covering one window, it’s easier if you link them up so they act as one.
  3. Find out the deviceID of the curtain you want to control by running the following command on the Windows command line. In the output you should see the identifier of your curtain
curl -H "Authorization: API_KEY_HERE" https://api.switch-bot.com/v1.0/devices
  1. Open up your configuration.xml and add the following
cover:
  - platform: command_line
    covers:
      switchbot_curtains:
        command_open: "/usr/bin/curl -X POST -H 'Content-Type: application/json' -H 'Authorization: API_KEY_HERE' -d '{\"command\": \"turnOn\"}' https://api.switch-bot.com/v1.0/devices/DEVICE_ID_HERE/commands"
        command_close: "/usr/bin/curl -X POST -H 'Content-Type: application/json' -H 'Authorization: API_KEY_HERE' -d '{\"command\": \"turnOff\"}' https://api.switch-bot.com/v1.0/devices/DEVICE_ID_HERE/commands"
        command_stop: "/usr/bin/curl -X POST -H 'Content-Type: application/json' -H 'Authorization: API_KEY_HERE' -d '{\"command\": \"turnOff\"}' https://api.switch-bot.com/v1.0/devices/DEVICE_ID_HERE/commands"
        friendly_name: Switchbot Curtains
  1. You should now have a working cover entity that controls your Switchbot Curtain(s) through the Hub :slight_smile:
5 Likes