Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working anymore #99

Open
lennvilardi opened this issue Feb 12, 2023 · 19 comments
Open

Not working anymore #99

lennvilardi opened this issue Feb 12, 2023 · 19 comments

Comments

@lennvilardi
Copy link

lennvilardi commented Feb 12, 2023

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

@koenvervloesem
Copy link
Member

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

@lennvilardi
Copy link
Author

lennvilardi commented Feb 12, 2023

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.

@koenvervloesem
Copy link
Member

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

@lennvilardi
Copy link
Author

lennvilardi commented Feb 12, 2023

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

@koenvervloesem
Copy link
Member

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.

@lennvilardi
Copy link
Author

lennvilardi commented Feb 12, 2023

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

@koenvervloesem
Copy link
Member

koenvervloesem commented Feb 12, 2023

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",

@lennvilardi
Copy link
Author

lennvilardi commented Feb 12, 2023

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

@koenvervloesem
Copy link
Member

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.

@lennvilardi
Copy link
Author

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.

@koenvervloesem
Copy link
Member

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.

@lennvilardi
Copy link
Author

lennvilardi commented Feb 14, 2023

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.

@koenvervloesem
Copy link
Member

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

Environment="BLEAK_LOGGING=1"

@lennvilardi
Copy link
Author

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
Copy link
Author

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']]

@koenvervloesem
Copy link
Member

koenvervloesem commented Feb 18, 2023

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?

@lennvilardi
Copy link
Author

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 ?

@koenvervloesem
Copy link
Member

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.

@Snuupy
Copy link

Snuupy commented Oct 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants