Python plugin: Xiaomi Mi Flower Mate

Python and python framework

Moderator: leecollings

mgabor
Posts: 15
Joined: Friday 01 February 2019 7:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by mgabor »

Dear PatrickM,
I have same problem as you. I use MIJIA BLE Temp&Hum sensor and after a couple of hours there's a bluetooth error and this breaks the domoticz python plugin system. Do you have found any solution the problem?
Regards,
Gabor
tonbor
Posts: 153
Joined: Monday 17 February 2014 9:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by tonbor »

No, I use the script not the plugin, that works fine
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by krizzz »

For the ones where the script is working. What is your distantice between your Pi and your plant with the sensor?


Verzonden vanaf mijn iPhone met Tapatalk
tonbor
Posts: 153
Joined: Monday 17 February 2014 9:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by tonbor »

I got 13 mi flower, largest distance is 11 meters.
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by krizzz »

tonbor wrote:I got 13 mi flower, largest distance is 11 meters.
WoW! Nice! So the script is working for you?

Are there any wals beteren your pi and the mi flower?


Verzonden vanaf mijn iPhone met Tapatalk
tonbor
Posts: 153
Joined: Monday 17 February 2014 9:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by tonbor »

Yes 11 meter and two wals, one thin other big......
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by sincze »

1 wall... And nothing here :(

Sent from my ONEPLUS A6003 using Tapatalk

Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by krizzz »

sincze wrote:1 wall... And nothing here :(

Sent from my ONEPLUS A6003 using Tapatalk
I have got exactly the same.

@tonbor, which USB Bluetooth adapter are you using?



Verzonden vanaf mijn iPhone met Tapatalk
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by sincze »

krizzz wrote: Sunday 05 May 2019 7:01
sincze wrote:1 wall... And nothing here :(

Sent from my ONEPLUS A6003 using Tapatalk
I have got exactly the same.

@tonbor, which USB Bluetooth adapter are you using?



Verzonden vanaf mijn iPhone met Tapatalk
Good question I am using the internal one in a geekworn metal enclosure.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
tonbor
Posts: 153
Joined: Monday 17 February 2014 9:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by tonbor »

A got the original from the rasp 3B+ in a plastic enclosure, metal blocks the bluetooth signal to much and at my second rasp a external one hanging at an usb cable in the right place.
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by sincze »

Tnx. I have to go external. Now in metal enclosure indeed. Specific dongle??
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
tonbor
Posts: 153
Joined: Monday 17 February 2014 9:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by tonbor »

I bought a CSR 4.0, first I received a fake one so beware. A logilink 100 meter had a worse performance compered to the CSR 4.0.
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by sincze »

Found one (mini) in the box of spares :)
Now searching for extension cable. Fingers crossed.
Tnx.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
coen17st

Re: Python plugin: Xiaomi Mi Flower Mate

Post by coen17st »

Does this plugin works in Domoticz on Windows OS or only Raspbian?
dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by dheuts »

Really nice plugin, thanks a lot!
Unfortunately I can't get it up and running.
I get A "Poller error" on version v2020.1 on a Raspberry with Buster installed.

Didnt use the plugin before. Also Tried both Python updating commands as mentioned in the Readme, no difference.

Can someone please help me? Thanks a lot!

UPDATE: Before, I added the devices manually with their Mac addresses. After reinstalling and leaving the script plugin at Automatic, it only found one of them. I think the other one was out of range and caused the “poller error”.
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
User avatar
MadMedic
Posts: 31
Joined: Wednesday 26 October 2016 14:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Huizen, the Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by MadMedic »

Hi guys,

Got all of the Xiaomi mi flower sensors (international version), 5 of them, working perfectly for a month now, with a Rpi 3B with the internal BLE chip.
Once in a while a poller error with the last of the 5 sensors. Only twice a week or so,

But, the problem I have now is the very poor lifetime of the CR 2032 batteries.
The first set of batteries (that came with the sensors) only lasted for 3 weeks.
The second set of batteries which I bought at Action (5 for € 1,49) lasted only 5 days ! 220mAh

Now I bought a third, i hope better, set of CR 2032 buttoncells batteries, 'Energizer' brand, which are 280 mAh (10 for € 19,- )
Going to put them in now and hope they will last a little bit longer.

But the question I have remains, since I'm only polling once a day at the most... how can it be that those batteries last so short ?
They supposed to have enough charge for at least half a year !

Anyone have an idea with can be the issue here ?

Just FYI..
  1. polling done only 1 times a day, via the timer of the manual switch,
  2. In the plugin settings the mac adresses were captured automaticly,
    now changed it into manually, to see if it will give a better result.
  3. mi flora python script is not being updated automaticly
  4. no entries in logs that sensors are being updated more then once a day
  5. distances between sensors and Rpi is 5 mtr at the most, through one thin wall, reception is mostly OK, except for a very few polling errors
  6. and lastly, no water in the sensors, all rubber sealings intact, all batteries and contacts are dry, so no short circuits
I'm totally puzzled. Hope someone can help me with this.


And this is how it looks in 'homehabit'
Spoiler: show
hh2.png
hh2.png (166.66 KiB) Viewed 1489 times
.
"Life is too short for bad coffee"
User avatar
MadMedic
Posts: 31
Joined: Wednesday 26 October 2016 14:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Huizen, the Netherlands
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by MadMedic »

No visionairy answers or insights ? hmm
.
"Life is too short for bad coffee"
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by lwolf »

MadMedic wrote: Wednesday 30 September 2020 13:50 But, the problem I have now is the very poor lifetime of the CR 2032 batteries.
The first set of batteries (that came with the sensors) only lasted for 3 weeks.
The second set of batteries which I bought at Action (5 for € 1,49) lasted only 5 days ! 220mAh
You can try to scan MiFlower sensors passively to see if it changes battery life.
RPIEasy "Environment - BLE Xiaomi sniffer" plugin supports them.
appelflap
Posts: 19
Joined: Friday 14 March 2014 22:12
Target OS: Linux
Domoticz version: beta
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by appelflap »

Passively scanning for BLE data is best option then. GATT takes a lot of battery life from the sensor

This is an awesome place to start if you want to write a python plugin: https://github.com/frawau/aioblescan
It's also being used by this plugin for homeassistant: https://github.com/custom-components/sensor.mitemp_bt

In bash you could use `hcitool -i hci0 lescan --duplicate` with `btmon` and process the incoming lines with a while loop and `read`. Filtering on Miflora like data with uuids 0xfe95.

Code: Select all

hcitool -i hci0 lescan --duplicate >/dev/null 2>&1 &

Code: Select all

while IFS= read -r line; do  <your-script-here> "$line" ; done < <(unbuffer btmon | grep "Service Data" | grep 0xfe95 2>&1)
The above script outputs something equal to this. You could parse it further or stash it in a logfile.

Code: Select all

Service Data (UUID 0xfe95): 712098002118506a8d7cc40d0910023f04
Service Data (UUID 0xfe95): 71209800ec85bf6a8d7cc40d071003f20000
Service Data (UUID 0xfe95): 712098002118506a8d7cc40d0910023f04
Service Data (UUID 0xfe95): 712098002218506a8d7cc40d041002de00
Service Data (UUID 0xfe95): 71209800ed85bf6a8d7cc40d08100164
Service Data (UUID 0xfe95): 712098002218506a8d7cc40d041002de00
Take the last row for example. This data (0x712098002218506a8d7cc40d041002de00) contains a prefix (0x71209800), msg counter (0x22), hw address (18506a8d7cc4 -> C4:7C:8D:6A:50:18) , 0x0d, and the actual part we want (0x041002de00).

This last part contains a data type, the 0x10 (i guess the number base: 16), the length of the data and the value of the sensor. For the four sensor types it could give:

Code: Select all

type  ?  length  data
04    10 02      c900    -> temperature in 0.1°C  0x00c9 = 201 (20.1°C) 
07    10 03      d24101  -> light in lux          0x0141d2 = 82386 lux  
08    10 01      38      -> moisture in %         0x38 = 56%            
09    10 02      7011    -> conductivity in µS/cm 0x0619 = 1561 µS/cm  
Parsing data from the first step gives:

Code: Select all

2020-11-05 12:49:46 - C4:7C:8D:6A:BF:85 [0x07] - 197 (0x0000C5) is light in lux
2020-11-05 12:49:52 - C4:7C:8D:6A:50:18 [0x04] - 22.1 (0x00DD) is temperature degrees C
2020-11-05 12:49:56 - C4:7C:8D:6A:BF:85 [0x08] - 100 (0x64) is moisture in %
2020-11-05 12:50:03 - C4:7C:8D:6A:BF:85 [0x09] - 4591 (0x11EF) conductivity in uS/cm
2020-11-05 12:50:04 - C4:7C:8D:6A:50:18 [0x07] - 645 (0x000285) is light in lux
2020-11-05 12:50:11 - C4:7C:8D:6A:50:18 [0x08] - 50 (0x32) is moisture in %
2020-11-05 12:50:16 - C4:7C:8D:6A:BF:85 [0x04] - 18.9 (0x00BD) is temperature degrees C
2020-11-05 12:50:23 - C4:7C:8D:6A:50:18 [0x09] - 1097 (0x0449) conductivity in uS/cm
2020-11-05 12:50:26 - C4:7C:8D:6A:BF:85 [0x07] - 257 (0x000101) is light in lux
2020-11-05 12:50:32 - C4:7C:8D:6A:50:18 [0x04] - 22.1 (0x00DD) is temperature degrees C
You could parse it to JSON and throw it at Domoticz. Implementation details depends on your setup.

Code: Select all

{"timestamp":"2020-11-05 12:59:37","hwaddr":"C4:7C:8D:6A:50:18","type":"moisture","cnt":"30","value":"50"}
{"timestamp":"2020-11-05 12:59:37","hwaddr":"C4:7C:8D:6A:BF:85","type":"temperature","cnt":"fb","value":"18.9"}
{"timestamp":"2020-11-05 12:59:37","hwaddr":"C4:7C:8D:6A:50:18","type":"conductivity","cnt":"31","value":"1087"}
{"timestamp":"2020-11-05 12:59:40","hwaddr":"C4:7C:8D:6A:BF:85","type":"luminocity","cnt":"fc","value":"230"}
Last edited by appelflap on Thursday 05 November 2020 21:23, edited 1 time in total.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by joostnl »

I don't wanna steal the thread, but i finally got the sensors working stable. Plugins and scripts didn't work for me.

Buy an esp32 from aliexpress and put openmqqt gateway on it.
With help of nodered transfer the sensors values. No battery info because it's not really connecting to the sensors.
Let me know if you need help

viewtopic.php?f=51&t=30637&p=259485#p259485
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest