Plant status with MiFlora in Home Assistant through Xiaomi BLE integration



Most instructions you'll find online document how to integrate MiFlora plant sensors through Home Assistant's ESPHome integration. Home Assistant natively supports MiFlora devices, though, through the Xiaomi BLE integration, where Home Assistant registers the values the sensor broadcasts over Bluetooth, and only occasionally polls the sensor for the battery status. This write-up covers the Xiaomi BLE setup. If Bluetooth is working correctly on your Home Assistant instance, all you need to do is activate the plant sensor by inserting a battery. Home Assistant will detect the plant sensor and expose its sensors, so you can show the values in a card.

Obtaining plant specific tresholds

The Xiaomi BLE integration allows you to show the raw plant sensor data, but Home Assistant has no way of telling you if those values are good or bad - that is, if the soil your plant sits in is dry, if it needs fertiliser, if the plant gets enough daylight, etc. That's where the plant status card comes in handy. HA needs to be told which tresholds are okay. There are a few ways to obtain those:

  • From the Xiaomi Mi Home app (if you have a Xiaomi branded device)
  • The HHCC Flower Care app (if you have a HHCC branded device)
  • By downloading the Mi Flora database and getting the values by hand
  • By consulting the open Plantbook database.

Keep in mind the apps and Plantbook might need registering. Extracting the right values from the database download may be rather clumsy. A HA community topic on the database can be found here, and Plantbook has one too.

Extending the YAML configuration with plant specific tresholds

Once you have the values, insert the following include in your configuration.yaml file:

!include plants.yaml

Then create a plants.yaml file, and insert the following. The sensor names need to match the Xiaomi BLE device and sensor names in HA exactly. In this case, e.g., my device is named 'Mi Flora Areca 1'. The moisture, conductivity, temperature and brightness ranges differ per plant species, so you take these from the app or database as explained above, and modify the code accordingly. The plant species here is an Areca Dypsis Lutescens as in the comment line on top, so I named my plant 'areca_1' for ease of use.

# Areca Dypsis Lutescens
areca_1:
  sensors:
    moisture: sensor.mi_flora_areca_1_moisture
    temperature: sensor.mi_flora_areca_1_temperature
    conductivity: sensor.mi_flora_areca_1_conductivity
    brightness: sensor.mi_flora_areca_1_illuminance
    battery: sensor.mi_flora_areca_1_battery
  min_moisture: 15
  max_moisture: 60
  min_battery: 20
  min_conductivity: 350
  max_conductivity: 2000
  min_temperature: 10
  max_temperature: 35
  min_brightness: 2000
  max_brightness: 35000
  check_days: 3

Save and restart HA to make sure the new plant entity is available. While just reloading the YAML configuration should work, for me it did not; only a restart made the plant entity show up.

Configuring the plant status card

After restarting, add a new plant status card. You should see the Areca plant entity available. The values will be shown automatically, and highlighted in red if they are outside the desired range fo your plant.

Adding a pretty picture to the plant status card

To add a picture to your plant status card, expand your configuration.yaml as follows. Since the picture value is a path passed to the browser, take care not to use any spaces.

homeassistant:
  customize:
    plant.areca_1:
        friendly_name: Areca Dypsis Lutescens
        entity_picture: /local/areca_dypsis_lutescens.jpg

Once that's done, place the areca_dypsis_lutescens.jpg file in the www/ subdirectory that's present in the HA configuration directory. This is where /local/ in the YAML maps to. See [the wiki][] for more information. Reload your configuration through the UI afterwards.

A note on battery status

As the HA wiki points out, the battery status will only be read once daily, if the BLE signal is strong enough.