BLE Beacons with Tasmota32 - Proof of Concept
Passerelle Sonoff Zigbee Bridge (ZBBridge) avec Domoticz->

While installing the latest stable release of Tasmota32 (11.1.0) on a DualR3 Lite by Itead, I noticed that it supported Bluetooth Low Energy (BLE). Wanting that familiarize myself with that technology about which I knew next to nothing, I proceeded to waste a couple of hours of time. Tasmota was displaying messages from a BLE beacon, but no matter what I tried, it was not possible to trigger a rule which is about the only feasible way I could think of to send the beacon information on to my home automation system. In the end the solution was very simple: don't use the stable version, use the development version of Tasmota32-bluetooth ( or, presumably, a subsequent stable release.

For the few that might be interested in how I went about testing this, here is some information.

First you need a beacon. There are IOS and Android apps, but I found something marginally more useful to do this. Called linux-beacon which is "[a] Python [2.7] script that creates an Apple® iBeacon®-compatible Bluetooth LE beacon using a computer running Linux and a Bluetooth LE adapter" according to the author Donald Burr (dburr). I wasn't too thrilled with the fact that the script did not run in Python 3, but I found two ports to Python 3 among the forks. I finally ended up reworking one of the ports for reasons explained in my fork. It is a simple matter to download the script to any computer equipped with a Bluetooth adapter and running a relatively recent copy Linux. This includes a Raspberry Pi 3 B running Raspberry Pi OS (buster) (i.e. Debian 10.8) and my desktop which is older than that Pi and which is running Mint 20.1. My version of the script named ibeacon is easily downloaded.

michel@hp:~/beacon $ wget https://raw.githubusercontent.com/sigmdel/linux-ibeacon/master/ibeacon --2022-05-27 20:12:07-- https://raw.githubusercontent.com/sigmdel/linux-ibeacon/master/ibeacon ... 2022-05-27 20:12:08 (5.79 MB/s) - ‘ibeacon’ saved [7577/7577]

Then make the downloaded script executable and start a beacon with it.

michel@hp:~/beacon $ chmod +x ibeacon michel@hp:~/beacon $ sudo ./ibeacon -M 5 -m 12 Advertising on hci0 with: uuid: 0xE20A39F473F54BC4A12F17D1AD07A961 major/minor: 5/12 (0x0005/0x000C) power: 200 (0xC8)

Open the Web interface of a device running at least version 11.1.0 of Tasmota32-bluetooth. Click on the Consoles button, and then on the Consoles button.

Tasmota web interface - getting to the web console

In the Enter command edit box, type the following backlog so115 1; ibeacon 1;. The setOption115 1 command enables Bluetooth. This can also be done from the Web interface main menu by clicking on the Configuration button, then clicking on the Configure BLE button, checking the Enable Bluetooth box and, finally, clicking on the Save button.

Tasmota web interface - beacon message

Every 15 seconds or so, the beacon from the linux-beacon will reach Tasmota and it will be echoed as an MQTT message on topic tele/newR3/SENSOR (note that newR3 is a modified MQTT topic and you will see something different) as can be seen in the screen capture shown above. My home automation system does not subscribe to Tasmota MQTT tele/# topics, so it was necessary to set up a rule to publish a meaningful MQTT message to the domoticz/in topic.

Here is one of a number of possible rules. Enter it in the edit box under the console output window as before.

Rule1 on ibeacon#UID=E20A39F473F54BC4A12F17D1AD07A961 do publish domoticz/in {"command":"switchlight","idx":173,"switchcmd":"Toggle"} endon

The response will be shown on the console.

01:08:53.664 CMD: Rule1 on ibeacon#UID=E20A39F473F54BC4A12F17D1AD07A961 do publish domoticz/in {"command":"switchlight","idx":173,"switchcmd":"Toggle"} endon 01:08:53.684 RUL: Stored uncompressed, would compress from 133 to 118 (-11%) 01:08:53.693 MQT: stat/newR3/RESULT = {"Rule1":{"State":"OFF","Once":"OFF","StopOnError":"OFF","Length":133,"Free":378,"Rules":"on ibeacon#UID=E20A39F473F54BC4A12F17D1AD07A961 do publish domoticz/in {\"command\":\"switchlight\",\"idx\":173,\"switchcmd\":\"Toggle\"} endon"}}

which shows that the rule has been stored but that it is disabled ("State":"OFF"). Enable the rule by entering the command

Rule1 on

Tasmota web interface - domoticz_in MQTT message

As can be seen, each MQTT message tele/newR3/SENSOR from with the IBEACON and containing the specified UID generated by Tasmota in response to a BLE message from the linux-beacon app gave rise to a domoticiz/in message toggling a Domoticz light switch with idx 173. It is not particularly useful to toggle a lamp by my desk on and off every 15 seconds, but it proves that it works.

Again, this rule will not trigger if using the current release of Tasmota32 (version 11.1.0); it does work with version

To stop the linux-beacon, use the following command.

michel@hp:~/beacon $ sudo ./ibeacon -z

I do not have a real BLE sensor that would allow me to work out a meaningful example, but maybe the next ship in from the Far East will bring something along those lines. We'll see. Well that wasn't really a well thought out statement. An ESP32 can send BLE beacons. So I may be experimenting with BLE beacons sooner than I expected.

Passerelle Sonoff Zigbee Bridge (ZBBridge) avec Domoticz->