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

Moderator: leecollings

Post Reply
mcesar
Posts: 3
Joined: Tuesday 27 February 2024 19:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
mcesar
Posts: 3
Joined: Tuesday 27 February 2024 19:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
mcesar
Posts: 3
Joined: Tuesday 27 February 2024 19:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest