Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Moderator: leecollings
-
- Posts: 1
- Joined: Wednesday 19 February 2020 16:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: CH
- Contact:
Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Hi Everybody,
i have four Xiaomi Mi Temperature and Humidity Sensors (lLYWSDCGQ/01ZM https://www.aliexpress.com/i/32849595532.html) and i'm searching for a way to integrate them into domoticz. I found a library with examplescript to poll them directly from the raspi without gateway (https://zsiti.eu/xiaomi-mijia-hygrother ... pberry-pi/). Is there a way to parse the output directly into domoticz as sensor?
thanx for any help in advance
Regards
i have four Xiaomi Mi Temperature and Humidity Sensors (lLYWSDCGQ/01ZM https://www.aliexpress.com/i/32849595532.html) and i'm searching for a way to integrate them into domoticz. I found a library with examplescript to poll them directly from the raspi without gateway (https://zsiti.eu/xiaomi-mijia-hygrother ... pberry-pi/). Is there a way to parse the output directly into domoticz as sensor?
thanx for any help in advance
Regards
-
- Posts: 21
- Joined: Thursday 22 October 2015 19:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: bèta
- Location: Netherlands
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Here you can find a script and a manual for use with Domoticz.
https://github.com/pFenners/mijia-sensor-domoticz
Use to find the sensor and note the MAC address of the device.
After downloading the code from GitHub, you must make 3 changes to the file
And line 25 you must change the word: into
At the end of the script there are 3 examples of the function update.
Eg.
Remove the # of one of the functions and replace the MAC address with the one you noted.
The number after the comma, "120" is the IDX of the sensor in Domoticz.
To test it you can now run the command:
https://github.com/pFenners/mijia-sensor-domoticz
Use
Code: Select all
sudo hcitool lescan
After downloading the code from GitHub, you must make 3 changes to the file
At the first line type:domoticz_mijia.py
Code: Select all
#! /usr/bin/python3
Code: Select all
base64.encodestring
Code: Select all
base64.encodebytes
Eg.
Code: Select all
update("58:2D:34:39:18:66","120")
The number after the comma, "120" is the IDX of the sensor in Domoticz.
To test it you can now run the command:
Code: Select all
./domoticz_mijia.py
Last edited by Mike70 on Thursday 09 April 2020 21:08, edited 1 time in total.
- Hesitated
- Posts: 42
- Joined: Monday 04 June 2018 21:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.11665
- Location: Ede
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Where do i find this file? It's not in the repository...
Domoticz 2020.2 - RPi3B+ - RFXtrx433XL - P1 - CC2531 - Somfy - Xiaomi - Hue - Omron - MQTT
-
- Posts: 21
- Joined: Thursday 22 October 2015 19:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: bèta
- Location: Netherlands
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Sorry.
I used the wrong github address.
You should use this one: https://github.com/pFenners/mijia-sensor-domoticz
I used the wrong github address.
You should use this one: https://github.com/pFenners/mijia-sensor-domoticz
- Hesitated
- Posts: 42
- Joined: Monday 04 June 2018 21:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.11665
- Location: Ede
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Minor detail...
First upgrade to Buster this weekend, then I'll look into it.
Thanks!
First upgrade to Buster this weekend, then I'll look into it.
Thanks!
Domoticz 2020.2 - RPi3B+ - RFXtrx433XL - P1 - CC2531 - Somfy - Xiaomi - Hue - Omron - MQTT
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
how does this work? using a esp32 of some kind with bluetooth? i could not find which device to use for bluetooth connection. i do not want to use the bluetooth on my pi since it does not cover the whole house. with multiple esp32 it would be possible but it is not listed how to do that.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
-
- Posts: 21
- Joined: Thursday 22 October 2015 19:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: bèta
- Location: Netherlands
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
I noticed that 1 Rpi does not receive all the units in our house. You could use an ESP32 on each floor.
I have a Rpi on each floor. That is a choice you can make.
For use with an ESP32, see this video: https://www.youtube.com/watch?v=RtJpx8BZvMw
I have a Rpi on each floor. That is a choice you can make.
For use with an ESP32, see this video: https://www.youtube.com/watch?v=RtJpx8BZvMw
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
I adjusted the script as per instructions.
When I run the script I get:
Traceback (most recent call last):
File "./domoticz_mijia.py", line 5, in <module>
from mijia.mijia_poller import MijiaPoller, \
ModuleNotFoundError: No module named 'mijia'
I also installed the script mija_poller, made it executable and added python3 to it.
Any ideas?
When I run the script I get:
Traceback (most recent call last):
File "./domoticz_mijia.py", line 5, in <module>
from mijia.mijia_poller import MijiaPoller, \
ModuleNotFoundError: No module named 'mijia'
I also installed the script mija_poller, made it executable and added python3 to it.
Any ideas?
-
- Posts: 31
- Joined: Wednesday 31 August 2016 11:17
- Target OS: OS X
- Domoticz version:
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Hi All, could anyone solve tis?
I am also stuck after following the instructions above:
Traceback (most recent call last):
File "domoticz_mijia.py", line 5, in <module>
from mijia.mijia_poller import MijiaPoller, \
ModuleNotFoundError: No module named 'mijia'
Any help?
I am also stuck after following the instructions above:
Traceback (most recent call last):
File "domoticz_mijia.py", line 5, in <module>
from mijia.mijia_poller import MijiaPoller, \
ModuleNotFoundError: No module named 'mijia'
Any help?
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Perhaps easier to use a Python plugin like viewtopic.php?f=65&t=22281
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 31
- Joined: Wednesday 31 August 2016 11:17
- Target OS: OS X
- Domoticz version:
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
In case some of you are interested, here the solution for the Mijia V2 (
https://github.com/erdose/xiaomi-mi-lywsd03mmc
model LYWSD03MMC
I am getting sometimes an error "Failed to connect to peripheral", but it works from time to time and I can see the data in my domoticz
https://github.com/erdose/xiaomi-mi-lywsd03mmc
model LYWSD03MMC
I am getting sometimes an error "Failed to connect to peripheral", but it works from time to time and I can see the data in my domoticz
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Hey, thanks for that!
Getting somewhat further now.
Just like you I get the occasional "Failed to connect", but also " Bluetooth command failed (code: 1, error: Invalid handle)".
And when it is working, I don't see the "INFO The request is http://192.168.178.23:8080/json.htm?typ ... battery=74" line in my log file.
No data appearing in Domoticz.
When I use curl to post the data myself, I see it appear in Domoticz, so the error seems to be on the side of the script, not on the Domoticz side.
menno@quokka:~$ curl 'http://192.168.178.23:8080/json.htm?typ ... battery=74'
{
"status" : "OK",
"title" : "Update Device"
}
Getting somewhat further now.
Just like you I get the occasional "Failed to connect", but also " Bluetooth command failed (code: 1, error: Invalid handle)".
And when it is working, I don't see the "INFO The request is http://192.168.178.23:8080/json.htm?typ ... battery=74" line in my log file.
No data appearing in Domoticz.
When I use curl to post the data myself, I see it appear in Domoticz, so the error seems to be on the side of the script, not on the Domoticz side.
menno@quokka:~$ curl 'http://192.168.178.23:8080/json.htm?typ ... battery=74'
{
"status" : "OK",
"title" : "Update Device"
}
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
That's for the Flower Mate, I don't think it works for these devices.waltervl wrote: ↑Tuesday 10 August 2021 17:27 Perhaps easier to use a Python plugin like viewtopic.php?f=65&t=22281
I also own a Flower Mate and the scripts works for it, but does not pick up my three Xiaomi Temperature and Humidity Sensors.
Meanwhile, back to getting the module not found error.
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
For Python module load errors check the last paragraph of the wiki https://www.domoticz.com/wiki/Using_Python_plugins
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 4
- Joined: Sunday 27 February 2022 20:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Hungary
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Hi Menno,Menno wrote: ↑Saturday 09 October 2021 15:28 Hey, thanks for that!
Getting somewhat further now.
Just like you I get the occasional "Failed to connect", but also " Bluetooth command failed (code: 1, error: Invalid handle)".
And when it is working, I don't see the "INFO The request is http:// 192 .168 .178 .23:8080/json .htm?type=command¶m=udevice&idx=1053&nvalue=0&svalue=28 .72;66;1&battery=74" line in my log file.
No data appearing in Domoticz.
When I use curl to post the data myself, I see it appear in Domoticz, so the error seems to be on the side of the script, not on the Domoticz side.
menno@quokka:~$ curl 'http:// 192 .168 .178 .23 :8080/json .htm?type=command¶m=udevice&idx=1053&nvalue=0&svalue=20;66;1&battery=74'
{
"status" : "OK",
"title" : "Update Device"
}
Can I ask you to come over to the thread of the Temp & Hum Sensor 2, and give me some hints to move forward making it working for me, please?
For me the script is not even getting to this part, only prints the following lines:
Code: Select all
2023-08-06 17:20:02 INFO ***************************************
2023-08-06 17:20:02 INFO Start script...
2023-08-06 17:20:02 INFO Input parameters:
Domoticz Server IP: 127 .0 .0 .1
Domoticz Server Port: 8080
Domoticz Server User: <myuserhere>
Domoticz Server Password: <mypasshere>
-
- Posts: 4
- Joined: Sunday 27 February 2022 20:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Hungary
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
I started to play with the script, and eventually changing the scanner.scan first param from 10 to 15 made it work:Lacman wrote: ↑Sunday 06 August 2023 17:22Hi Menno,Menno wrote: ↑Saturday 09 October 2021 15:28 Hey, thanks for that!
Getting somewhat further now.
Just like you I get the occasional "Failed to connect", but also " Bluetooth command failed (code: 1, error: Invalid handle)".
And when it is working, I don't see the "INFO The request is http:// 192 .168 .178 .23:8080/json .htm?type=command¶m=udevice&idx=1053&nvalue=0&svalue=28 .72;66;1&battery=74" line in my log file.
No data appearing in Domoticz.
When I use curl to post the data myself, I see it appear in Domoticz, so the error seems to be on the side of the script, not on the Domoticz side.
menno@quokka:~$ curl 'http:// 192 .168 .178 .23 :8080/json .htm?type=command¶m=udevice&idx=1053&nvalue=0&svalue=20;66;1&battery=74'
{
"status" : "OK",
"title" : "Update Device"
}
Can I ask you to come over to the thread of the Temp & Hum Sensor 2, and give me some hints to move forward making it working for me, please?
For me the script is not even getting to this part, only prints the following lines:I'd appreciate your, or anyone's help.Code: Select all
2023-08-06 17:20:02 INFO *************************************** 2023-08-06 17:20:02 INFO Start script... 2023-08-06 17:20:02 INFO Input parameters: Domoticz Server IP: 127 .0 .0 .1 Domoticz Server Port: 8080 Domoticz Server User: <myuserhere> Domoticz Server Password: <mypasshere>
Code: Select all
try:
scanner = Scanner().withDelegate(TempHumDelegate())
scanner.scan(15.0, passive=True)
except Exception as e:
logger.error(str(e))
pass
BR,
Lacman
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Nothing there at that link, but did you get it working?Lacman wrote: ↑Sunday 13 August 2023 21:10
Can I ask you to come over to the thread of the Temp & Hum Sensor 2,
BR,
Lacman
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
The script no longer works.
I get 401 errors, despite having allowed basic-auth and having the proper IP-ranges as trusted networks.
Anyone else experiencing this and more importantly, having it fixed?
I get 401 errors, despite having allowed basic-auth and having the proper IP-ranges as trusted networks.
Anyone else experiencing this and more importantly, having it fixed?
-
- Posts: 29
- Joined: Tuesday 08 October 2019 12:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Enschede (NL)
- Contact:
Re: Python Script or plugin for Xiaomi Mi Temp and Humidity Sensor
Yup, i'm also having troubles..... also with this plugin... viewtopic.php?t=34348
https://github.com/erdose/xiaomi-mi-lywsd03mmc
It's since the domoticz update 2023.2
https://github.com/erdose/xiaomi-mi-lywsd03mmc
It's since the domoticz update 2023.2
Who is online
Users browsing this forum: Bing [Bot] and 1 guest