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:
Code: Select all
git clone https://github.com/Tristan79/miflora.git
cp -R ~/miflora/ ~/domoticz/scripts/python/miflora
7) Install the required dependencies:
Code: Select all
sudo apt-get install nstall python3 python3-pip
sudo pip3 install pygatt
sudo pip3 install requests
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:
Code: Select all
print("\n1: Bouganvillea")
update("C4:7C:8D:60:D4:FA","11","12","13","14")
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:
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%
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.
Code: Select all
* */12 * * * /usr/bin/python3 /domoticz/scripts/python/miflora/domoticz.py >/dev/null 2>&1
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.
