gateway
gateway copied to clipboard
Theengs Gateway does not find anymore Xiaomi Mijia sensors.
Hi,
at some undetermined time, after some system updates, the daemon has stopped detecting 2 Xiaomi Mijia sensors, which were working fine before.
The gateway is installed on a Proxomox VM, Debian 11, standard python 3, with a passthrough on the USB port, and "hcitool lescan" seems to work:
root@servizi:~# hcitool lescan
LE Scan ...
A4:C1:38:AF:6A:91 (unknown)
A4:C1:38:AF:6A:91 ATC_ES_CED
A4:C1:38:4C:A5:A6 (unknown)
A4:C1:38:4C:A5:A6 ES_CED02
Environment
# Theengs Gateway Diagnostics
## Package Versions
| Name | Value |
|--------------------|--------|
| Theengs Gateway | 1.0.0 |
| Theengs Decoder | 1.4.0 |
| Bleak | 0.20.2 |
| Bluetooth Clocks | 0.1.2 |
| Bluetooth Numbers | 1.1.0 |
| Paho MQTT | 1.6.1 |
| Bluetooth Adapters | 0.15.3 |
## Python
| Name | Value |
|----------------|---------------------|
| Version | 3.9.2 |
| Implementation | CPython |
| Compiler | GCC 10.2.1 20210110 |
| Executable | /usr/bin/python3 |
## Operating System
| Name | Value |
|--------------|---------------------------------------|
| System | Linux |
| Release | 5.10.0-21-amd64 |
| Version | #1 SMP Debian 5.10.162-1 (2023-01-21) |
| Machine type | x86_64 |
## Configuration
{
"adapter": "hci0",
"ble_scan_time": 5,
"ble_time_between_scans": 5,
"discovery": 1,
"discovery_device_name": "",
"discovery_filter": [],
"discovery_topic": "homeassistant/sensor",
"hass_discovery": 1,
"host": "172.16.0.31",
"log_level": "DEBUG",
"lwt_topic": "ced_roma",
"pass": "***",
"port": 1883,
"presence": 0,
"presence_topic": "ced_roma/presence",
"publish_advdata": 0,
"publish_all": 1,
"publish_topic": "ced_roma",
"scanning_mode": "passive",
"subscribe_topic": "ced_roma/undecoded",
"time_format": 0,
"time_sync": [],
"user": "***"
}
## Bluetooth adapters
Default adapter: hci0
### hci0
| Name | Value |
|--------------|---------------------|
| address | 00:1A:7D:XX:XX:XX |
| sw_version | servizi |
| hw_version | usb:v1D6Bp0246d0537 |
| passive_scan | False |
| manufacturer | cyber-blue(HK)Ltd |
| product | 0001 |
| vendor_id | 0a12 |
| product_id | 0001 |
Additional context Output of the command:
root@servizi:~# export BLEAK_LOGGING=1
root@servizi:~# python3 -m TheengsGateway -ll INFO
INFO:BLEGateway:Starting BLE scan
INFO:BLEGateway:Connected to MQTT Broker!
INFO:BLEGateway:Subscribed to ced_roma/undecoded
2023-04-20 16:43:07,248 bleak.backends.bluezdbus.manager Thread-1 DEBUG: initial properties: {'/org/bluez': {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.AgentManager1': {}, 'org.bluez.ProfileManager1': {}, 'org.bluez.HealthManager1': {}}, '/org/bluez/hci0': {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Adapter1': {'Address': '00:1A:7D:DA:71:15', 'AddressType': 'public', 'Name': 'servizi', 'Alias': 'servizi', 'Class': 0, 'Powered': True, 'Discoverable': False, 'DiscoverableTimeout': 180, 'Pairable': False, 'PairableTimeout': 0, 'Discovering': False, 'UUIDs': ['00001801-0000-1000-8000-00805f9b34fb', '00001800-0000-1000-8000-00805f9b34fb', '00001200-0000-1000-8000-00805f9b34fb', '0000110c-0000-1000-8000-00805f9b34fb', '0000110e-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb'], 'Modalias': 'usb:v1D6Bp0246d0537', 'Roles': ['central', 'peripheral']}, 'org.freedesktop.DBus.Properties': {}, 'org.bluez.GattManager1': {}, 'org.bluez.LEAdvertisingManager1': {'ActiveInstances': 0, 'SupportedInstances': 5, 'SupportedIncludes': ['tx-power', 'appearance', 'local-name']}, 'org.bluez.Media1': {}, 'org.bluez.NetworkServer1': {}}}
DEBUG:bleak.backends.bluezdbus.manager:initial properties: {'/org/bluez': {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.AgentManager1': {}, 'org.bluez.ProfileManager1': {}, 'org.bluez.HealthManager1': {}}, '/org/bluez/hci0': {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Adapter1': {'Address': '00:1A:7D:DA:71:15', 'AddressType': 'public', 'Name': 'servizi', 'Alias': 'servizi', 'Class': 0, 'Powered': True, 'Discoverable': False, 'DiscoverableTimeout': 180, 'Pairable': False, 'PairableTimeout': 0, 'Discovering': False, 'UUIDs': ['00001801-0000-1000-8000-00805f9b34fb', '00001800-0000-1000-8000-00805f9b34fb', '00001200-0000-1000-8000-00805f9b34fb', '0000110c-0000-1000-8000-00805f9b34fb', '0000110e-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb'], 'Modalias': 'usb:v1D6Bp0246d0537', 'Roles': ['central', 'peripheral']}, 'org.freedesktop.DBus.Properties': {}, 'org.bluez.GattManager1': {}, 'org.bluez.LEAdvertisingManager1': {'ActiveInstances': 0, 'SupportedInstances': 5, 'SupportedIncludes': ['tx-power', 'appearance', 'local-name']}, 'org.bluez.Media1': {}, 'org.bluez.NetworkServer1': {}}}
And there it get stuck.
How can I proceed?
You are reading the sensors every 5s. Probably the battery died. I had the same issue. I tried to set to passive mode. But my raspberry os does not allow this. For the moment I set the time to every 10min. But for the long term I will probably switch to another solution which reads the sensors passive.
You are reading the sensors every 5s. Probably the battery died.
That's not it!
Not only I have an alarm set when batteries go under 10%, but the two sensors work fine with another little python demon (which I think uses passive mode, but maybe different libraries): https://github.com/JsBergbau/MiTemperature2
The exact same thing is happening at home, on a RPi 3, which has a debian 11 derivative distribution, so maybe there is something wrong with the debian shipped default libraries...