Page 1 of 1

Xiaomi BLE temperature & humidity sensor

Posted: Saturday 27 January 2018 18:09
by freibeuter
Hi guys!

Just started using Domoticz and trying to make my home a bit smarter 8-)
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

Re: Xiaomi BLE temperature & humidity sensor

Posted: Sunday 28 January 2018 11:20
by freibeuter
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

Re: Xiaomi BLE temperature & humidity sensor

Posted: Wednesday 07 February 2018 16:54
by Slokoavac
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!

Re: Xiaomi BLE temperature & humidity sensor

Posted: Sunday 11 March 2018 12:06
by Chakkie
freibeuter wrote:
Sunday 28 January 2018 11: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
Hi freibeuter

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

Re: Xiaomi BLE temperature & humidity sensor

Posted: Sunday 08 July 2018 14:59
by Hesmink
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!

Re: Xiaomi BLE temperature & humidity sensor

Posted: Monday 09 July 2018 9:34
by freibeuter
Hesmink wrote:
Sunday 08 July 2018 14:59
- Took me a while to discover I needed Python 2. Why not add "#!/usr/bin/env python2" at the top of the script?
Thanks - added the shebang
Hesmink wrote:
Sunday 08 July 2018 14:59
I would also suggest to name the script like 'miThermoHygro.py' so we can store it in ~/Domoticz/scripts/python.
Done ;)
Hesmink wrote:
Sunday 08 July 2018 14:59
Where does the battery information go within Domoticz?
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.