Python plugin: Xiaomi Mi Flower Mate
Moderator: leecollings
-
- Posts: 3
- Joined: Friday 13 April 2018 23:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
I'm not sure if it adds a lot of information, but...
- I like the work on this plugin a lot! It opens up the possibility to access the plant data, even when not in range.
- Unfortunately, I do get the exact same error message: "Error: (MiFlower) 'onHeartbeat' failed 'BTLEException'. Also, the toggle switch gets stuck, and the only option is to reset my raspberry pi.
The weird part is that it usually *does* work a few times, and I do get valid data. But after the 3rd/4th time, it crashes.
Although my knowledge on domoticz and python (especially) is rather at the very beginner level, i'd be happy to contribute to some trouble shooting here. Any thoughts about stuff I can try?
- I like the work on this plugin a lot! It opens up the possibility to access the plant data, even when not in range.
- Unfortunately, I do get the exact same error message: "Error: (MiFlower) 'onHeartbeat' failed 'BTLEException'. Also, the toggle switch gets stuck, and the only option is to reset my raspberry pi.
The weird part is that it usually *does* work a few times, and I do get valid data. But after the 3rd/4th time, it crashes.
Although my knowledge on domoticz and python (especially) is rather at the very beginner level, i'd be happy to contribute to some trouble shooting here. Any thoughts about stuff I can try?
Re: Python plugin: Xiaomi Mi Flower Mate
Instead of switch button why you don't use a push button to refresh?
-
- Posts: 331
- Joined: Wednesday 21 December 2016 9:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: current
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
The button already works as a push button really. It just switches back to 'off' after it has scanned all the devices.
I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip.
I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip.
-
- Posts: 3
- Joined: Friday 13 April 2018 23:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
I think it's important to realize that (at least, for me), it *sometimes* works. This points towards certain possibilities (like, sensor is just inside/outside range), and away from other possibilities (like, privileges of the plug-in).
I can try to run the setup with my plant next to my raspberry pi. If the distance is < 1meter, I think we can safely confirm (or rule out) that that is the issue.
To be continued.
I can try to run the setup with my plant next to my raspberry pi. If the distance is < 1meter, I think we can safely confirm (or rule out) that that is the issue.
To be continued.
Re: Python plugin: Xiaomi Mi Flower Mate
Thank you, I understand now.blauwebuis wrote: ↑Monday 16 April 2018 10:07 The button already works as a push button really. It just switches back to 'off' after it has scanned all the devices.
"I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip."
This is my second question. One of my sensors is a little bit far away from my bluetooth receiver and sometimes it fails to read. In this case refresh button stays "on" and it's not possible to update anymore.
2018-04-16 19:51:04.991 User: Admin initiated a switch command (102/Xiaomi Flower Mate - Refresh/Off)
2018-04-16 19:51:04.991 MAIN SwitchLightInt : switchcmd=="On" || level < 0, new level:0
Please, add some more error handling and/or timeout function to the plugin.
Re: Python plugin: Xiaomi Mi Flower Mate
Or is there any way to reset plugin without need to restart whole domoticz?
Re: Python plugin: Xiaomi Mi Flower Mate
Thanks for developing this plugin.
Have the plugin enabled in my domoticz installation, but automatic scanning is failing. I see the following in domoticz logfile:
(Xiaomi Mi Flower) Scan failed
Any suggestions how to debug this further?
Have the plugin enabled in my domoticz installation, but automatic scanning is failing. I see the following in domoticz logfile:
(Xiaomi Mi Flower) Scan failed
Any suggestions how to debug this further?
-
- Posts: 10
- Joined: Tuesday 21 March 2017 20:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Can it be you run it as an unprivileged (non root) user? The scanner needs to run as root the script says.
I am not aware of a way to make the plugin run as another user and only the sub module run as root. I think it is not possible due to security constraints (or am I mistaken?)
Guess you can then only use the manual configured mac addresses you found with "hcitool lescan".
Regards.
Re: Python plugin: Xiaomi Mi Flower Mate
Any updates on this script? My plants starting to die! 

-
- Posts: 1
- Joined: Monday 14 May 2018 15:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Hello,
First of all thanks a lot for this cool plugin
I confirm the behavior explained by @bartS12, at around 5 meter of my raspberry, i can't get the data from the sensor but if i move it near to the raspberry (arround 50cm) it's working well.
Are you looking for an update ?
Thanks
First of all thanks a lot for this cool plugin

I confirm the behavior explained by @bartS12, at around 5 meter of my raspberry, i can't get the data from the sensor but if i move it near to the raspberry (arround 50cm) it's working well.
Are you looking for an update ?

Thanks
-
- Posts: 6
- Joined: Thursday 17 May 2018 1:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Hello,
I always get this error:
2018-05-17 01:15:59.613 User: Admin initiated a switch command (693/Huerto - Flip to update Mi Flowermates/Off)
2018-05-17 01:15:59.630 (Huerto) onCommand called for Unit 1: Parameter 'Off', Level: 0
2018-05-17 01:15:59.630 (Huerto) amount of Flower Mates to now ask for data: 1
2018-05-17 01:16:03.050 (Huerto) getting data from sensor: C4:7C:8D:66:14:E2
2018-05-17 01:16:03.058 Error: (Huerto) 'onHeartbeat' failed 'ImportError'.
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 247 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 99 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 154 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function getPlantData
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 103 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/miflora_poller.py, function firmware_version
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 47 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/__init__.py, function __enter__
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 48 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/bluepy.py, function connect
This is on a Rasp3. Bluetooth from raspbian discovers the Mi Flora device, so I supose that Domoticz should discover it too.
I have tested with manual or automatic, with no luck.
When button is pressed turns virtual switch off, and get then the error.
Someone?
I always get this error:
2018-05-17 01:15:59.613 User: Admin initiated a switch command (693/Huerto - Flip to update Mi Flowermates/Off)
2018-05-17 01:15:59.630 (Huerto) onCommand called for Unit 1: Parameter 'Off', Level: 0
2018-05-17 01:15:59.630 (Huerto) amount of Flower Mates to now ask for data: 1
2018-05-17 01:16:03.050 (Huerto) getting data from sensor: C4:7C:8D:66:14:E2
2018-05-17 01:16:03.058 Error: (Huerto) 'onHeartbeat' failed 'ImportError'.
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 247 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 99 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 154 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function getPlantData
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 103 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/miflora_poller.py, function firmware_version
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 47 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/__init__.py, function __enter__
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 48 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/bluepy.py, function connect
This is on a Rasp3. Bluetooth from raspbian discovers the Mi Flora device, so I supose that Domoticz should discover it too.
I have tested with manual or automatic, with no luck.
When button is pressed turns virtual switch off, and get then the error.
Someone?
-
- Posts: 6
- Joined: Thursday 17 May 2018 1:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Nothing, no reads after 24 hours. I wonder if the Mi Flower must be added to raspbian devices, associated, or it is no needed.
I have read that it is required to "You'll also have to give Python to access Bluetooth trough additional libraries you will need to install.", as said at https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
Not sure what to do or if it not necessary with this method: https://www.domoticz.com/wiki/Plugins/Mi_flower_mate
Thanks
I have read that it is required to "You'll also have to give Python to access Bluetooth trough additional libraries you will need to install.", as said at https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
Not sure what to do or if it not necessary with this method: https://www.domoticz.com/wiki/Plugins/Mi_flower_mate
Thanks
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Any news on solving the Error: (Mi Flora) 'onHeartbeat' failed 'BTLEException'. Running Pi 3b+ with 11 mi flora sensors 

-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Any fix yet?blauwebuis wrote: ↑Monday 16 April 2018 10:07 The button already works as a push button really. It just switches back to 'off' after it has scanned all the devices.
I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip.
-
- Posts: 21
- Joined: Friday 07 July 2017 22:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest β
- Location: Italy
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
After a long a work (and a bit of “puzzle-tutorial”) I managed to integrate my Mi Flower Mate in Domoticz, but without this plug-in.
The plug-in has some kind of error with Bluetooth Scan on Raspberry Pi 3: each time the automatic scan mode is invoked it results in a “Scan Error” exit message.
Also, even by switching to manual mode and using Mi Flower MAC Address no data is being pulled.
So, here is what I did instead but please note that:
- I’m running RASPBIAN STRETCH LITE with SID repository enabled due to my needs
- I have a mixed python environment, here you can read the whole thing: https://drive.google.com/open?id=1ZPVI ... nop1wALugx
1) I’ve started installing the required dependencies listed here: https://www.domoticz.com/wiki/Plugins/Mi_flower_mate
2) Then I installed bluez right from sources.
PLEASE NOTE: since I’m using SID repository I was able to install the more recent version of Bluez: 5.49-4. This version works perfectly fine and has support for Bluetooth Low Energy. If you are using standard repository then chances are you will get a 5.23-ish version.
That is a problem because you need at least version 5.44 in order to make things work. So you will have to compile the new version and install manually over the previous one.
In order to do so, you can follow the section in the official wiki here: https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
3) To enable Bluetooth Low Energy features I followed this guide: https://learn.adafruit.com/install-blue ... y-features
4) Reboot your raspberry to apply changes and in the meantime bring the Flower Mate inside near the raspberry.
5) Launch a Bluetooth Scan to find the Flower Mate MAC ADDRESS with the following:
6) Download this script and copy it inside the domoticz plugin folder:
7) Install the required dependencies:
8) Inside Domoticz I created a new Dummy Device called “Plant” and then added the following virtual sensors:
Soil Humidity – type:percentage
Soil Temperature –type:temperature
Plant Irradiation –type:lux
Soil Fertility –type:custom with axis label: uS/cm2
9) Take note of the IDx of the previously created sensors, in this particular order
10) Locate the domotciz.py file inside miflora folder and edit it with the following:
- At the very beginning insert Domoticz IP, Username and Password (if used)
- At the very bottom delete all lines after the first one (the print lines)
- Customize the print \n1 line with your sensor data: insert a name after the n1: to identify your sensor
- Then in the second line, insert the Bluetooth MAC Address in the first position and then the Sensors IDx in the same order as created.
The result should be similar to this:
Save and exit the editor
11) Now for the moment of true: execute the domoticz.py script to read sensor data with:
12) If the read is successful you should see something like this:
13) Now you will just need to add a cronjob to execute the script at your desired interval to update Domoticz readings. In order to preserve battery life in my Flower Care I chose to made two readings a day.
I agree this is not the best solution, nor the tidiest, but it works.
I hope this might help you too and possibly someone who could develop a working plug-in.
The plug-in has some kind of error with Bluetooth Scan on Raspberry Pi 3: each time the automatic scan mode is invoked it results in a “Scan Error” exit message.
Also, even by switching to manual mode and using Mi Flower MAC Address no data is being pulled.
So, here is what I did instead but please note that:
- I’m running RASPBIAN STRETCH LITE with SID repository enabled due to my needs
- I have a mixed python environment, here you can read the whole thing: https://drive.google.com/open?id=1ZPVI ... nop1wALugx
1) I’ve started installing the required dependencies listed here: https://www.domoticz.com/wiki/Plugins/Mi_flower_mate
2) Then I installed bluez right from sources.
PLEASE NOTE: since I’m using SID repository I was able to install the more recent version of Bluez: 5.49-4. This version works perfectly fine and has support for Bluetooth Low Energy. If you are using standard repository then chances are you will get a 5.23-ish version.
That is a problem because you need at least version 5.44 in order to make things work. So you will have to compile the new version and install manually over the previous one.
In order to do so, you can follow the section in the official wiki here: https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
3) To enable Bluetooth Low Energy features I followed this guide: https://learn.adafruit.com/install-blue ... y-features
4) Reboot your raspberry to apply changes and in the meantime bring the Flower Mate inside near the raspberry.
5) Launch a Bluetooth Scan to find the Flower Mate MAC ADDRESS with the following:
Code: Select all
sudo hcitool lescan
Code: Select all
git clone https://github.com/Tristan79/miflora.git
cp -R ~/miflora/ ~/domoticz/scripts/python/miflora
Code: Select all
sudo apt-get install nstall python3 python3-pip
sudo pip3 install pygatt
sudo pip3 install requests
Soil Humidity – type:percentage
Soil Temperature –type:temperature
Plant Irradiation –type:lux
Soil Fertility –type:custom with axis label: uS/cm2
9) Take note of the IDx of the previously created sensors, in this particular order
10) Locate the domotciz.py file inside miflora folder and edit it with the following:
- At the very beginning insert Domoticz IP, Username and Password (if used)
- At the very bottom delete all lines after the first one (the print lines)
- Customize the print \n1 line with your sensor data: insert a name after the n1: to identify your sensor
- Then in the second line, insert the Bluetooth MAC Address in the first position and then the Sensors IDx in the same order as created.
The result should be similar to this:
Code: Select all
print("\n1: Bouganvillea")
update("C4:7C:8D:60:D4:FA","11","12","13","14")
11) Now for the moment of true: execute the domoticz.py script to read sensor data with:
Code: Select all
/usr/bin/python3 domoticz.py
Code: Select all
1: My Plant Name
Mi Flora: C4:7C:8D:60:D4:FA
Firmware: 3.1.8
Name: Flower care
Temperature: 27.7°C
Moisture: 30%
Light: 199 lux
Fertility: 1740 uS/cm?
Battery: 80%
Code: Select all
* */12 * * * /usr/bin/python3 /domoticz/scripts/python/miflora/domoticz.py >/dev/null 2>&1
I hope this might help you too and possibly someone who could develop a working plug-in.

