BLE gateway on a Raspberry Pi, Debian or Windows PC -> Theengs Gateway!

Hi @m4biz ,

We have identified and fixed a problem when changing the time between, will be fixed in the next release expected this month.

Ok. Iā€™ll wait.
Thanks

Hi there,

is it possible with TheengsGateway and OMG together using it as a room presence setup?

What i tried:
OMG on ESP32
Theengs on RPI3 + 4 with snapd

But i donā€˜t know how to configure the topicsā€¦
Do they have to be identically or differently?

Sorry itā€˜s all very new :wink:

Thanks

Hello,

With OMG it is already possible:

Just use the default presence topic, the different gateway name represent each rooms.

With Theengs gateway it will be available in the next release.

Also the next release of OMG will add the autodiscovery of tracker devices like Nuts, Tilesā€¦

Ok, i will wait for next releaseā€¦

Do you know the release date? :innocent:

Thanks

This is ideally what I wanted esphome ble proxy to do but all of the esp32 devices have a weaker BT antenna than I need. I was hoping for a rPI solution and now that may be the case. Will they LD2410 BLE MMW work with this?

Should be in the following weeks

1 Like

Has anyone got this going with LYWSD03MMC > Theengs Android app > Mosquitto > HomeAssist Autodiscover?

I have everything seemingly working up to getting the sensors to appear in homeassistant. Iā€™m clearly missing something, I just donā€™t know what it is or where to configure.

Hey,

I have installed TheengsGateway today. I have a esp32 bt proxy (olimex). Log file just tells me that in DEBUG mode:

[19:07:46] INFO: Creating TheengsGateway configuration...
[19:07:46] INFO: Starting TheengsGateway...
INFO:BLEGateway:Starting BLE scan
INFO:BLEGateway:Connected to MQTT Broker!
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded

It the Home Assistant BT proxy being supported out of the box or do I have to setup something at the ADAPTER field?

Thanks

Hi @syngin, similar to ble-monitor, ESPHome Bluetooth Proxies are not supported for TheengsGateway.

You would either have to use the internal BT adapter of the machine running TheengsGateway, or if the reception range might be too far, install the ā€˜proxyā€™ version esp32dev-ble-mqtt-undecoded of OpenMQTTGateway on a separate ESP32.

Running a full version esp32dev-ble of OpenMQTTGateway, which already includes the BLE Theengs Decoder, would allow you to directly connect to your MQTT broker, without the need of TheengsGateway at all. The current development version nightly build also already includes the SwitchBot Outdoor Meter.

Hope this helps.

1 Like

HI, iā€™ve just installed TheengsGateway, but it stuck on Starting, iā€™d like to use the internal raspberry adapter:

[10:36:51] INFO: Creating TheengsGateway configuration...
[10:36:58] INFO: Starting TheengsGateway...

could please help me? Iā€™d like to manage tuya BLE devices, is it possible?

Thanks

Can you set the log level to DEBUG and show the output of the gateway then? Often the problem is that the BLE adapter isnā€™t recognized.

I am working on end-to-end communication between WiFi based device and BLE based device connected to RPi4 via MQTT. I have implemented Wifi device and looking to implement BLE based device. Can you please help me on this?

What do you want to achieve exactly in term of use cases, and which devices do you want to use?

Iā€™ve got an rpi4 running theengsgateway and publishing to mosquitto on a local homeassistant machine.

I have four sensors, the LYWSD03MMC variety with the latest ATC firmware, set to broadcast every 60s.

TheengsGateway -H hass-address -u user -p pass works, but itā€™s posting tons of messages at a much, much higher rate than the sensors are configured to broadcast. Makes sense, itā€™s doing active polling. Feels like this is going to destroy the battery in these sensors.

Passive polling should fix that. I did enable the bluetooth service experimental flag, though the daemon is in /usr/sbin/ for me instead of /usr/lib/bluetooth/, restarted the bluetooth daemon, and added -s passive to my TheengsGateway invocation.

