Prime Day Offers! SwitchBot have 25% off during the Prime Day sales, plus you can get an additional 5% off with this code: XMSWITCHBOT SwitchBot Hub 2 on Amazon UK: amzn.to/3JA6Dpr (or Amazon US: amzn.to/44mK3IH) SwitchBot Hub 2 Direct from SwitchBot: bit.ly/46vmteX Valid until 30th July 2023
I have been struggling for ages to get my SwitchBot Curtain Rod working with Home Assistant. Your video has finally solved it for me. Thank you very much! 🙂
Really helpful. Thank you so much. I have a mini hub and thought I'd have to invest in a hub 2 to get my curtains working. The process you describe is totally different to most descriptions, so something must have changed at the Switchbot end. But you have saved the day!
Glad it helped! You can also use Bluetooth Proxies via ESPHome if you want to have local control of the curtains in Home Assistant. I have that working with the Curtain 3 and the Blind Tilt.
Great video, helped me get my Switchbot stuff into HA in the easiest way via a hub and the cloud API. Bluetooth is a pretty bad protocol for local comms and is only really useful for device to hub occasional updates and not for HA Host to device.
Glad it helped. However, I personally run all of my SwitchBot devices over bluetooth straight back to HA. I use ESPHome bluetooth proxies (two of them) to cover areas where the Pi can't reach, and those proxies talk over Wifi. So far it's perfect and rock solid, but you do need to like playing with ESP32 modules :)
As a HA noob this video really helped me out - have managed to get all the different SwitchBot MeterPluses picked up and now just need to get some automations going to control my wifi fused spurs so my dumb eletric heating will finally be smart! Thank you!
For a 2nd blind. Do I just enter the rest_command again? I have one working but when I just add another rest_command it cancels out one of the blinds. Thanks in advance.
Carissimo, grazie per il video e per le dettagliate informazioni trovate sul blog. Ho provato ad utilizzare i suggerimenti e sembrava che le API (con swithbot All Devices) fornissero le informazioni necessarie (ho due termometri). Purtroppo dopo non hanno più funzionato: ottengo l'entità "sensor.switchbot_all_devices" con lo "Stato" OK ma non ci sono attributi tranne il friendlyname ! Puoi darmi qualche suggerimento ?? Thanks
I don’t speak Italian but I am making a guess that your all devices sensor is empty? Have you tried waiting a few hours or reducing the refresh period on the sensor temporarily?
@@SpeakToTheGeekTech First of all, thanks for the reply! I then tried to reduce the update time and finally managed to get the data! Thanks again. A little information, if I also wanted to obtain the sensor battery data (I have two Meter Plus) which entity should I configure? Thank you again
There is a battery entity you can pull from the API for the meter plus. You’d do it in the same way as you get humidity or temperature. github.com/OpenWonderLabs/SwitchBotAPI?tab=readme-ov-file#meter-plus-1
Thanks for creating this video. This has been very helpful for me getting the API setup and was much easier than trying to get teh python script working in HA which I had created
@SpeakToTheGeekTech Any tutorial regarding getting the Hygrometers temps from SwitchBot API Cloud that sync with the SwitchBot Hub Mini (Don't have the bluetooth) ? Seems to the SwitchBot Add-On on HA isn't able to retreive device from API Cloud. Thank you in advance.
There's no specific guide, but it's basically the exact same guide as shown in this video. Instead of pulling the data from the Hub 2 as I do in this tutorial, you need to find your temp/hydro meter devices in 'all devices' and use that instead. The key names are still temperature and humidity just like my example: github.com/OpenWonderLabs/SwitchBotAPI#outdoor-meter-1
Hi! I use a Hub 2 to remote control my old Air conditioning unit. I have a Shelly blu motion sensor. Do you know if I use the Shelly blu to trigger the switchbot hub 2 when, for example, the Shelly detects no motion for more than 5 minutes? Thanks a lot
Yes that is entirely possible using a Home Assistant automation and the SwitchBot API to call an IR command on the Hub. I haven't shown an example of calling IR commands in this guide but it's all in SwitchBot's API documentation.
@@SpeakToTheGeekTech thanks Sir. I’m totally unfamiliar with Home Assistant and API. Do you know if I can do this from within the Shelly device web interface ?
@@francesca7765 Not a clue sorry, I have never used that Shelly device and I also doubt that's possible anyway. Calling the SwitchBot API requires a fair bit of work as you might have seen in this video.
I am trying to control my switchbot BlindTilts Using Switchbot API 1.1 following the procedure in your video. I can run my automation successfully one time after restarting HA. All subsequent attempt cause a 401 error. All of you rest_Command sets the nonce value to "". Searching the web, I found info stating the nonce value needs to be a different random number for every attempt. However, all my attempts to implement this have failed. How do you get the rest_command to work without setting the nonce value?
As far as I can tell the nonce value is optional. Just to make sure things haven't changed, I've spent the last few minutes double-checking my configuration and testing it for you! My rest_commands still work fine for both the Curtain 2 Bots and the Blind Tilt with no nonce value set.
Thanks for responding promptly. Do you have any suggestion as to what else will cause it to work only on the first attempt after HA restart?
9 หลายเดือนก่อน
Hi, I have one issue when adding the rest sensor, later I'm adding it, restarting etc..., I'm going to the developer tools and I search for switchbot_all_devices but I only get "friendly_name: SwitchBot All Devices" but not more info.The token and the key are ok, I use them lo link switchbot cloud integration. What could I been doing wrong? Thanks
It takes a while for the first update (see the refresh interval). If you set the refresh interval to a lower value it should update more quickly. It's a good idea to set this back to. a high value after the first population though
9 หลายเดือนก่อน
@@SpeakToTheGeekTech I tried this too, but I think I found the problem, I was writing in the configuration.yaml above the tss, automation, scrip, scene etc... and it wasn't working, I saw again the video and I realise you had it written below and I tried, when I saved and reboot everything was showing and now I have it comunicating with the hub 2 and I see temp and humidity, I'm new on home assistant and I don't know if this may be the issue or just I didn't wait enough. Thanks for the reply and great tutorial, I'm adding now one bot reading the API commands.
Hello, I have done as in your instructions. But my list under "SwitchBot All Devices" shows no entries. I have integrated a "Hub2" and an "Outdoor Spotligt Cam" into my Switchbot app. What could be the error? If I set up the Switchbot integration (cloud) in HomeAssistant with the same token and key. I then also get no devices shown. Thanks for the help Greetings Frank
It can take a while for all devices to update using the default refresh rate in my example. You can either change that to reduce it in your config, or wait about an hour for it to update.
You say the blind tilt doesn't support updating status, but Curtains does? Would you be able to help me work out how to update the status of Curtains automatically? I think you mentioned "web hooks"? Thanks
I've not written a tutorial for webhooks yet, mainly because although it works a lot of the time I haven't found it totally reliable. It's also not the sort of thing I could type out instructions to in a comment as it's a full on guide that's needed if you're not familiar with how that sort of thing works.
@SpeakToTheGeekTech ah okay thanks anyway! I was after setting up a ZigBee button to toggle the curtains open and closed, but if I control the curtains from another source the status doesn't update so the toggle button behaves cronky
I personally use bluetooth to connect Home Assistant directly to the SwitchBot curtains, you can use an ESPHome bluetooth proxy to extend that if necessary. If you have a SwitchBot Hub then you could use Matter too for control. Both of those methods have live position status.
@@SpeakToTheGeekTech Thanks mate. I have bluetooth set up using a dongle attached to the Home Assistant Green. I have found that the initial connection is sometimes unbearably slow. Once the first command has worked, the subsequent commands are very responsive. I don't think range is the issue as the dongle is close to the curtains. I have a switchbot hub but it's called "Switchbot HUb Mini E2" and I can't work out if it supports matter or not.
Great video, thank you for spending the time to put this together. I attempted to add my thermostat and getting results for the all devices entity however for humidity and temperature is state unavailable , any suggestions?
You definitely have the hub 2 and not the hub mini? If so then I wouldn't know what is wrong sorry. If you are querying the correct device and it's pushing out the data, and ht API is presenting it back to you then it should all work, but as you can see there are a lot of places in that chain where issues could happen.
Hi, thanks for the video! I am trying to read the state of my switchbot motion sensors, however I only managed to get to the state body: deviceList: - deviceId: [deviceID] deviceName: [deviceName] deviceType: Motion Sensor enableCloudService: true hubDeviceId: [hubdeviceID] ... the point where I am stuck is how to set this up as a sensor. I read that it should be binary sensor, so I guess it would work differently than the example you set up (and not too familiar with home assistant programming). can you point me to a resource to find out?
This method is not suitable for sensors like this because you will not get real-time status updates. You need to use callbacks and that’s a lot more complicated. I’m planning a video on this in a few months.
@@SpeakToTheGeekTech thank you! I will return Switchbot and also abandon the idea to use it remotely on a different wifi to monitor the roof, instead deploy a second instance of home assistant at that location for now
May i ask a question, i actually use the rest.yaml to store all those sensors and i got a very smooth process to follow your instruction in the video/web. However, when i enter into the rest_command: i got the Error loading /config/configuration.yaml: expected '', but found '', it will be same if i added the rest_command to the configuration.yaml neither
I also split out my configuration in my proper HA installation - I just show it in a single file in my demos for simplicity. rest_command would be a different root section (like rest is) so would sit in a separate file from rest.yaml, or it can just sit as a root object in configuration.yaml. I suspect there may be a rogue spacing issue in the copy/paste you have done if you are seeing an error? I actually used my own guide about 2 weeks ago, pasting everything into just configuration.yaml ready for another SwitchBot video I was preparing and all config was still good then.
Thank you for a very helpful video. Unfortunately I have some problem. I do everything and it shows temperature and humidity for a few minutes and then it writes "unknown." If I restart HomeAssistant it shows temperature and humidity again for a few minutes and then writes "unknown." I have Hub 2. Also one more question, is it possible to add two Switchbot hubs ? I have one in a basement and one in a floor.
Got it working but sometimes it is VERY delayed. Is this just because it has to go to Switchbot's server over the internet? Any tips to make it faster? I did try getting this all set up over bluetooth. I can see the curtain status over bluetooth but the action buttons dont do anything. i read you can also do this over matter but i dont really wanna spend £80 on the hub 2 just to get matter
Sounds like your hub might be quite a distance from devices you are controlling. It needs a reliable and close bluetooth connection between them to work properly. Also, updates won't be live either using the API method because it's a pull method to get the status. I personally use direct bluetooth from Home Assistant to the devices for most things, and I use ESPHome bluetooth proxy devices (you have to make them yourself) in order to extend the bluetooth signal into the room with the devices in.
@@SpeakToTheGeekTech Thanks. The hub is pretty close but I'll move it closer. I don't think I need status updates to be live or fast, I just want the open/close action to be fast. Will the API method stop working if my internet connection goes down? I'd love to get direct bluetooth working. I have a bluetooth adapter plugged into my Home Assistant Green. I can see the curtains and their open/close status updates in real time, but the open/close buttons in HA do nothing. Would you be able to give me a hand getting it working? Thank you for your help and your well-made content
The API method will only work if you have an internet connection, that's correct. I wouldn't know why your open/close command don't work - for me it works straight out of the box really. Could be an unsupported bluetooth adapter maybe but I haven't heard of your issues so it would be Google time.
Great tutorial! However, this isn't fully working for me for some reason. I'm using the hub mini and the sign script works well, but when I try to pull the list of devices and subsequent steps, nada. It does work when I use the "sign" header in postman for example.
Try setting the scan_interval to 60 for the devices sensor, reload the config and wait about 2 minutes to see if that works. Sometimes the very first run doesn't work and you have to wait the whole timer (3600 seconds / 1 hour) for it to try and refresh the list again.
Thanks for coming back to me! I appreciate it. No luck yet though, and the "Switchbot Cloud" integration is a bit useless. I'm determined to make it work :)
How long has it been? It can take a couple of hours to populate or you can temporarily change the refresh time for the all devices sensor to something lower.
SwitchBot might also have updated the API, you may need to change the line: - resource: api.switch-bot.com/v1.0/devices to - resource: api.switch-bot.com/v1.1/devices
@SpeakToTheGeekTech OK, thank you. I'm running the latest software (Home Assistant) on my VMware ESXI server. I will try another platform, I don't think it will matter, but it doesn't hurt to try, I guess.
Hello, thank you for your work! Do you think it works with outdoor meter sensor? I followed the tutorial, but when I want to check the state of "SwitchBot All Devices" their is no device. Thank you for your help!
I have the SwitchBot Outdoor Meter (the white one that has a lanyard) and can confirm it works just fine with the API. It shows up in my All Devices data, and I can access value_json.body.temperature and value_json.body.humidity values.
The SwitchBot button (remote?) does not have any API status information. More importantly it would require configuring web hooks to get an event from it which I haven't covered in this video, and the API doesn't appear to publish that event for that device anyway sorry.
wow that was a quick reply@@SpeakToTheGeekTech ;-) Loved your video BTW. I believe this is doable via MQTT? Would you mind helping me get the configuration.yml elements for the hub mini and the temperature sensor (different device) Thanks again
To my knowledge there is no way to get the remote to work with Home Assistant because it is bluetooth paired with your hub. As for getting the temperature sensor data (doesn't matter if it's hub 2 or hub mini, that's just your gateway), you need to start by looking in the all devices data and finding the device ID in there. Then it's basically the same configuration as I demo for the hub 2 sensors but using your unique device ID.
Thanks for your feedback I will test with my temperature sensor deviceId@@SpeakToTheGeekTech On the other hand, what I can do is getting a blue tooth tongle then in order to integrate them all, right?
No, the remote is not supported by Home Assistant at this time regardless of whether you have bluetooth connectivity on your server or not. I have a Raspberry Pi, it has built in bluetooth, it can see most SwitchBot devices but not the remote.
Hello, I would like to thank you for putting together a comprehensive guide on the switchbot api v1.1. However I am appearing to be getting issues with sensor.switchbot_all_devices only showing me the state as OK and not giving me the body. I have confirmed all steps previously works. Thank you in advance
Why do we have to use their cloud api? I thought one of the main selling points of matter (which this hub claims to support) was offline capability? The main reason I use HA is to keep my devices offline. So it’s kind of a bummer we have to use apis to accomplish flipping a simple switch 😢
Yes it works fine with the Hub Mini for any devices paired with your account via the hub. But the Hub Mini doesn’t have any built in sensors so you won’t get any data from the hub itself.
Makes sense. I’ve been using Hoobs to bring non HomeKit native devices into HomeKit. I’m trying home assistant and I will say, it’s much more complicated to get Switchbot working. With Hoobs there was a GUI where I put the token, key, etc.. I was hoping that native SwitchBot integration in Home assistant would work but no luck. I was under the impression Hoobs was a stripped down version of home assistant. I guess what I’m asking, could you tell me why getting Switchbot integrated with home assistant is much more complicated than on the Hoobs platform?
I've never actually used Hoobs but from what I can see there's nothing that suggests it might be based on Home Assistant. I think it's a totally different development program. It has been designed to be as user friendly as possible which is in contrast to Home Assistant that developed from being as widely/easy to customise and hack your own components together. My method of getting SwitchBot working via the API is the only way at the moment I think (someone might come up with this rolled up in a third party integration I guess at some point), but you can still pair using Matter if you want (that's super easy if the device supports it) or Bluetooth. I am personally using Bluetooth for all of my SwitchBot devices via ESPHome Bluetooth Proxy extenders. This doesn't work for the temperature sensors though which I'm using the API for at the moment until Matter is totally stable and out of beta.
I don’t think the hub mini (the one without the screen) is matter certified. My main goal is getting the IR signals I have saved in the Switchbot app setup as devices in HomeKit. With that said, I believe you’re correct, your way of doing it using the API is my best option. Or, get another rasp pi for Hoobs to run to do what it does well. Then use HA for automations.
Thank you very much for your video. It is very valuable. For complete happiness I need to know how to handle the current state of my lock. I have adopted your code for my smart lock, but I cannot control the state of my lock - i.e. it is always shown as closed. Please help me how to get 'lockState' from the JSON that I receive to my lock in home assistant. Thank you in advance :)
Getting lockState works exactly as shown in my video. If the raw data isn’t updating then that’s not something I can fix, this method can only read what is already there. For the lock, Bluetooth is the most reliable method of monitoring the state and you can control it too. Controlling it works via the API too by adapting the method I’ve shown.
@@SpeakToTheGeekTech I'm sorry, but could you give me more precise information? I've watched this a hundred times and still can't find a solution. Is Home Assistant able to process the API response after opening/closing the door that it is open/closed and set that status for the door entity? Sorry, I'm new to Home Assistant and still learning.
My solution here is a 'fetch' solution. It checks the API every few minutes to see if there's a change, and updates the sensor states accordingly. Yes, it can do what you want, but it will not be realtime - there will be a delay in it updating and it will only show the status at the time it checks. So if you open and close a door, it will probably not see that change. I've provided the basic building blocks in this guide but I can't provide a specific guide or exact help for everyone's circumstances sorry. I am working on another video which will be a 'push' solution, so SwitchBot's API can push the status to sensors and things in realtime, but that's not ready yet and also you would still need to customise it to your exact requirements. I get all the information to tweak what my tutorial does from SwitchBot's own documentation (github.com/OpenWonderLabs/SwitchBotAPI). If you are struggling with this API method, try using Matter or Bluetooth to connect to your lock, it's much simpler for beginners.
Prime Day Offers! SwitchBot have 25% off during the Prime Day sales, plus you can get an additional 5% off with this code: XMSWITCHBOT
SwitchBot Hub 2 on Amazon UK: amzn.to/3JA6Dpr (or Amazon US: amzn.to/44mK3IH)
SwitchBot Hub 2 Direct from SwitchBot: bit.ly/46vmteX
Valid until 30th July 2023
I was wondering if the blind tilt got an update to allow webhooks yet?
I have been struggling for ages to get my SwitchBot Curtain Rod working with Home Assistant.
Your video has finally solved it for me. Thank you very much! 🙂
I’m very glad it helped!
Really helpful. Thank you so much. I have a mini hub and thought I'd have to invest in a hub 2 to get my curtains working. The process you describe is totally different to most descriptions, so something must have changed at the Switchbot end. But you have saved the day!
Glad it helped! You can also use Bluetooth Proxies via ESPHome if you want to have local control of the curtains in Home Assistant. I have that working with the Curtain 3 and the Blind Tilt.
Great video, helped me get my Switchbot stuff into HA in the easiest way via a hub and the cloud API. Bluetooth is a pretty bad protocol for local comms and is only really useful for device to hub occasional updates and not for HA Host to device.
Glad it helped. However, I personally run all of my SwitchBot devices over bluetooth straight back to HA. I use ESPHome bluetooth proxies (two of them) to cover areas where the Pi can't reach, and those proxies talk over Wifi. So far it's perfect and rock solid, but you do need to like playing with ESP32 modules :)
As a HA noob this video really helped me out - have managed to get all the different SwitchBot MeterPluses picked up and now just need to get some automations going to control my wifi fused spurs so my dumb eletric heating will finally be smart! Thank you!
Glad it was useful!
For a 2nd blind. Do I just enter the rest_command again? I have one working but when I just add another rest_command it cancels out one of the blinds. Thanks in advance.
Thank you so much. Your video has saved me hours!
Glad it helped!
Beautifully explained and well documented. Thank you, this was extremely helpful.
Glad it was helpful!
Carissimo, grazie per il video e per le dettagliate informazioni trovate sul blog.
Ho provato ad utilizzare i suggerimenti e sembrava che le API (con swithbot All Devices) fornissero le informazioni necessarie (ho due termometri).
Purtroppo dopo non hanno più funzionato: ottengo l'entità "sensor.switchbot_all_devices" con lo "Stato" OK ma non ci sono attributi tranne il friendlyname !
Puoi darmi qualche suggerimento ?? Thanks
Stessa situazione.
I don’t speak Italian but I am making a guess that your all devices sensor is empty? Have you tried waiting a few hours or reducing the refresh period on the sensor temporarily?
@@SpeakToTheGeekTech
First of all, thanks for the reply!
I then tried to reduce the update time and finally managed to get the data!
Thanks again.
A little information, if I also wanted to obtain the sensor battery data (I have two Meter Plus) which entity should I configure?
Thank you again
There is a battery entity you can pull from the API for the meter plus. You’d do it in the same way as you get humidity or temperature. github.com/OpenWonderLabs/SwitchBotAPI?tab=readme-ov-file#meter-plus-1
Thanks for creating this video. This has been very helpful for me getting the API setup and was much easier than trying to get teh python script working in HA which I had created
Glad it helped!
Thank you for your time putting this video together and sharing your techywizardry with we semitechnical folk.
You're welcome :)
@SpeakToTheGeekTech Any tutorial regarding getting the Hygrometers temps from SwitchBot API Cloud that sync with the SwitchBot Hub Mini (Don't have the bluetooth) ? Seems to the SwitchBot Add-On on HA isn't able to retreive device from API Cloud. Thank you in advance.
There's no specific guide, but it's basically the exact same guide as shown in this video. Instead of pulling the data from the Hub 2 as I do in this tutorial, you need to find your temp/hydro meter devices in 'all devices' and use that instead. The key names are still temperature and humidity just like my example: github.com/OpenWonderLabs/SwitchBotAPI#outdoor-meter-1
Hi! I use a Hub 2 to remote control my old Air conditioning unit. I have a Shelly blu motion sensor. Do you know if I use the Shelly blu to trigger the switchbot hub 2 when, for example, the Shelly detects no motion for more than 5 minutes? Thanks a lot
Yes that is entirely possible using a Home Assistant automation and the SwitchBot API to call an IR command on the Hub. I haven't shown an example of calling IR commands in this guide but it's all in SwitchBot's API documentation.
@@SpeakToTheGeekTech thanks Sir. I’m totally unfamiliar with Home Assistant and API. Do you know if I can do this from within the Shelly device web interface ?
@@francesca7765 Not a clue sorry, I have never used that Shelly device and I also doubt that's possible anyway. Calling the SwitchBot API requires a fair bit of work as you might have seen in this video.
I am trying to control my switchbot BlindTilts Using Switchbot API 1.1 following the procedure in your video. I can run my automation successfully one time after restarting HA. All subsequent attempt cause a 401 error. All of you rest_Command sets the nonce value to "". Searching the web, I found info stating the nonce value needs to be a different random number for every attempt. However, all my attempts to implement this have failed. How do you get the rest_command to work without setting the nonce value?
As far as I can tell the nonce value is optional. Just to make sure things haven't changed, I've spent the last few minutes double-checking my configuration and testing it for you! My rest_commands still work fine for both the Curtain 2 Bots and the Blind Tilt with no nonce value set.
Thanks for responding promptly. Do you have any suggestion as to what else will cause it to work only on the first attempt after HA restart?
Hi, I have one issue when adding the rest sensor, later I'm adding it, restarting etc..., I'm going to the developer tools and I search for switchbot_all_devices but I only get "friendly_name: SwitchBot All Devices" but not more info.The token and the key are ok, I use them lo link switchbot cloud integration. What could I been doing wrong? Thanks
It takes a while for the first update (see the refresh interval). If you set the refresh interval to a lower value it should update more quickly. It's a good idea to set this back to. a high value after the first population though
@@SpeakToTheGeekTech I tried this too, but I think I found the problem, I was writing in the configuration.yaml above the tss, automation, scrip, scene etc... and it wasn't working, I saw again the video and I realise you had it written below and I tried, when I saved and reboot everything was showing and now I have it comunicating with the hub 2 and I see temp and humidity, I'm new on home assistant and I don't know if this may be the issue or just I didn't wait enough. Thanks for the reply and great tutorial, I'm adding now one bot reading the API commands.
Hello,
I have done as in your instructions.
But my list under "SwitchBot All Devices" shows no entries.
I have integrated a "Hub2" and an "Outdoor Spotligt Cam" into my Switchbot app. What could be the error?
If I set up the Switchbot integration (cloud) in HomeAssistant with the same token and key. I then also get no devices shown.
Thanks for the help
Greetings
Frank
It can take a while for all devices to update using the default refresh rate in my example. You can either change that to reduce it in your config, or wait about an hour for it to update.
You say the blind tilt doesn't support updating status, but Curtains does? Would you be able to help me work out how to update the status of Curtains automatically? I think you mentioned "web hooks"? Thanks
I've not written a tutorial for webhooks yet, mainly because although it works a lot of the time I haven't found it totally reliable. It's also not the sort of thing I could type out instructions to in a comment as it's a full on guide that's needed if you're not familiar with how that sort of thing works.
@SpeakToTheGeekTech ah okay thanks anyway! I was after setting up a ZigBee button to toggle the curtains open and closed, but if I control the curtains from another source the status doesn't update so the toggle button behaves cronky
I personally use bluetooth to connect Home Assistant directly to the SwitchBot curtains, you can use an ESPHome bluetooth proxy to extend that if necessary. If you have a SwitchBot Hub then you could use Matter too for control. Both of those methods have live position status.
@@SpeakToTheGeekTech Thanks mate. I have bluetooth set up using a dongle attached to the Home Assistant Green. I have found that the initial connection is sometimes unbearably slow. Once the first command has worked, the subsequent commands are very responsive. I don't think range is the issue as the dongle is close to the curtains. I have a switchbot hub but it's called "Switchbot HUb Mini E2" and I can't work out if it supports matter or not.
Great video, thank you for spending the time to put this together. I attempted to add my thermostat and getting results for the all devices entity however for humidity and temperature is state unavailable , any suggestions?
You definitely have the hub 2 and not the hub mini? If so then I wouldn't know what is wrong sorry. If you are querying the correct device and it's pushing out the data, and ht API is presenting it back to you then it should all work, but as you can see there are a lot of places in that chain where issues could happen.
Hi, thanks for the video! I am trying to read the state of my switchbot motion sensors, however I only managed to get to the state
body:
deviceList:
- deviceId: [deviceID]
deviceName: [deviceName]
deviceType: Motion Sensor
enableCloudService: true
hubDeviceId: [hubdeviceID]
...
the point where I am stuck is how to set this up as a sensor. I read that it should be binary sensor, so I guess it would work differently than the example you set up (and not too familiar with home assistant programming). can you point me to a resource to find out?
i have the same problem but with smart lock :)
This method is not suitable for sensors like this because you will not get real-time status updates. You need to use callbacks and that’s a lot more complicated. I’m planning a video on this in a few months.
@@SpeakToTheGeekTech thank you! I will return Switchbot and also abandon the idea to use it remotely on a different wifi to monitor the roof, instead deploy a second instance of home assistant at that location for now
App version is moved to About in the menu in Swichbot app version 9.0, so this trick is not working to get "Developers options"
In the new app: profile > preferences > about > developer options
May i ask a question, i actually use the rest.yaml to store all those sensors and i got a very smooth process to follow your instruction in the video/web. However, when i enter into the rest_command: i got the Error loading /config/configuration.yaml: expected '', but found '', it will be same if i added the rest_command to the configuration.yaml neither
I also split out my configuration in my proper HA installation - I just show it in a single file in my demos for simplicity. rest_command would be a different root section (like rest is) so would sit in a separate file from rest.yaml, or it can just sit as a root object in configuration.yaml. I suspect there may be a rogue spacing issue in the copy/paste you have done if you are seeing an error? I actually used my own guide about 2 weeks ago, pasting everything into just configuration.yaml ready for another SwitchBot video I was preparing and all config was still good then.
Thanks@@SpeakToTheGeekTech, cause all the copy and paste work fine for me and let me share with you if I got any resolution in this case stay tune.
@@SpeakToTheGeekTech finally i add the rest_command: to configuration.yaml, with everything being lower case and it's work.
Thank you for a very helpful video. Unfortunately I have some problem. I do everything and it shows temperature and humidity for a few minutes and then it writes "unknown." If I restart HomeAssistant it shows temperature and humidity again for a few minutes and then writes "unknown." I have Hub 2. Also one more question, is it possible to add two Switchbot hubs ? I have one in a basement and one in a floor.
For a second blind . Do I just add another rest_command to the yaml? When I do it cancels one of the blinds out. Thanks in advance.
Yes but you have to give them different names
Got it working but sometimes it is VERY delayed. Is this just because it has to go to Switchbot's server over the internet? Any tips to make it faster?
I did try getting this all set up over bluetooth. I can see the curtain status over bluetooth but the action buttons dont do anything.
i read you can also do this over matter but i dont really wanna spend £80 on the hub 2 just to get matter
Sounds like your hub might be quite a distance from devices you are controlling. It needs a reliable and close bluetooth connection between them to work properly. Also, updates won't be live either using the API method because it's a pull method to get the status. I personally use direct bluetooth from Home Assistant to the devices for most things, and I use ESPHome bluetooth proxy devices (you have to make them yourself) in order to extend the bluetooth signal into the room with the devices in.
@@SpeakToTheGeekTech Thanks. The hub is pretty close but I'll move it closer. I don't think I need status updates to be live or fast, I just want the open/close action to be fast.
Will the API method stop working if my internet connection goes down?
I'd love to get direct bluetooth working. I have a bluetooth adapter plugged into my Home Assistant Green. I can see the curtains and their open/close status updates in real time, but the open/close buttons in HA do nothing. Would you be able to give me a hand getting it working?
Thank you for your help and your well-made content
The API method will only work if you have an internet connection, that's correct. I wouldn't know why your open/close command don't work - for me it works straight out of the box really. Could be an unsupported bluetooth adapter maybe but I haven't heard of your issues so it would be Google time.
I literally did everything you did and when i call service restful command, it doesnt open the blinds.
Nevermind I figure out what was wrong.
Great tutorial! However, this isn't fully working for me for some reason. I'm using the hub mini and the sign script works well, but when I try to pull the list of devices and subsequent steps, nada. It does work when I use the "sign" header in postman for example.
Try setting the scan_interval to 60 for the devices sensor, reload the config and wait about 2 minutes to see if that works. Sometimes the very first run doesn't work and you have to wait the whole timer (3600 seconds / 1 hour) for it to try and refresh the list again.
Thanks for coming back to me! I appreciate it. No luck yet though, and the "Switchbot Cloud" integration is a bit useless. I'm determined to make it work :)
For some reason my all devices sensor returns only "OK" :/ I do have a T value so everything else must be correct I presume
Set the update interval temporarily on the all devices sensor to 60 and wait a minute.
The All Devices list is empty, I did exactly what you did? It only shows 1 attribute: "friendly_name: SwitchBot All Devices" and nothing else.
How long has it been? It can take a couple of hours to populate or you can temporarily change the refresh time for the all devices sensor to something lower.
SwitchBot might also have updated the API, you may need to change the line:
- resource: api.switch-bot.com/v1.0/devices
to
- resource: api.switch-bot.com/v1.1/devices
@SpeakToTheGeekTech thank you for your reply. It's s a couple of days now, and I already tried the 1.1 version. Is it still working for you?
Yup all working fine on latest version of Home Assistant with the 1.1 version in the API URL
@SpeakToTheGeekTech OK, thank you. I'm running the latest software (Home Assistant) on my VMware ESXI server. I will try another platform, I don't think it will matter, but it doesn't hurt to try, I guess.
Hello, thank you for your work! Do you think it works with outdoor meter sensor? I followed the tutorial, but when I want to check the state of "SwitchBot All Devices" their is no device. Thank you for your help!
I have the SwitchBot Outdoor Meter (the white one that has a lanyard) and can confirm it works just fine with the API. It shows up in my All Devices data, and I can access value_json.body.temperature and value_json.body.humidity values.
@@SpeakToTheGeekTechok thank you, I will continue to identify the issue.
awesome. Would you help doing the same for the hub mini and the switchbot button?
KR
The SwitchBot button (remote?) does not have any API status information. More importantly it would require configuring web hooks to get an event from it which I haven't covered in this video, and the API doesn't appear to publish that event for that device anyway sorry.
wow that was a quick reply@@SpeakToTheGeekTech ;-)
Loved your video BTW. I believe this is doable via MQTT?
Would you mind helping me get the configuration.yml elements for the hub mini and the temperature sensor (different device)
Thanks again
To my knowledge there is no way to get the remote to work with Home Assistant because it is bluetooth paired with your hub. As for getting the temperature sensor data (doesn't matter if it's hub 2 or hub mini, that's just your gateway), you need to start by looking in the all devices data and finding the device ID in there. Then it's basically the same configuration as I demo for the hub 2 sensors but using your unique device ID.
Thanks for your feedback I will test with my temperature sensor deviceId@@SpeakToTheGeekTech
On the other hand, what I can do is getting a blue tooth tongle then in order to integrate them all, right?
No, the remote is not supported by Home Assistant at this time regardless of whether you have bluetooth connectivity on your server or not. I have a Raspberry Pi, it has built in bluetooth, it can see most SwitchBot devices but not the remote.
Hello,
I would like to thank you for putting together a comprehensive guide on the switchbot api v1.1. However I am appearing to be getting issues with sensor.switchbot_all_devices only showing me the state as OK and not giving me the body. I have confirmed all steps previously works.
Thank you in advance
Change the refresh interval on that sensor down to 60 seconds and it should appear more quickly. You can set it back to 3600 afterwards.
Why do we have to use their cloud api? I thought one of the main selling points of matter (which this hub claims to support) was offline capability? The main reason I use HA is to keep my devices offline. So it’s kind of a bummer we have to use apis to accomplish flipping a simple switch 😢
For the products that are Matter compatible you don’t need to use this cloud API. You can just pair and off it goes. The Cloud API is just an option.
Will this work just the same with the SwitchBot hub mini?
Yes it works fine with the Hub Mini for any devices paired with your account via the hub. But the Hub Mini doesn’t have any built in sensors so you won’t get any data from the hub itself.
Makes sense. I’ve been using Hoobs to bring non HomeKit native devices into HomeKit.
I’m trying home assistant and I will say, it’s much more complicated to get Switchbot working. With Hoobs there was a GUI where I put the token, key, etc..
I was hoping that native SwitchBot integration in Home assistant would work but no luck. I was under the impression Hoobs was a stripped down version of home assistant.
I guess what I’m asking, could you tell me why getting Switchbot integrated with home assistant is much more complicated than on the Hoobs platform?
I've never actually used Hoobs but from what I can see there's nothing that suggests it might be based on Home Assistant. I think it's a totally different development program. It has been designed to be as user friendly as possible which is in contrast to Home Assistant that developed from being as widely/easy to customise and hack your own components together. My method of getting SwitchBot working via the API is the only way at the moment I think (someone might come up with this rolled up in a third party integration I guess at some point), but you can still pair using Matter if you want (that's super easy if the device supports it) or Bluetooth. I am personally using Bluetooth for all of my SwitchBot devices via ESPHome Bluetooth Proxy extenders. This doesn't work for the temperature sensors though which I'm using the API for at the moment until Matter is totally stable and out of beta.
I don’t think the hub mini (the one without the screen) is matter certified. My main goal is getting the IR signals I have saved in the Switchbot app setup as devices in HomeKit.
With that said, I believe you’re correct, your way of doing it using the API is my best option.
Or, get another rasp pi for Hoobs to run to do what it does well. Then use HA for automations.
@@SpeakToTheGeekTechalso, thank you for taking the time to reply!
Did not appear SwitchBot All Device in state for me
Give it a little while to refresh
Thank you very much for your video. It is very valuable. For complete happiness I need to know how to handle the current state of my lock. I have adopted your code for my smart lock, but I cannot control the state of my lock - i.e. it is always shown as closed. Please help me how to get 'lockState' from the JSON that I receive to my lock in home assistant. Thank you in advance :)
Getting lockState works exactly as shown in my video. If the raw data isn’t updating then that’s not something I can fix, this method can only read what is already there. For the lock, Bluetooth is the most reliable method of monitoring the state and you can control it too. Controlling it works via the API too by adapting the method I’ve shown.
@@SpeakToTheGeekTech I'm sorry, but could you give me more precise information? I've watched this a hundred times and still can't find a solution. Is Home Assistant able to process the API response after opening/closing the door that it is open/closed and set that status for the door entity?
Sorry, I'm new to Home Assistant and still learning.
My solution here is a 'fetch' solution. It checks the API every few minutes to see if there's a change, and updates the sensor states accordingly. Yes, it can do what you want, but it will not be realtime - there will be a delay in it updating and it will only show the status at the time it checks. So if you open and close a door, it will probably not see that change. I've provided the basic building blocks in this guide but I can't provide a specific guide or exact help for everyone's circumstances sorry. I am working on another video which will be a 'push' solution, so SwitchBot's API can push the status to sensors and things in realtime, but that's not ready yet and also you would still need to customise it to your exact requirements. I get all the information to tweak what my tutorial does from SwitchBot's own documentation (github.com/OpenWonderLabs/SwitchBotAPI). If you are struggling with this API method, try using Matter or Bluetooth to connect to your lock, it's much simpler for beginners.
@@SpeakToTheGeekTech ok thanks for your answer. I think I need to learn the basics of home assistants. Greetings
hmm im geting this. why?
content:
message: Unauthorized
status: 401