Xiaomi has a great line of pretty high quality but very inexpensive hardware that you can use in your smart home. Right now I’m using their plant, door, water, and temperature sensors, as well as their curtain motors. These plant sensors seem to be the only Xiaomi sensor that I have that is not ZigBee. So recently, I got another Raspberry Pi (3B+) to be able to pull in my Mi Flora plant sensors from my living room. There are a ton of tutorials on how to get HASSio loaded on an SD card, so I’ll assume you have Home Assistant up and running.
Here are the steps I used to get my sensors displaying in Home Assistant via the MiFlora component.
- If you installed the “SSH server” add-on from the built-in add-on, then remove that one first.
- Install the “SSH & Web Terminal” add-on.
This is in the Official add-ons repository. - Configure the
username
andpassword
/authorized_keys
options.
Use a complex password here as it checks against Have I Been Pwned database. - Activate
ssl
on the Web Terminal if you use it.
If you use this, make sure you have valid keys that you are pointing to. - Start the “SSH & Web Terminal” add-on.
- Check the logs of the “SSH & Web Terminal” add-on to see if everything went well.
- Open the Web Terminal.
https://hassio.local:7681/ if you have not changed anything from default settings. - Reboot the host.
- Once rebooted, open the Web Terminal.
- Type bluetoothctl to enter the bluetooth controller and then scan on to begin the scanning.
You will begin to see the list of devices appearing on the scanner.
1234567891011➜ ~ bluetoothctlAgent registered[bluetooth]# scan onDiscovery started[CHG] Controller B8:27:EB:Q7:X0:36 Discovering: yes[NEW] Device C4:7C...[NEW] Device C4:7C:8D:67:2E:99 Flower care[NEW] Device 3E:8A...[NEW] Device D8:0F...[NEW] Device C4:7C:8D:67:2D:91 Flower care[NEW] Device 50:32... - Now you have everything you need to add the sensors to your config.
- Edit you configuration.yaml file and add the following:
1234567891011121314151617181920212223242526sensor:- platform: mifloramac: 'C4:7C:8D:67:2D:91'name: Ficus Elastica - Rightforce_update: falsescan_interval: 1800# median: 3monitored_conditions:- moisture- light- temperature- conductivity- battery- platform: mifloramac: 'C4:7C:8D:67:2E:99'name: Schefflera Actinophylla - Leftforce_update: falsescan_interval: 1800# median: 3monitored_conditions:- moisture- light- temperature- conductivity- battery - Restart your Home Assistant instance and you should get the sensors to appear.
- To add them to the UI, I added the following to my lovelace config file:
12345678910111213141516171819202122232425262728293031views:- title: Living Room RPicards:- type: entitiesentities:- entity: sensor.ficus_elastica_right_moisturename: Moisture- entity: sensor.ficus_elastica_right_light_intensityname: Light Intensity- entity: sensor.ficus_elastica_right_conductivityname: Conductivity- entity: sensor.ficus_elastica_right_temperaturename: Temperature- entity: sensor.ficus_elastica_right_batteryname: Batterytitle: Right Ficus Elastica Plantshow_header_toggle: false- type: entitiesentities:- entity: sensor.schefflera_actinophylla_left_moisturename: Moisture- entity: sensor.schefflera_actinophylla_left_light_intensityname: Light Intensity- entity: sensor.schefflera_actinophylla_left_conductivityname: Conductivity- entity: sensor.schefflera_actinophylla_left_temperaturename: Temperature- entity: sensor.schefflera_actinophylla_left_batteryname: Batterytitle: Left Schefflera Actinophylla Plantshow_header_toggle: false
- To make sure I don’t forget about the plants, I’ve added an automation to remind me when it’s time to water my plants:
12345678910111213- alias: Plant Notificationtrigger:- entity_id: sensor.ficus_elastica_right_moistureplatform: numeric_statebelow: '20'- entity_id: sensor.schefflera_actinophylla_left_moistureplatform: numeric_statebelow: '20'action:- service: persistent_notification.createdata:message: Water the plants!title: Plants needs some TLC!
Hi, thanks for the guide! I’m planning on putting together a dozen or two of these sensors and feeding the information into a heatmap of moisture and light levels throughout my garden in Lovelace. The only thing Google turned up was something on Azure marketed to large-scale agriculture. Do you know where I should start to create something like that in HA?
I’m not familiar with a Lovelace heatmap card, but it’s likely someone has made a custom card. In any case, you can make your system, after the data is in HA, you can send it to influxdb and use Grafana to make the heat map, and then you can import a Grafana graph back into Lovelace.
Hey. i added two sensors to my HA. before I found your instructions. but my second sensor shows “unavailable”. can you suggest something?
Do another Bluetooth scan and make sure that sensor is broadcasting an address. I have 4 sensors hooked up to one ESP32 and it’s very reliable.
Thanks. I don’t know how, but my 3 sensors are working now. I didn’t do anything, just waited a couple of days
Hi,
How do you set commands on elevated privileges on HassOS ?
Hello, I run Hassio on Raspberry Pi 3B+ and I have “-bash: bluetoothctl: command not found” when running bluetoothctl command. What can I do ?
Did you follow the instructions and run terminal through elevated privileges?
Hi and thanks for your guide!
I read somewhere that you can install max one mi flora on hassio but I see you have two mi flora installed. How does they work together?
It works fine, I actually have three