Home Gadget News Configure the SwitchBot Bot button in Home Assistant via Cloud without Bluetooth

Configure the SwitchBot Bot button in Home Assistant via Cloud without Bluetooth

by Dejuan Stroman
Configure the SwitchBot Bot button in Home Assistant via Cloud without Bluetooth

Configure the SwitchBot Bot button in Home Assistant via Cloud without Bluetooth

That you just may purchase the SwitchBot bot machine for roughly 30 euros on Amazon:

It is fully significant that you beget got the SwitchBot Hub so as that you may well well send orders with out having to be comparatively end to the machine. We have to always be acutely conscious that Bluetooth does no longer beget as noteworthy differ as Wi-Fi wi-fi networks, so it’s significant that you enlighten this SwitchBot Hub internal reach. of the machine to give you an Internet connection.

Now that you know what two reliable integrations exist, and the negative allotment of native integration the exercise of Bluetooth, let's explore all the pieces you may install on your Dwelling Assistant to exercise the SwitchBot Bot from the Cloud API.

Bag the significant data from the SwitchBot app

In discuss in confidence to configure SwitchBot Bot in Dwelling Assistant the exercise of the Cloud API, it’s significant to set aside data from the producer's reliable application. When we beget now both the Hub and the Bot installed with the application, and related the Hub to our Wi-Fi wi-fi network, we’ll have to lunge to the «Profile / Settings«. If on the backside you damage no longer explore the selection “Pattern alternatives«, you may well have to click on the model of the application several instances (about 5 or 10 instances) for it to seem.

Within construction alternatives we can explore both the token and the secret key. Each and every of these items are entirely significant for the operation of the SwitchBot Bot thru the Cloud API. We reproduction this files from the application to the PC, the exercise of any potential equivalent to sending an electronic mail to ourselves.

Now we beget now to discover the Bluetooth MAC take care of of the SwitchBot Bot machine, to crash this we lunge to the machine in ask, and in the «Settings» click on «Tools data«. Here is the achieve we’ll explore the BLE MAC of the machine in ask.

As soon as we beget now your entire significant data: API key, secret key and Bluetooth MAC, we can lunge to our Dwelling Assistant to put in your entire machine we need.

Inserting in machine in Dwelling Assistant

In our Dwelling Assistant we’ll lunge to the «Settings/Add-ons» to put in an application called «AppDaemon«, is a machine that may allow us to elevate out scripts in Python language in our Dwelling Assistant.

We install this plugin as we beget now constantly done, and we allow the “Surveillance«, nevertheless the selection of «Automatic change» we lunge away it unchecked. Within the past we beget now up so a ways this plugin and it has “damaged” the Python script, due to they’ve made significant modifications in the change. So We imply you change manuallywhich potential diagram you may well well lunge benefit whilst you occur to explore that it doesn't work for some reason.

As soon as we beget now installed it, we’ll lunge to the “Settings” tab and in the “Python Programs» we build:

We press «enter» and then click on the «Attend«. AppDaemon will take care of automatically download this Python equipment and your entire significant dependencies, enormously facilitating the installation of this machine, which is fully significant.

Now that we beget now all the pieces installed, we’ll carry out the significant script to exercise the SwitchBot Bot by job of Cloud API in our Dwelling Assistant.

Originate the script to elevate out the recount

The first ingredient we beget now to crash is install the plugin «File Editor» whilst you occur to’ve got no longer installed it till now, because it’s one of the significant biggest Dwelling Assistant plugins to wait on watch over all interior recordsdata. Within the «Atmosphere» of this plugin, it’s significant to uncheck the «Attach into tag Basepath» to be succesful to lunge to the root direction of the recordsdata. As soon as we beget now done that, the inch to entry the AppDaemon configuration is «/addon_configs/XXXXX_appdaemon/«, here’s the achieve we’ll beget your entire current configuration.

We have to always carry out the Python script in the inch «/addon_configs/XXXXX_appdaemon/apps/«, here we’ll explore two recordsdata called «apps.yaml» and “howdy.py«. We click on carry out a brand unusual file and we’ll call it «switchbot-storage.py«, since we beget now positioned our SwitchBot Bot on high of a storage a ways flung that we is no longer going to wire, in this diagram, when running this Bot the bodily button of the storage a ways flung will seemingly be pressed.

The negate of the script is as follows:

import appdaemon.plugins.hass.hassapi as hass
import uuid
from switchbot import SwitchBot
class SwitchBotGarageClass (hass.Hass):
def initialize(self):
self.listen_event(self.botgarage_event, “COMMUNITY_GARAGE”)
def botgarage_event(self, event_name, data, kwargs):
self.log(“Switchbot button begins in storage”)
#Clarify Switchbot API token
your_switch_bot_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
your_switch_bot_secret=”XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”
switchbot = SwitchBot(token=your_switch_bot_token, secret=your_switch_bot_secret)
#We call different devices in the provider and decide the bot.
machine = switchbot.machine(identification='AABBCCDDEEFF')
#We present out pressing the bot to attain it work.
machine.recount('press')
self.log(“Pause switchbot button in storage”)

We solely have to comprise out three traces with our data:

  • your_switch_bot_token: it’s a ways the token that we beget now taken from the application, it’s a ways the first price that looks in red.
  • your_switch_bot_secret: is the secret password that we beget now from the application, ethical below the old price.
  • machine = switchbot.machine(identification='AABBCCDDEEFF'): we must always build the BLE MAC take care of with out the colon (:) or spaces, all in capital letters and the numbers.

Within the following screenshot you may well well explore the diagram it would possibly perchance well perchance explore:

1709567379 576 Configure the SwitchBot Bot button in Dwelling Assistant by job of Cloud

To activate the unusual Python script in AppDaemon, it’s very significant so as to add the following to what already exists:

switchbot-storage-door:
module: switchbot-storage
class: SwitchBotGarageClass

Within the following screenshot you may well well explore the diagram it would possibly perchance well perchance explore:

1709567379 114 Configure the SwitchBot Bot button in Dwelling Assistant by job of Cloud

Now that we beget now all the pieces ready, we can lunge to the AppDaemon pluginclick on «Beginning the discover interface» and in the 2nd choice of «Convey» we can explore that it has known it correctly. It is one ingredient that it recognizes it correctly, and fairly one other is that once it’s completed it does no longer return any errors.

1709567380 357 Configure the SwitchBot Bot button in Dwelling Assistant by job of Cloud1709567380 700 Configure the SwitchBot Bot button in Dwelling Assistant by job of Cloud

Now we beget now to carry out a script that is in articulate of executing this Python script that we beget now registered, then we can add this script to any button, automation, and various others. So as to crash this, we lunge to the «Settings / Automations and scenes«, in the « tabScripts» click on «Add Script«, we pick «Originate a brand unusual script.

We can configure this script with a descriptive name, in the «Sequence» we’ll have to make your mind up «Guide tournament” and in “Occasion kind» we build «GARAGE_COMMUNITY» or the name you beget got given to the Python script (in the code the achieve it says self.listen_event(self.botgaraje_event, «GARAJE_COMUNIDAD»)).

Now we can trail it thru the script introduction menu itself to test it, or set aside a button in primarily the most important menu that executes said script. When we trail it, we can explore both in the AppDaemon log, and in the Dwelling Assistant log in the App Daemon allotment, as well to in the SwitchBot Bot app in the “log” allotment that we beget now correctly completed the script.

As you may well well explore, this direction of is a lot more advanced than the exercise of the reliable SwitchBot Cloud integration, nevertheless this means works for the SwitchBot Bot machine that we beget now. It is a will have to beget that you be vigilant and no longer solely change the AppDaemon, it has came about to us more than once that the script has stopped engaged on account of an change, and we beget now needed to rewrite the script or lunge benefit till the trojan horse develop into once fastened.

Source credit : crast.net

You may also like