Switch Bot

@ jellytotz

If you are referring to the switchbot bot, it gives you the states on or off. The issue with this is that if someone manually turn on/off the device. The state HA says will not be accurate. Furthermore, when HA reboots, it reverts to off.

With that said, you can create a switch to retains it’s states when HA reboots using an input_boolean. This is how I did to one of my bots. My bots is controlled via shell command. I believe it will work with a switch as well. You can use it as a guide and tweak to your setup.

input_boolean.yaml

  washroom_fan:
    name: Washroom Fan
    icon: mdi:fan

shell_command.yaml

  24hr_fan_bot: 'curl -k "http://192.168.1.30:5004/?id=fab50h9b504e&cmd=press"'

switch.yaml

  - platform: template
    switches:
     24hr_fan:
       friendly_name: '24hr Fan'
       value_template: "{{ states('input_boolean.washroom_fan') }}"
       turn_on:
         - service: shell_command.24hr_fan_bot
         - service: input_boolean.turn_on
           entity_id: input_boolean.washroom_fan
       turn_off:
         - service: shell_command.24hr_fan_bot
         - service: input_boolean.turn_off
           entity_id: input_boolean.washroom_fan
       icon_template: >-
         {% if is_state('input_boolean.washroom_fan', 'on') %}
           mdi:fan
         {% else %}
            mdi:fan-off
         {% endif %}

1 Like

Hello,

I’ve some switchbot thermometer and a switchbot hub min.
Can anyone explain me how to make the integration of these without IFTTT?

I’m realy lost…

THX

Hey guys,

I have a HA VM with no BT, can I use this though the hub?

I believe you can use switchbot api. Request API token via the feedback within the mobile app.

There is no integration though, someone would need to make it?

This is how I do it. It’s all local without using the cloud API, which didn’t exist at the time. It also doesn’t need the hub, but you can keep it if you still want to be able to see your Meter in the Switchbot app.

Here is a very detailed video covering how to set everything up, starting from 3:04.

1 Like

Thanks for that,

My issue is though I run HA through a VM with no BT.

At the moment, I have have the devices coming through to HA via SmartThings integration. But just makes it hard to get rid of SmartThings (its pretty much dead anyway lol)

Ill have to think about it

A VM without Bluetooth is no problem with this method. You use a separate device like a Pi Zero W to sniff BLE and publish MQTT messages for your HA instance.

Depending on your host set-up, you might be able to run sbm2mqtt on the host system of the VM instead of on a separate machine, assuming it’s Linux. Some people run it under Ubuntu.

Ok, that’s interesting… Maybe finally a use for the 5 or so Pi Zeros I have haha.

So basically install This on the Pi and point the home assistant MQTT broker to it?

checkout my code for esp32. all the work is done by esp32 to convert mqtt to switchbot bluetooth and back to mqtt response. Zero failures over the past week. you can add as many esp32s around the house to get maximum coverage

Yes, that’s right. I’ve tested it with four Meters. You’ll have to do something else for for button presser, though.

2 Likes

I’m trying to figure out the options to have the Switchbot Bot get triggered. Any thoughts around this? I have the same HA setup in a VM with no Bluetooth.

I do have a spare Pi lying around that I could setup to script, but would like it controllable eventually in HA even if it went over MQTT.

Just wondering how you had gotten the ID of the bot that you use within your CURL shell script

@ damonizer
Hi. I am using node.js to control the bot. You can find some info here and how I set it up. You will need an extra rpi at the least for this. I used a rpi zero w.

Hi
i used your code to do the multiple consecutive clicks part for my switchbot but i can’t get it to work

Hey there,

I have also 2 ps of switchbot. I have those intergrated in my Home assistant an i can see the status of my curtains off the are open or closed. So i also intergrated mij BLT MAC in my config, but i stil cant controll mij curtains. When i press open or closed there is nothing happend. Is here somebody how knows what it can be?

Thanks.

Is there any way to still make use of the Hubs Minis to get the data from the Meters or should I just see buying those as a mistake? Do people also sell those ESP32s in some kind of case that doesn’t scare normal people?

I’d not be installing it in a house.

I just bought a switchbot to control my Desi( A turkish brand) door lock with bluetooth.

The bot has easily been detected with the official integration without the need of an hub.

Because my door lock is only bluetooth I have sticked the bot into it to run operations through HA to open the door from outiside.

I have also configured an automation to run directly from telegram so that other people can also open the door lock. İt works perfectly fine. You just have to enter their telegram id into configuration.yaml.

But there is one little problem.

action:
  - service: telegram_bot.send_message
    data_template:
      target: '{{ trigger.event.data.chat_id }}'
      message: Tamam {{ trigger.event.data["from_first"] }}, Sokak kapısı açıldı!
  - type: turn_on
    device_id: 584c23e38e377e02a283a93483e10f32
    entity_id: switch.berko
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - type: turn_off
    device_id: 584c23e38e377e02a283a93483e10f32
    entity_id: switch.berko
    domain: switch
mode: single

The integration lets you to use on - off and - toggle switchbot bot commands.

As seen in my automation for the action part whenever /door command written to telegram as an action switchbot activates. But with one slight problem. The bot keeps opening unless I give another action to close as you can see in automation.

That is not a big problem because it closes with the second “Turn off” command but I would like to know if there is a way to let the bot run only once in HA ?

Hey @duceduc
Trying to find a way to keep my switchbot alive. Or at least give it a nudge it needs to wake up. Is:

24hr_fan_bot: 'curl -k "http://192.168.1.30:5004/?id=fab50h9b504e&cmd=press"'

A way to do that? What is the ip address and where would i find the id and commands ?

Thanks!

Hey atv,
I have ditched this method awhile back and have gone with this method instead.

The commands are manually inputted and the id is the mac address you can find in the switchbot app under that switchbot device. So for the switchbot bot you will need to add the scan command and have it scan xx minutes. That would keep it awake.