- gielie
- Posts: 290
- Joined: Tuesday 12 January 2016 11:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest β
- Location: The Netherlands (Alkmaar)
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
I have a question.
My mi flora is working fine on an rasp 2, but i have it running on my second pi (slave) because of the bluetooth distance.
I would like to have this data on my master pi, i tried the master/slave option but the data of the flora is not showing in my master pi (other data is showing) so its only the flora data that is not showing.
Is it possible to add a ip based function in the script, so my master pi can switch the flora switch on my slave pi and receive the data based on ip adres?
My mi flora is working fine on an rasp 2, but i have it running on my second pi (slave) because of the bluetooth distance.
I would like to have this data on my master pi, i tried the master/slave option but the data of the flora is not showing in my master pi (other data is showing) so its only the flora data that is not showing.
Is it possible to add a ip based function in the script, so my master pi can switch the flora switch on my slave pi and receive the data based on ip adres?
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Are all the devices available in the master slave settings?
Well I updated today all my 3 rasps to 4.970 version and indeed no master/slave Exchange anymore for the MI Flora sensors
The reason is explaind here viewtopic.php?f=6&t=18224&sid=257658d0e ... 8&start=20
Well I updated today all my 3 rasps to 4.970 version and indeed no master/slave Exchange anymore for the MI Flora sensors

The reason is explaind here viewtopic.php?f=6&t=18224&sid=257658d0e ... 8&start=20
- Attachments
-
- Screenshot_20180617-072116.png (341.43 KiB) Viewed 4643 times
Last edited by tonbor on Thursday 28 June 2018 8:09, edited 3 times in total.
-
- Posts: 317
- Joined: Thursday 12 January 2017 15:30
- Target OS: Linux
- Domoticz version: Beta Ch
- Location: Finland
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
I managed to broke my association by using android miflower app and connecting it to device, after that it broke. I have tried to remove and installing plugin again, but its a nop go. No devices appears anymore. How do i delete old plugin and install new one correctly ?
I can see device when scanning, but plugin is not installing ?
I can see device when scanning, but plugin is not installing ?
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Remove plugin directory and plugin in hardware domoticz
-
- Posts: 85
- Joined: Saturday 14 January 2017 21:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Xiaomi Mi Flower Mate
Hi,
after the installation of the script, how I add the sensor in the dashboard?
Thanks
after the installation of the script, how I add the sensor in the dashboard?
Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
Who is online
Users browsing this forum: No registered users and 1 guest