Switchbot

Hello everyone,
I found this thread when looking for “SwitchBot and OpenHAB”. As I did not find an “out-of-the-box” solution I started tinkering/ playing around with it and got it to work from OH.
I run OH 2.5.1-2 (Release Build) on a RPi 3 (integrated BT, no dongle) with Raspbian “stretch”

I would like to share what I did to make it work (wasn’t straight forward as I also learned some new concepts on the way).
First I connected the SwitchBot via BT to my (Android-) phone using the original SwitchBot app (no hub) and got the BT Mac address which I need later.
Then I installed “python-host” from OpenWonderLabs on Github following their instructions
and moved the “switchbot.py-file” to the location of my choice. The idea was to run the Python script from OH

To do this I installed the Exec-Binding through PaperUI
and also the RegEx Transformation (which I have not used any further yet)
The configuration I did through files:

Thing

Thing exec:command:<Thing name> [command="python <path to switchbot.py> <SwitchBot MAC> <command for SwitchBot>", interval=0, autorun=false]

(the available commands for the SwichBot are “Press”, “Turn On”, Turn Off", “Down” or “Up” (I found this looking through the switchbot.py file))

Item

Switch <SwitchBot_trigger> // item used for triggering the action and used in the "rule"
Switch <SwitchBot_Run> {channel="exec:command:<Thing name>:run", autoupdate="false"}

Sitemap

	Frame label="<Frame label>" {
		Switch item=<SwitchBot_trigger> label="<Trigger label>" icon="wallswitch"
	}

Rule

rule "<rule name for SwitchBot>"
when
   Item <SwitchBot_trigger> changed
then
    <SwitchBot_Run>.sendCommand(ON)
end

Sometimes I need to “trigger” it twice before it does something so I might need to change some timers to allow for the BT connection to be established

Status feedback would be nice but at this time I have no idea if or how this might be possible
I just came across a BT to MQTT by “zewelor” on github but did not do any further tests

Hope this helps anybody and if there is anybody who would like to comment or recommend any change/ different approach, this would be most welcome.