Switch-Bot API integration

I will add more commands for the IR appliances as it is only on/off for now.

Thanks for the confirmation. Then the documentation should be updated to reflect that it is for the IR part.

The best would be if custom commands could be sent from the hubs, like the Broadlink integration allows it.

And as I remember from another post, it is capable to do that through the cloud API.

1 Like

Yeah. I am working on it.
From my understanding, there are 3 groups of commands:

  • Those recognized by both the app and by default by the api (working on them now)
  • Those recognized by the app and and probably custom command for the api, I am still looking for how to call them and make it easy to use
  • Those added to the app as custom button and custom command for the api. If possible, I need to find a way to get the list of custom commands or an easy way to add them in Home Assistant

Some hint on this, if you havenā€™t came across it yet:

And to call custom commands. You can add service like Broadlink has:

1 Like

Thanks for the links.

If I do not manage to do more automatic discovery, I will add something similar to Broadlink for the custom commands.

1 Like

If you are interested, I developed a custom integration that allow to control switchbot remote via cloud api GitHub - KiraPC/ha-switchbot-remote: A Custom HomeAssistant Integration to control Switchbot Hub

2 Likes

total stupid question, but i am already stuck on how to add the calculated token to the secrects.yaml
Can someone share the full script (of course without tokensinside) and where to store it in home assistant?

thanks in advance
michael

Hi

  • Had Switchbot integrated to HA via API/rest commands and everything was working fine ā€¦ until it wasnā€™t.
  • Problem:
    • Service to open (turnOn), close (turnOff) and setPosition called for Curtain doesnā€™t work anymore.
    • This seems specific to curtains only, rest commands to control IR devices continue to work fine.
    • Curtains can be controlled from Switchbot app, so it seems the problem lies with the HA integration
  • Troubleshooting thus far:
    1. See if the HA updates had broken the integration. I rolled back to an earlier backup and this doesnā€™t seem to be the case(?).
    2. See if thereā€™s a change in syntax with the Switchbot API. This doesnā€™t seem to be the case either. And the IR device commands are working fine.

Iā€™m lost as to what else I can check, appreciate any help

Iā€™m facing the exact same issue as of a few hours ago. It worked last night (last action was 19 hours ago), but this morning, it has stopped working.

I wonder if it has something to do with the now legacy api v1.0.
However, interestingly, it can still read the position. It just canā€™t send any of the commands

Tried digging deeper but Iā€™m barely competent with such things to be honest. Will need to see if the codes can be converted to v1.1

aaand just as mysteriously as it stopped working, it just started working again

can only surmise this is a very specific one off issue to Switchbot curtains HA API integration

also to confirm on my side, also no issues getting the position and status from Curtain. it was only limited to posting commands.

iā€™m still on v1.0, so fingers crossed this keeps working

and post update to HA 2023.12.1, it does still work but thereā€™s some noticeable lag. so itā€™s a Switchbot issue? maybe theyā€™re still working on it

===

actually itā€™s a HA issue? running this on command line does successfully post the command:

curl -X POST -H "Content-Type: application/json" -H "Authorization: {{ token }}" -d "{\"command\": \"setPosition\", \"parameter\": \"0,ff,100\", \"commandType\": \"command\"}" https://api.switch-bot.com/v1.0/devices/{{ deviceId }}/commands

Maybe not the same issue, but I had a Switchbot Bot stop working suddenly (5 months ago~). I think I only had to update the Bot firmware in the app and that fixed it?.. I also converted the code to v1.1 at the same time, but Iā€™m not exactly sure which one I did first anymore, been too long. Since then, itā€™s been working without any problems. (I donā€™t have the Curtain though, so maybe itā€™s totally unrelated!)

At this point in time, there appears to be this:
SwitchBot Bluetooth - Home Assistant.
and this:
SwitchBot Cloud - Home Assistant.

So this FR should be considered closed.

Future support questions should go thru the regular HA core integration paths as this is not monitored for issues.