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

From a long time it was asked if OpenMQTTGateway could run on a Raspberry Pi.

With the externalization of the part of OMG BLE code into Theengs Decoder and the multi-platform compatibility of the library, the doors were wide open to it.

By integrating Theengs Decoder into a Python script we made a multi-platform BLE to MQTT gateway that can run on a Raspberry Pi, Unix, Windows, MAC, and many more.

So now if you have a server with a BLE component you can retrieve decoded BLE devices data (LYWSD03MMC, Mi Flora, IBT-4XS, CGG1, TH1-2, Mi Scale… from Xiaomi, Inkbird, Govee, Qingping) and publish those to MQTT.

Cherry on the cake, TheengsGateway use the same API as OpenMQTTGateway, so it will act in concert with your existing ESP based OpenMQTTGateway.
If you use auto-discovery with OMG the sensors data will be automatically retrieved from TheengsGateway also!

If you have Python and Pip this is as simple as one command:
pip3 install TheengsGateway

Full documentation can be found below:
https://theengs.github.io/gateway/

7 Likes

Amazing work. Would be awesome if you’d make it available as an Add-on or as an AppDaemon app.

Good idea ! Let us search how can it be done so that it is super easy for HASS users to leverage Theengs Gateway

New version:

  • Add option to publish all detected devices. by @h2zero in #18
  • MiBand Activity Heart Rate Extension by @DigiH in #91
  • Switchbot S1 status decoder by @DigiH in #94
  • static_value bool implementation by @DigiH in #96
  • Initial NOT implementation by @DigiH in #97
  • Change property condition check to a function, add nestng support. by @h2zero in #98
  • Inkbird fixes and 6xS merge with Solis 6 by @DigiH in #101
  • Govee H5055 decoder by @DigiH in #102
1 Like

@mihsu81 developped an addon that enables to have Theengs with a few clicks in Home Assistant.

Just add this repository in the addon store.

Docs below:


Next step, sensor auto discovery!

1 Like

Auto discovery of sensors has been adeed to Theengs gateway:
https://gateway.theengs.io/install/install.html#install-theengs-gateway-as-an-add-on-in-home-assistant

If the gateway detect BLE sensors they will now be automatically created into the device registry of Home Assistant with the adequate entities.
Configuration options:

From this, you can add those to your dashboard and enjoy a less than 5 min yaml-free integration of your BLE sensors!

1 Like

Here is a GIF to show how flawless is the process:

Theengs-Addon-install5

1 Like

So does this mean that if I install this I can use my existing Mosquito MQTT and it will use the BLE in my RPi to communicate to devices?

Yes, you can connect it to your existing broker, it will retrieve data from your BLE sensors and send it to Mosquitto.

New Version v0.4.0:

What’s Changed

New sensors:

Others:

Full Changelog: v0.3.0…v0.4.0

Can this be used to control the switchbot button or only to gather the data (mode/state/battery) from it?

Good question, only to gather data from it, for the moment.

If you want to control it you can use an ESP32 with OpenMQTTGateway

1 Like

thank you for the quick reply!

@ylwmamba thanks for asking that clarifying question. I too was of the thinking that it could be used to control BLE devices not just pull data. Bummer. :man_shrugging:

1 Like

I’m running Theengs Gateway on one Raspberry Pi (let’s call it Pi A) and Home Assistant with Mosquitto on another (Pi B). It works great and my devices were auto-discovered in Home Assistant. However, whenever I restart Home Assistant on Pi B (or reboot) the sensors stay as unavailable until I restart Theengs on Pi A. I suspect a configuration problem but I’m not sure what to change, it’s all just the defaults that I got when running with discovery flag. Please can someone help?

{
    "adapter": "",
    "ble_scan_time": 5,
    "ble_time_between_scans": 5,
    "discovery": 1,
    "discovery_device_name": "TheengsGateway",
    "discovery_filter": [
        "IBEACON",
        "GAEN",
        "MS-CDP"
    ],
    "discovery_topic": "homeassistant/sensor",
    "host": "192.168.178.45",
    "log_level": "WARNING",
    "pass": "pass",
    "port": 1883,
    "publish_topic": "home/TheengsGateway/BTtoMQTT",
    "subscribe_topic": "home/TheengsGateway/+",
    "user": "user"
}

Good catch,
The issue seems Pi B is not retaining the discovery of entities and devices.
Let me analyze the code we may miss a retain flag when publishing

A fix is available below:

I restarted my broker and the message definition was kept by it.

New version v0.5.0:

What’s Changed

New devices and changes:

Devices Model Measurements
April Brother ABTemp uuid/mfid/major/txpower @ 1 m/temperature/battery
April Brother N03 temperature/humidity/luminance/battery
Qingping CGDN1 temperature/humidity/PM2.5/PM10/carbon dioxide
iBeacon protocol uuid/mfid/major/minor/txpower @ 1 m/voltage
Thermobeacon WS02 temperature/humidity/voltage/timestamp/maximum temperature/maximum temperature timestamp/minimum temperature/minimum temperature timestamp
Thermobeacon WS08 temperature/humidity/voltage/timestamp/maximum temperature/maximum temperature timestamp/minimum temperature/minimum temperature timestamp

Full Changelog: v0.4.0…v0.5.0

1 Like

Hello @1technophile , et al.

Long time reader, first time poster.

I’ve just purchased a BLE enabled smart lock model Eqiva eQ-3 and i’ve been able to get some info while using theengsgw running in stand alone mode.

I have home assistant core install on a RPi4, with mosquitto (which is working fine with zigbee2mqtt)

Running theengsgw with

python3 -m TheengsGateway -H localhost -P 1883 -u mqttuser -p mqttpasswd -ll DEBUG -a hci0 -pt "home/keylock/frontdoor" --publish_all 1 --discovery 1 --discovery_name frontlock

I have the following output:

INFO:BLEGateway:Sent `{"manufacturerdata": "001a2218a65c", "name": "KEY-BLE", "id": "00:11:22:33:44:55", "rssi": 0}` to topic `home/keylock/frontdoor/001122334455`
DEBUG:BLEGateway:00:11:22:33:44:55 RSSI:-68 AdvertisementData(local_name='KEY-BLE', manufacturer_data={6656: b'"\x18\xa6\\'}, service_uuids=['777fe34e-afcc-4d47-851d-8bcbf30f7a9b'])

I can see theengsgw connecting to mosquitto

1664833956: New connection from 127.0.0.1:37895 on port 1883.
1664833956: New client connected from 127.0.0.1:37895 as auto-A1563A7A-9F42-A02C-04F9-8646F29876A3 (p2, c1, k60, u'mqttuser').

But then i get no new devices on the mqtt integration.
I am able to subscribe topic “home/keylock/frontdoor/001122334455” on the mqtt integration settings page, which then outputs

{
    "manufacturerdata": "001a2218a65c",
    "name": "KEY-BLE",
    "id": "00:1A:22:18:A6:5C",
    "rssi": -67
}

So, i believe i’m getting the signal strength, and something is working.

Some additional info about this KET-BLE device and BLE support can be found here GitHub - lumokitho/esp32-keyble: ESP32 port of the keyble library, which is what i first had in mind (use an ESP32 as gateway), but then i thought about using the already existing RPi4.

What i would like to be able to to, for starters:

Be able to publish a payload so that i could lock/unlock/etc the keylock.

Would love to be able to have your add-on available as a custom_component, since core install does not support HA Addons.

Any pointers would be greatly appreciated!

… and great job with this integration! :slight_smile:

Hugo.

Hello Hugo,

Thanks for the information, currently this lock is not supported by the gateway, but that’s an interesting device. We can try to add it , the first step would be to identify the lock and decode its state, to do so I encourage you to open a topic below:

Once added to the decoder the valve data could be available into OpenMQTTGateway, Theengs gateway and the app.
It will be the first step implementing the control of it.