Mi Flora plant sensor
Step-by-step how-to guide install the Mi Flora plant sensor on a Raspberry Pi 4, with the latest Raspbian Buster image and Domoticz.
For this how-to we will be using our highly regarded Python Plugin Manager. In case you have not installed this yet, take a look at the prerequisites, you will find a link to the related how-to to install this.
Please be aware that when you buy your Flower Mate from China, you need to buy the International model and NOT the Chinese/Asian model!
There are also reports that Xiaomi would or could be bricking these devices using the native Flower Care app. Personally I do not have experienced these issues, but just to be safe:
You don’t need the Flower Mate app to get this device working with Domoticz!!!
This how-to is part of a bigger series of Domoticz how-to’s on sancla.com!
This tutorial has been verified with:
Python Plugin Manager version 1.5.1
The Mi Flower Mate plugin version 1.0.0
- Running Domoticz installation with stable Raspbian Buster release and SSH access. See my previous post for a how-to:
- Domoticz Python Plugin Manager installed:
- Raspberry Pi 4 (MEM 2GB with 16GB sd-card)
- Raspbian Buster Lite 4.19, Februari 2020
- Domoticz Stable 2020.1 (compile date 22-3-2020)
- Domoticz Python plugin manager dated March 29, 2020
Step 1: Install the Bluepy library
Before we can install the plugin we need to install the bluepy library. This library enables Python to talk to Bluetooth devices under Linux. Without this library, the plugin can’t talk to your Flower Mate. Start by connecting with SSH to your Domoticz installation and run the following commands:
sudo apt-get install python3-pip libglib2.0-dev -y
sudo pip3 install bluepy
Step 2: Install the Mi Flower Mate Plugin
Next is to install the Mi Flower Mate Plugin with the Python Plugin Manager (PP-Manager). Add a new hardware device under Domoticz and use the following settings to create the hardware device (and activate the plugin):
- Enabled: Enabled
- Name: PP-Mi Flower Mate
- Type: Python Plugin Manager
- Data Timeout: Disabled
- Plugin to install: Xiaomi Mi Flower Mate
- Auto Update: All (NotifyOnly)
- Security Scan: False
- Debug: False
Reboot Domoticz once you have installed the new hardware device, to load the plugin within Domoticz. You can reboot Domoticz from the webinterface menu: Setup -> More Options -> Restart System.
Or with SSH: sudo reboot
The next step is to add the Xiaomi Mi Flower Mate hardware device, after the plugin has been activated.
Use the following settings:
- Enabled: Enabled
- Name: Mi Flower Mate
- Type: Xiaomi Mi Flower Mate
- Data Timeout: Disabled
- Device selection: Automatic *
Once a Flower Mate device is found, it will automatically add the found sensors to Domoticz:
* Device selection
For the device selection you can also add the devices manually. This is especially useful if you have multiple devices or if you have ‘interference’ from the flower mate of your neighbor(s).
If you are using the manual option, scan for your Flower Mates to find their mac-addresses by entering this command into a terminal:
sudo hcitool lescan
Let it run for a while (or for the inpatient ones, whip out the battery from the flower mate and put it back in). After a while, bluetooth devices in the area will start to show up. Look for found devices named “Flower care” or similar.
Step 3: Enabling the device in Domoticz
Once you have acquired your Flower Mate device in Domoticz, automatically or manually, you need to enable the device in order to receive updates. This is done this way as this enables the plugin to actively pull an update from the Mi Flower Mate device. But only once, not continuously (by design to save power and put you in control).
Step 4: Automatically update the sensors
However, as great as it is to manually update the sensors every time, automatically updating your Mi Flower Mate sensors would be even better. Luckily, we can do this very easily under Domoticz, thanks to the design choices the developer made.
I present you 2 different options:
- Option A: Using a device timer
- Option B: Using a Blockly script
Option A: Create device timers
The easiest way to automatically trigger an update of the sensors is to enable the devices and enable a timer for this device. After you enabled all the Mi Flower Mate devices, look for it under the Switches tab in Domoticz.
Then click on the “Timers” button to configure the timer:
On of the nice things of working with timers is that you can add multiple timers. In this example I created 4 timers, to the sensors receives an update every 6 hours.
Keep in mind that the more frequent you pull an update from your Mi Flower Mate, the worse the energy consumption will be and the faster the battery will be drained!
Option B: Create a Blockly script
In this example I created a fairly easy to duplicate Blockly script to update the sensors daily. There are others ways to script this, even better with LUA, Python or dzVents scripts. But this example should give you a fairly good start with Blockly. Keep in mind that the more frequent you pull an update from your Mi Flower Mate, the worse the energy consumption will be and the faster the battery will be empty!
- Save your script!
- Enable the “update Mi Flowermates” device under Devices!