Xiaomi BLE temperature & humidity sensor
Moderator: leecollings
-
- Posts: 6
- Joined: Saturday 27 January 2018 16:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Xiaomi BLE temperature & humidity sensor
Hi guys!
Just started using Domoticz and trying to make my home a bit smarter
That´s why a bought a couple of Xiaomi´s new cheap temperature and humidity sensors that transfer data via BLE (see http://cleargrass.com/). As a newbie it took me about half a day setting up a python script reading temperature, humidity and battery values from sensor and pass it to Domoticz via JSON URL (if someone else needs it, how can I make it public?). So far so good. I set up a dummy hardware in Domoticz and added my sensors as devices of type "Temp + Humidity". In the devices view I can see data is populated correctly, diagramms are showing history - great!
However when I switch to the temperature section in domoticz, I only see the sensors, but no data directly on those widgets (see attached image).
Am I doing something wrong?
Also I marked them as favorites as you can see when looking at the stars but I can´t see them in the dashboard overview
Thanks for helping!!
BR,
Alex
Just started using Domoticz and trying to make my home a bit smarter
That´s why a bought a couple of Xiaomi´s new cheap temperature and humidity sensors that transfer data via BLE (see http://cleargrass.com/). As a newbie it took me about half a day setting up a python script reading temperature, humidity and battery values from sensor and pass it to Domoticz via JSON URL (if someone else needs it, how can I make it public?). So far so good. I set up a dummy hardware in Domoticz and added my sensors as devices of type "Temp + Humidity". In the devices view I can see data is populated correctly, diagramms are showing history - great!
However when I switch to the temperature section in domoticz, I only see the sensors, but no data directly on those widgets (see attached image).
Am I doing something wrong?
Also I marked them as favorites as you can see when looking at the stars but I can´t see them in the dashboard overview
Thanks for helping!!
BR,
Alex
- Attachments
-
- sensors temperature section
- sensors.png (52.07 KiB) Viewed 12125 times
-
- Posts: 6
- Joined: Saturday 27 January 2018 16:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Decided to publish code on GitHub: https://github.com/fr31b3u73r/miThermoHygro
Feel free to test and give me feedback!
Update: Issue is fixed in newest version of script (missed stripping out non Ascii value from received package) - thanks to @PaulFen for pointing it out here: viewtopic.php?f=56&t=20925
Feel free to test and give me feedback!
Update: Issue is fixed in newest version of script (missed stripping out non Ascii value from received package) - thanks to @PaulFen for pointing it out here: viewtopic.php?f=56&t=20925
-
- Posts: 14
- Joined: Monday 20 November 2017 15:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: Balkans
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Cool man! Tnx for script! I am still waiting for it's price to come down and buy one or 2 of em. Still more affordable to use Xiaomi zigbee thermo/hydro meters (8-9$ each) and easier to use with zigbee GW (tho which is 26$) straight to domoticz oob. But that BLE one looks cool too
can you pair it with mi home app and BLE on Raspi at same time? Does it allows multiple pairings?
cheers!
can you pair it with mi home app and BLE on Raspi at same time? Does it allows multiple pairings?
cheers!
Pi 2 (raspbian stretch) w. Conrad VOC USB, Xiaomi PM 2.5 detector , Xiaomi/Philips bulbs, Mi Flora BT, Xiaomi GW (w. temp/humidity/pir)
Pi Zero W (raspbian stretch) w. - Xiaomi GW (temp/hum/door)
Pi Zero W (raspbian stretch) w. - Xiaomi GW (temp/hum/door)
-
- Posts: 33
- Joined: Wednesday 23 December 2015 11:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Hi freibeuterfreibeuter wrote: ↑Sunday 28 January 2018 10:20 Decided to publish code on GitHub: https://github.com/fr31b3u73r/miThermoHygro
Feel free to test and give me feedback!
Update: Issue is fixed in newest version of script (missed stripping out non Ascii value from received package) - thanks to @PaulFen for pointing it out here: viewtopic.php?f=56&t=20925
Your script works perfectly but unfortunately I am only able to get the data from the device when the device is in paring mode. So basically I need to press and hold the paring button at the back of the device everytime otherwise I won't get the data readout. Do you know what's the issue here.
My raspberry Pi is still on Wheezy and may be that's the problem
thanks
-
- Posts: 168
- Joined: Monday 22 June 2015 10:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Hi,
Got your script to work.
The range of BT is surprisingly far, so I'm able to use these sensors anywhere.
Sensors now are pretty cheap (< 9€ at Joybuy).
Where does the battery information go within Domoticz?
Also my experience getting it to work:
- Took me a while to discover I needed Python 2. Why not add "#!/usr/bin/env python2" at the top of the script?
- I needed to install requests and bluepy, bluepy would only install after installing libglib2.0-dev.
After that it immediately worked!
I would also suggest to name the script like 'miThermoHygro.py' so we can store it in ~/Domoticz/scripts/python.
Thanks!
Got your script to work.
The range of BT is surprisingly far, so I'm able to use these sensors anywhere.
Sensors now are pretty cheap (< 9€ at Joybuy).
Where does the battery information go within Domoticz?
Also my experience getting it to work:
- Took me a while to discover I needed Python 2. Why not add "#!/usr/bin/env python2" at the top of the script?
- I needed to install requests and bluepy, bluepy would only install after installing libglib2.0-dev.
After that it immediately worked!
I would also suggest to name the script like 'miThermoHygro.py' so we can store it in ~/Domoticz/scripts/python.
Thanks!
-
- Posts: 6
- Joined: Saturday 27 January 2018 16:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Thanks - added the shebang
Done
It's an additional param for the Domoticz API (see https://www.domoticz.com/wiki/Domoticz_ ... y_level.29) - I am not that familiar with Domoticz yet, but you can see it e.g. in the App by pressing long on the device.
-
- Posts: 38
- Joined: Thursday 07 June 2018 22:23
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Sud de France
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Hi freubeuter!
I have several temp/hum sensors (old round LCD MJ_HT_V1, new angular LYWSD03MMC, zigbee without display) and a couple of those e-ink GlearGrass devices you have written a script. Those who commented here said that the script worked pretty easily but I have a problem.
My Domoticz runs on an Intel NUC DE3815TYKH with Mint 19. I had to install bluepy, requests, setuptools etc for Python2, no problems with them. But the script doesn't simply run at all. After running it, it hangs and stays like this forever. I tried to step through it with pdb and the line it stops is handle_temp_hum_value(), I don't know is this any worth of info or not, I am not a coder, though.
Can you assist me a little with your script? How could I see what it does on a certain moment, how could I debug it or print on console some results (URL, etc) to see what's wrong?
Thanks in advance!
I have several temp/hum sensors (old round LCD MJ_HT_V1, new angular LYWSD03MMC, zigbee without display) and a couple of those e-ink GlearGrass devices you have written a script. Those who commented here said that the script worked pretty easily but I have a problem.
My Domoticz runs on an Intel NUC DE3815TYKH with Mint 19. I had to install bluepy, requests, setuptools etc for Python2, no problems with them. But the script doesn't simply run at all. After running it, it hangs and stays like this forever. I tried to step through it with pdb and the line it stops is handle_temp_hum_value(), I don't know is this any worth of info or not, I am not a coder, though.
Can you assist me a little with your script? How could I see what it does on a certain moment, how could I debug it or print on console some results (URL, etc) to see what's wrong?
Thanks in advance!
-
- Posts: 8
- Joined: Thursday 06 February 2014 21:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Hi
I have problem with this script, see copy from log below.
2020-07-28 22:53:00.131 Error: EventSystem: Failed to execute python event script "BLE"
2020-07-28 22:53:00.131 Error: EventSystem: Traceback (most recent call last):
2020-07-28 22:53:00.131 Error: EventSystem: File "<string>", line 4, in <module>
2020-07-28 22:53:00.131 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
any thaughts?
Domoticz running on RPI3
Regards Rickard
I have problem with this script, see copy from log below.
2020-07-28 22:53:00.131 Error: EventSystem: Failed to execute python event script "BLE"
2020-07-28 22:53:00.131 Error: EventSystem: Traceback (most recent call last):
2020-07-28 22:53:00.131 Error: EventSystem: File "<string>", line 4, in <module>
2020-07-28 22:53:00.131 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
any thaughts?
Domoticz running on RPI3
Regards Rickard
-
- Posts: 1
- Joined: Tuesday 09 March 2021 8:53
- Target OS: OS X
- Domoticz version:
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
its 2018 post still looks good enough
-
- Posts: 361
- Joined: Sunday 29 November 2015 21:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: UK
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Just tried to install this and getting the same error
2021-07-23 10:08:27.970 Error: EventSystem: Failed to execute python event script "BLE Sensor Reading"
2021-07-23 10:08:27.971 Error: EventSystem: Traceback (most recent call last):
2021-07-23 10:08:27.971 Error: EventSystem: File "<string>", line 4, in <module>
2021-07-23 10:08:27.971 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
Did anyone get this issue resolved, checked to make sure requests is present and it is, the version I have is 2.21.00 is this a newer version and so causing an issue ?
Any help would be appreciated as I know little to nothing about python
TIA
Dave
2021-07-23 10:08:27.970 Error: EventSystem: Failed to execute python event script "BLE Sensor Reading"
2021-07-23 10:08:27.971 Error: EventSystem: Traceback (most recent call last):
2021-07-23 10:08:27.971 Error: EventSystem: File "<string>", line 4, in <module>
2021-07-23 10:08:27.971 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
Did anyone get this issue resolved, checked to make sure requests is present and it is, the version I have is 2.21.00 is this a newer version and so causing an issue ?
Any help would be appreciated as I know little to nothing about python
TIA
Dave
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
In the github it saysDave21w wrote: ↑Friday 23 July 2021 11:11 Just tried to install this and getting the same error
2021-07-23 10:08:27.970 Error: EventSystem: Failed to execute python event script "BLE Sensor Reading"
2021-07-23 10:08:27.971 Error: EventSystem: Traceback (most recent call last):
2021-07-23 10:08:27.971 Error: EventSystem: File "<string>", line 4, in <module>
2021-07-23 10:08:27.971 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
Did anyone get this issue resolved, checked to make sure requests is present and it is, the version I have is 2.21.00 is this a newer version and so causing an issue ?
Any help would be appreciated as I know little to nothing about python
TIA
Dave
To be able to use it your device needs a bluetooth hardware that supports BLE, Python (2) as well as external libraries as defined in imports. Tested on Raspberry Pi 3.
So You need to install (or confirm that it is installed) the Python libraries:
binascii
base64
requests
Normally you install these with:
sudo pip3 "python module name"
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: 361
- Joined: Sunday 29 November 2015 21:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: UK
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Only just got back to looking at this, I still have this error:-
However when I try to install the "requests" module I am told the requirement is already satisfied for both python2 and 3.
Any ideas guys ?
However when I try to install the "requests" module I am told the requirement is already satisfied for both python2 and 3.
Any ideas guys ?
-
- Posts: 361
- Joined: Sunday 29 November 2015 21:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: UK
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
Still can't get this to work despite installing what believe are all rerquirements
Anybody else have any success ?
Anybody else have any success ?
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Xiaomi BLE temperature & humidity sensor
libraries have to be installed with the same user as the user running Domoticz else it cannot find it.
So if root is running Domoticz use 'sudo pip3' to install the libraries. else install with normal pip3
So if root is running Domoticz use 'sudo pip3' to install the libraries. else install with normal pip3
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
Who is online
Users browsing this forum: No registered users and 1 guest