Now instead of pretty consistently sending ~260 messages every time, itā€™s sending 0 with the occasional 1 message from a neighbourā€™s Nest broadcasting, I guess.

Whatā€™s interesting is running btmon while TheengsGateway is running shows my four sensors having their broadcasts getting picked up quite reliably ā€“ the HCI Event with the data in the payload, as well as the MGMT Event with the very same data available. Itā€™s all there. Itā€™sā€¦ just being ignored?

I adjusted the scan times/time between scans to 5 second scans with 0 second delays in case it was just missing the broadcast, but this didnā€™t work. It just picks up the neighbourā€™s Nest broadcasts.

I can still see the HCI and MGMT events from my sensors in btmon, and I can see what look like the monitoring activations/deactivations happening frequently in the log as well, itā€™s just not grabbing the sensor broadcasts.

Any thoughts? Passive scanning appears to be working, itā€™s just not acknowledging the data coming in.

For the time being I set scans to 5 seconds and time between to 55.

With publish_all disabled, Iā€™m still receiving multiple messages for a single device during the scans fairly consistently. The data in each message is also different, indicating itā€™s being polled actively twice.

I have a feeling this is going to obliterate the batteries in the sensors, so getting passive scanning working would be awesome.

1 Like

alrighty, sitting down to actually look at this now.

I see the passive mode is hardcoded to look for flags 06 and 1a, but the ATC firmware appears to be broadcasting with flag 0x00000000. Makes sense, I assume the OrPatterns are acting as filters, and obviously 0x00000000 is not 0x06 or 0x1a.

Here are the events Iā€™m trying to pick up that btmon reports when doing a passive scan:

> HCI Event: LE Meta Event (0x3e) plen 29
 #49 [hci0] 226.169230
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Connectable undirected - ADV_IND (0x00)
        Address type: Public (0x00)
        Address: A4:C1:38:CE:BE:D2 (Telink Semiconductor (Taipei) Co. Ltd.)
        Data length: 17
        Service Data: Environmental Sensing (0x181a)
          Data: a4c138cebed200d62d540b95fd
        RSSI: -77 dBm (0xb3)
@ MGMT Event: ADV Monitor Device Found (0x002f) plen 33
{0x0001} [hci0] 226.169289
        Handle: 0
        Address: A4:C1:38:CE:BE:D2 (Telink Semiconductor (Taipei) Co. Ltd.)
        Addr Type: 1
        RSSI: -77
        Flags: 0x00000000
        AD Data Len: 17
        AD Data: 10161a18a4c138cebed200d62d540b95fd

I figured I would try adding the 0x00000000 flag to the OrPattern list and invoke BleakScanner directly with these bluez args:

patterns = [
        OrPattern(0, AdvertisementDataType.FLAGS, b"\x06"),
        OrPattern(0, AdvertisementDataType.FLAGS, b"\x1a"),
        OrPattern(0, AdvertisementDataType.FLAGS, b"\x00\x00\x00\x00"),
        ]

But the sensors didnā€™t show up. I see them in btmon but they arenā€™t getting thrown to the detection callback that dumps the device address and advertisement data to the console.

I think the issue is somewhere in the or_patterns but Iā€™m at a loss for what to plop in there to pick up the payload pasted above.

When doing an active scan, bleak immediately picks up the sensors and shows their AdvertisementData as such:

AdvertisementData(local_name='ATC_8036EE', service_data={'0000181a-0000-1000-8000-00805f9b34fb': b'\xa4\xc18\x806\xee\x00\xd7,\\\x0b\xd5\x1f'}, rssi=-48)

Iā€™ve tried an OrPattern of (0, AdvertisementDataType.SERVICE_DATA_UUID128, b"\x00\x00\x18\x1a\x00\x00\x10\x00\x80\x00\x00\x80\x5f\x9b\x34\xfb") to match the payload above, as all of them use that UUID, but this also does not seem to work.

What would be helpful is dumping out all the information from the beacon that I can associate with these OrPattern filters, but btmon seems to obfuscate that with human-readable names. Iā€™m a bit out of my wheelhouse here.

There are some other Common Data Types (page13) Iā€™ve been blindly poking at to no avail.

Any help would be appreciated.

EDIT-

Got it!

This will pull the previous postsā€™s example of the environment sensor, despite the 0x00000000 flag.

        OrPattern(0, AdvertisementDataType.SERVICE_DATA_UUID16, b"\x1a\x18"),

service data is 0x181a but I guess itā€™s little-endian, so the filter needs to be b"\x1a\x18".

thanks to the neighbourā€™s Hatch Rest that keeps broadcasting this presumably correct payload to test against:

> HCI Event: LE Meta Event (0x3e) plen 36                                                                                                                                                                            #85 [hci0] 329.946732
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Connectable undirected - ADV_IND (0x00)
        Address type: Random (0x01)
        Address: E7:43:21:09:48:B6 (Static)
        Data length: 24
        Name (complete): Hatch Rest
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        16-bit Service UUIDs (complete): 1 entry
          Device Information (0x180a)
        Service Data: Battery Service (0x180f)
          Data: 64
        RSSI: -99 dBm (0x9d)

Edit2

Double got it.

So I was using the ATC firmware from atc1441, not pvvx.

Switched over to the pvvx firmware and everything just works correctly out of the box. I should have realized something was wrong when the ATC firmware I was using was broadcasting bad payloads.

Carry on, everything is good to go now. :smiley:

1 Like

New release!

[1.9.0]

Whatā€™s Changed

On top of numerous new devices supported, this version brings exciting features like the support of encrypted advertisements, the capability to resolve private BLE addresses, HA MQTT discovery tuning, and TLS/Websockets support. Letā€™s dive in!

New devices

Devices Model Measurements
April Brother N07 temperature/humidity/battery/packet ID
BM6 Battery Monitor BM6 battery
GOVEE H5100 temperature/humidity/battery
GOVEE H5104 temperature/humidity/battery
GOVEE H5179 temperature/humidity/battery
INKBIRD IBS-TH12S temperature/humidity/battery
NUT NUTALE tracker
Oral B Toothbrush state, mode, sector, pressure, time
Lippert BottleCheck temperature/level/sync status/voltage/battery/reading quality/acceleration x/y-axis
ShellyBlu Button1 button press type/battery/packet ID
ShellyBlu Door/Window contact/rotation/battery/packet ID
ShellyBlu Motion motion, illuminance, battery, packet ID
ThermoPro TP357s temperature/humidity

New features

Miscelleanous

Documentation

CI

New Contributors

Full Changelog: Comparing v1.1.0...v1.2.0 Ā· theengs/gateway Ā· GitHub

Is there any possibility Theengs Gateway could support Sengled Bluetooth mesh light bulbs, specifically the B11-N1E? There are quite a few out there that were sold by Amazon to work only with Alexa devices. Theyā€™ve been identified as Telink bulbs, but I donā€™t believe anyone has managed to get them working in HA (without using Amazon Alexa). This would be a nice benefit to the community if possible.

https://www.reddit.com/r/homeassistant/comments/lh57ly/how_do_i_add_my_sengled_bluetooth_le_bulb_to_home/

Hello.
Iā€™m new in HomeAssistant (not in Linux) , coming from Jeedom and impressed by the power of HA !

I have already installed TheenGateway as addon of HA ( runing on a NUC as a VM with proxmox) and it works fine.
I would like to add an BLE ā€œantennaā€ on a raspi3.

1/ Which method do you recommand as I see python, docker, snap ā€¦ I would like to have something easy to configure, starting automatically on boot.
2/ which release of raspi debian do you recommand ?

Only theengs Gateway will run on it.

Thanks for advises.