Reading sensor data from a BTLE device / iBeacon on via CLI

I have a BTLE-based soil moisture sensor (this one from AprilBrother) that I wish to monitor in HA ( It seems to broadcast as an iBeacon out of the box, and I can see it fine with hcitool. It claims to support Eddystone too.

It broadcasts the useful data as 2 bytes in the minor field (I believe this is an iBeacon field). I’ve written a shell (bash) script using hcitool and hcidump that will print out the temperature or moisture for a given MAC address, and it works great from the CLI (of a different Linux machine).

I’m now stuck as to how to get this data into HA. I don’t want to spend a heap of time going down a lengthy path to discover it is flawed in some way, so I was hoping to use the command_line sensor as a quick & dirty first step.

Where should I put my script so that it (1) can be accessed by the CLI sensor and (2) has access to the hcitool and hcidump tools (which seem to only be available on the host of, which I assume I can’t reach in HA)?

I can’t seem to write to the FS of the host system, but I can’t get to the required tools in the HA container. Do I need to build a docker image? Do I need to start over and write a Python add-on? Are there good references to start from for these approaches?


I could be interested in integrated this sensor to OpenMQTTGateway, if you want to collaborate and give me some informations on service data published by this sensor, i can try to do it.
Once it is integrated, the data will be published by mqtt thanks to an esp32 board.

Thanks! :slight_smile:

I’m not (yet) using MQTT in my setup but would certainly try it out if this worked. I modified this script to get to the data. Running hcitool lescan --duplicates then launching hcidump --raw captures packets like:

>  04 3E 2A 02 01 00 00 3C 67 1B 6A 3B 12 1E 02 01
   06 1A FF 4C 00 02 15 B5 B1 82 C7 EA B1 49 88 AA
   99 B5 C1 51 70 08 D9 00 01 0B 16 C5 C2

In this case, 3C 67 1B 6A 3B 12 represents the MAC (backwards - 12:3B:6A:1B:67:3C) of the device I want to poll. The iBeacon major & minor data live in bytes 40-41 and 42-43 respectively.

The temperature and moisture data are in the low & high bytes of the minor field (resp.), so byte 42 of the above payload is moisture (I’m not sure what the unit is here, but it’s 0x0B, or 11 in decimal) and byte 43 is temperature (0x16, 22°C). The unit was on my desk for this capture, so fairly dry and room temp.

Does this help you?

(FWIW, I’m still looking for a simple path to get this data into HA - e.g. a command_line sensor)

Thanks for the infos, if you install an app like beacon simulator, process a scan and click on the device, are you able to read the bytes you pointed for temperature and humidity into the “Service Data” section?

Yes, see the screenshot. The data is in the “minor” field of the iBeacon payload. The screenshot shows it in decimal, so 3350 Dec = 0x0D16 Hex, or 13 & 22.