Hi,
Yes, you can do this without using a gateway. Since your Raspberry Pi script is already reading the data from the sensors, the main thing you need is to send that data into Domoticz.
Domoticz has a JSON API that allows you to update sensor values. So what you can do is take the temperature and humidity output from your script and pass it to Domoticz using a simple HTTP request. For that, you first create a dummy temperature and humidity sensor in Domoticz and note its IDX. Then in your script, after reading the values, you send them to Domoticz using the API URL with that IDX.
If you are using Python, you can send the request using something like requests. If it’s a bash script, curl will work fine. Once set up, it will update automatically whenever your script runs.
Your current approach is already on the right track, you just need this small step to connect it with Domoticz.
Kind regards
Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Moderator: leecollings
-
Menno
- Posts: 46
- Joined: Wednesday 24 July 2019 13:23
- Target OS: Linux
- Domoticz version: 2026.1
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
After wrangling ChatGPT and CoPilot for hours, it works again.
I made (well, let the agents make) two separate Python scripts (to avoid timing issues).
First scripts acquires sensor data, logs to file.
Second script sends logged values to Domoticz.
Both are called from a wrapper script in bash that is called from cron.
If anyone is interested, I can post all three here.
Edit: these scripts did not work reliably. They work with the sensors' passive Bluetooth advertisements, which can not reliably be decoded.
Instead I now have one script that makes an active connection and one wrapper to start it from cron.
(Also made a new script for the Xiaomi Miflora plant sensor)
Let me know if there is interest.
I made (well, let the agents make) two separate Python scripts (to avoid timing issues).
First scripts acquires sensor data, logs to file.
Second script sends logged values to Domoticz.
Both are called from a wrapper script in bash that is called from cron.
If anyone is interested, I can post all three here.
Edit: these scripts did not work reliably. They work with the sensors' passive Bluetooth advertisements, which can not reliably be decoded.
Instead I now have one script that makes an active connection and one wrapper to start it from cron.
(Also made a new script for the Xiaomi Miflora plant sensor)
Let me know if there is interest.