Page 1 of 1

Yet another script to listen to Xiaomi thermometers with atc1441/pvvx firmware

Posted: Tuesday 27 February 2024 19:34
by mcesar
Hi all,

New here. Recently I started to migrate my Domoticz system from 433 MHz (with an RFLink gateway) to BLE+WiFi. In doing that, I used Xiaomi thermometers re-flashed to the pvvx firmware. Although there are some other scripts available to listen to them, I found them not exactly my taste, so wrote my own script.

Its main characteristics are:
  • Supports atc1441 and pvvx BLE advertisment protocols
  • Supports plain and encrypted BLE advertisment protocols
  • Passive scan (long battery life)
  • Supports Domoticz (http/https JSON API) and MQTT brokers. Also, Domoticz via MQTT
  • Supports encryption and authentication when communicating with Domoticz and MQTT brokers
  • A single python file
  • Full asynchronous IO (Python async/await, bleak, aiohttp, aiomqtt) giving low CPU and memory usage even with many thermometers and clients
  • Daemonizable, to be run as a service. No cron jobs, uses the system journald service to log
  • Configuration is written in a human-friendly YAML file
  • Tested on Debian Bullseye and Bookworm and Windows 10/11
If want to use and test, find it on github: https://github.com/mcesar-rlacruz/atc_pvvx_monitor.

Best regards.

Re: Yet another script to listen to Xiaomi thermometers with atc1441/pvvx firmware

Posted: Tuesday 27 February 2024 21:28
by waltervl
No experience myself but did you look at the OpenMQTTGateway project? As that supports also MQTT Auto Discover protocol Wich makes integration very simple.

Re: Yet another script to listen to Xiaomi thermometers with atc1441/pvvx firmware

Posted: Wednesday 28 February 2024 14:24
by mcesar
Hi,

Well, thanks. In fact it is not OpenMQTTGateway what I just tested, but the related https://gateway.theengs.io/. In less than an hour Domoticz is reporting temp/humid/battery for all sensors. There are some issues (there's no way to enable insecure TLS, no report for RSSI, incompatible versions for paho-mqtt with other apps in my system,…), but seems a really nice starting.

When decided to update from 433 MHz to BLE+WiFi studied various solutions. Surprisingly I didn't found OpenMQTTGateway .

Thanks again % regards.

Re: Yet another script to listen to Xiaomi thermometers with atc1441/pvvx firmware

Posted: Friday 01 March 2024 18:35
by mcesar
Hi again,

After some testing (and a successful pull-request to theengs/gateway to enable insecure TLS), I rolled back to my script. OK, the TheengsGateway works, but Tasmota devices do not support, from some time ago, the Home Assistant autodiscovery protocol, so I do not have any real benefit from using Theengs (my thermometers are yet "discovered", but my Tasmotas will not…).

Even more, the Theengs Gateway, when using autodiscovery, publishes values of temperature, humidity and battery to different topics, resulting in 3 different devices inside Domoticz for each thermometer. With my script I can configure that, and I do receive all temperature/humidity/battery/RSSI into a single Device (so even low battery notifications work out of the box).

My next project will be some "MQTT message processor" that receives MQTT messages published to/from Tasmota devices and «translates» them from/to Domoticz MQTT JSON API. Not sure if Node-RED can do that, but seems simple enough to be achieved with some Python dicts wizardry and regular expressions.

Regards.

Re: Yet another script to listen to Xiaomi thermometers with atc1441/pvvx firmware

Posted: Saturday 02 March 2024 14:00
by waltervl
There is also a Tasmota discovery script (branch of shellyteacher script) that discovers Tasmota devices and transforms them into MQTT Auto discover.
But probably not the flexibility of your own project.