gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Not working anymore

Open lennvilardi opened this issue 2 years ago • 19 comments

Describe the bug Status is offline in mqtt explorer, no more values are sent

To Reproduce Don't know where to start it's suddenly stopped, I've restarted my broker but I get message from my tasmota devices, I've rebooted HA.

Screenshots From the mqtt view of HA Capture d’écran 2023-02-12 à 18 50 05 From MQTT Explorer Capture d’écran 2023-02-12 à 18 49 08

Environment (please complete the following information): All 3 environnements are with a Sena UD100-G03 bluetooth dongle, all are well detected in hci0. -1 raspberry pi 2 -1 VM with debian 11 -1 raspberry pi 4 with debian 11 They all have the same configuration file theengsgw.conf :

{ "adapter": "hci0", "ble_scan_time": 1000, "ble_time_between_scans": 100, "discovery": 1, "discovery_device_name": "TheengsGateway", "discovery_filter": [ "IBEACON", "GAEN", "MS-CDP" ], "discovery_topic": "homeassistant/sensor", "hass_discovery": 0, "host": "192.168.0.203", "log_level": "WARNING", "pass": "password", "port": 1883, "publish_topic": "home/TheengsGateway", "scanning_mode": "active", "subscribe_topic": "home/+/BTtoMQTT/undecoded", "time_format": 0, "time_sync": [], "user": "mqtt-broker" }

All 3 gateways are started via a service Capture d’écran 2023-02-12 à 19 00 30

With nrf connect I see the devices so it's not a battery problem.

I've tried with only one antenna and only one TheengsGateway service still no value. I will gladly accept any help

lennvilardi avatar Feb 12 '23 18:02 lennvilardi

Do you see something odd in the logs with journalctl -u TheengsGateway? Maybe change the log level to INFO first to see more.

koenvervloesem avatar Feb 12 '23 18:02 koenvervloesem

Nothing odd. I've changed the log and that's the first results : févr. 12 19:59:33 raspberrypi python3[13798]: INFO:BLEGateway:Starting BLE scan févr. 12 19:59:33 raspberrypi python3[13798]: INFO:BLEGateway:Connected to MQTT Broker! févr. 12 19:59:33 raspberrypi python3[13798]: INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded Same on the 3 logs.

lennvilardi avatar Feb 12 '23 19:02 lennvilardi

And what did you change between the working and not working state? Update Theengs Gateway? Update the operating system?

koenvervloesem avatar Feb 12 '23 19:02 koenvervloesem

I really don't know... the 3 devices were installed this week-end so they were with the latest updates of the OS and the gateway. In the BLEA plugin for Jeedom, to avoid multiconnection to the same device, I was able to choose the antenna... maybe my Mi Flower doesn't like multiconnection or overlapping bluetooth. I have one antenna per floor. One payload went trought : Capture d’écran 2023-02-12 à 20 24 28

lennvilardi avatar Feb 12 '23 19:02 lennvilardi

One payload went trought :

Wait, so it does work? Did something else change so the BLE receivers are less receptive maybe? Antenna orientation, obstacles between the antenna and Mi Flora devices? Theengs Gateway doesn't connect to the Mi Floras, so that shouldn't be a difference, they just broadcast their data around so any device can receive it.

koenvervloesem avatar Feb 12 '23 19:02 koenvervloesem

No obstacle my plant in my living room is at 2 meters of the antenna in clear view Capture d’écran 2023-02-12 à 21 01 15 And the Mi Flower is broadcasting see : IMG_B620D6B9DB3F-1

lennvilardi avatar Feb 12 '23 20:02 lennvilardi

Now that I'm looking at your theengsgw.conf file, this looks odd:

 "ble_time_between_scans": 100,

This means that your gateway is waiting for 100 seconds between every scan. I would drastically reduce this. The default value is 5 seconds.

Note that for the publish topic, we're using by default:

"publish_topic": "home/TheengsGateway/BTtoMQTT",

koenvervloesem avatar Feb 12 '23 20:02 koenvervloesem

Here's my new conf file :

{ "adapter": "hci0", "ble_scan_time": 5, "ble_time_between_scans": 5, "discovery": 1, "discovery_device_name": "TheengsGatewaySalon", "discovery_filter": [ "IBEACON", "GAEN", "MS-CDP" ], "discovery_topic": "homeassistant/sensor", "hass_discovery": 1, "host": "192.168.0.203", "log_level": "INFO", "pass": "password", "port": 1883, "publish_topic": "home/TheengsGateway/BTtoMQTT", "scanning_mode": "active", "subscribe_topic": "home/+/BTtoMQTT/undecoded", "time_format": 0, "time_sync": [], "user": "mqtt-broker" } I've restarted MQTT Broker and working with only one antenna the nearest my plant and the data are not populated in the broker

lennvilardi avatar Feb 12 '23 21:02 lennvilardi

Have you disconnected the app from the Mi Flora before using Theengs Gateway? Because as long as the app is connected to the device, the latter doesn't advertise, so Theengs Gateway can't detect its measurements.

koenvervloesem avatar Feb 13 '23 06:02 koenvervloesem

The app have been disconnected. It's seem is a bluetooth issue, how do I verify that the bluetooth is still scanning ? After a reboot the TheengsGateway work for a few hours.

lennvilardi avatar Feb 13 '23 20:02 lennvilardi

Maybe try setting the environment variable BLEAK_LOGGING to 1 to see what the underlying Bluetooth library is doing. You can do that in your systemd service unit file with the Environment key.

koenvervloesem avatar Feb 14 '23 07:02 koenvervloesem

I don't find a bleak.service to edit with an environnment variable. Do you mean I have to edit bluetooth.service ? At some time the bluetooth stop scanning. Try to power of - power on - scan on via bluetoothctl not working I have to restart the bluetooth service to get it working again but for a few hours... From HA : The Bluetooth adapter must be accessible to D-Bus and running BlueZ >= 5.43. It is highly recommended to use BlueZ >= 5.63 as older versions have been reported to be unreliable. The host system should be running Linux kernel 5.15.62 or later. I'm using 5.55-3.1 with a kernel 5.15.32, hard to get all the requirements.

lennvilardi avatar Feb 14 '23 15:02 lennvilardi

No I meant in your /etc/systemd/system/TheengsGateway.service. Just add in this file:

Environment="BLEAK_LOGGING=1"

koenvervloesem avatar Feb 14 '23 16:02 koenvervloesem

Thanks @koenvervloesem I have compiled Bluez 5.66 but it still failed after 2 days :( now I have added the environment to TheengsGateway.service. I'll be back in a few days with the result.

lennvilardi avatar Feb 17 '23 16:02 lennvilardi

last entries in the log with the environnment enabled :

févr. 17 18:39:40 retropie python3[17769]: 2023-02-17 18:39:40,888 bleak.backends.bluezdbus.manager DEBUG: received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_90_DD_5D_AA_C0_77', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
févr. 17 18:39:40 retropie python3[17769]: DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_90_DD_5D_AA_C0_77', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]

lennvilardi avatar Feb 18 '23 09:02 lennvilardi

~It seems like your Bluetooth adapter suddenly disconnects, right?~ It seems like this is just the last time it finds a device and then it doesn't see anything anymore, strange.

If you run bluetoothctl and then the command scan on and let it run, does scanning also stop after a time?

koenvervloesem avatar Feb 18 '23 09:02 koenvervloesem

scan on stop finding new devices too, power off / power on / scan on doesn't work, only a restart of the bluetooth service works, how I can find why it stopped ?

lennvilardi avatar Feb 19 '23 22:02 lennvilardi

I don't know, this looks like a problem with Bluetooth on your device then, not a problem specific to Theengs Gateway. Do you see something suspicious in the output of dmesg? Or maybe you can try another Bluetooth adapter.

koenvervloesem avatar Feb 20 '23 07:02 koenvervloesem

I ran into the same with debian12 but was working on rpiOS 12 so if anyone is having issues with debian on rpi try rpiOS.

Snuupy avatar Oct 17 '23 13:10 Snuupy