Monitor your plants with Home Assistant

I love to have a lot of plants in my apartment, but unfortunately I sometimes forget to water them. So why not using modern technology to make sure, I don’t ever forget it again.

What you need

  • A Raspberry Pi or a Linux-PC with a supported Bluetooth LE interface.
  • Bluez
  • Mi Plant flower sensor for every plant
  • Home assistant

Setup

Home assistant

First you should install Home Assistant and make sure everything works well. Home assistant provides good documentation how to setup the platform.

Bluetooth software

The Linux bluetooth software might not yet be installed on your system.

Check communication with the plant sensor

The easiest way to make sure your PC can read data from the sensor is using the hcitool command line tool.

hcitool lescan
LE Scan ...
XX:XX:XX:XX:XX:XX (unknown)
XX:XX:XX:XX:XX:XX Flower mate

It might list a lot of other devices. Just make sure, it can also see the “Flower mate” device. If you can’t see this device, the distance between the flower sensor and your PC might be too large. Try moving the plant near your PC and check if it works then.

Integrate polling into Home Assistant

First, you need to poll the data from the sensor in Home Assistant:

sensor
  platform: miflora
  mac: xx:xx:xx:xx:xx:xx
  name: Flower 1
  force_update: false
  monitored_conditions:
   - moisture
   - light
   - temperature
   - conductivity

As the MAC address, you need to use the address that is shown in the hcitool lescan output.

Notify yourself when you come home

It doesn’t make much sense to send you a notification during the day that you should water the flowers. You might have forgotten it already when you come home. So let’s just send a notification when you come home.

Setup presence detection

Home Assistant documentation how to do this. There are a lot of different device trackers. Have a look and decide what works best for you.

Setup notifications

The next step is sending a notification to you. For this guide I use Pushetta, but Home Assistant provides a large number of notification mechanisms. Have a look at them and select the one that fits best for you.

An example notifier configuration might look like this:

notify
  name: pushetta
  platform: pushetta
  channel_name: mychannel
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Define the automation

Now comes the new rule:

automation:
  alias: Alarm me to water plants
  trigger:
    platform: state
    entity_id: device_tracker.myname
    from: 'not_home'
    to: 'home'
  condition:
    condition: numeric_state
    entity_id: sensor.flower1_moisture
    below: 20
  action:
    service: notify.pushetta
    data:
      message: 'Water Flower 1!'

What does this do? First it checks it check, if you came from (device tracker changes from not_home to home) and check then if the moisture is below a well-defined threshold. The value might be a bit different for your plant, you need to adjust this. If the moisture is too low, it sends a notification via Pushetta.

You can combine multiple plants in the condition statement or create an automation for every single plant. I personally prefer the latter as I then know exactly which plant I should water.

Long-term monitoring

It often helps to have long-term data available to optimize not only watering, but also fertilize in the right intervals. While you can store the whole history within Home assistant, it isn’t really optimized for this use case. Therefore I recommend to use InfluxDB for this. This is a time-series database specifically designed to store sensor data over a long period. To visualize the data, I use Grafana. With this, you can create nice reports like this:
TODO

11 thoughts on “Monitor your plants with Home Assistant”

  1. Great achievement!
    I’m running HASS 0.28.2 but I can’t see miflora platform yet!
    Also I have a different requirement, since my HASS server does not have BlE I would like to use my Raspberry pi 3 to collect data from Miflora sensor and send it to my HASS, is it possible?

    Thanks
    Naoufal

  2. Hi,

    I’ve bought some on Internet and only one of them is seen as “flower mate”. Others are seen as “flower care” and are not seen in HA. Any idea of my mistake ?

    Thanks in advance,

    Doune

  3. Hi Daniel,

    do you have a good source for moisture and conductivity values or is it more of an trial and error approach 🙂

    Best regards, Fabian

  4. Hi

    When I run the demo.py script included in your miflora library I get this error:-

    File “C:\Python36\miflora\miflora_poller.py”, line 12, in
    from subprocess import PIPE, Popen, TimeoutExpired
    ImportError: cannot import name TimeoutExpired

    I get this in Python 2.7 and 3.6.

    The subprocess module must be visible as there are no complaints about importing PIPE and Popen.

    Any thoughts?

    Thanks

    1. Hi
      Please delete my previous comment.
      TimeoutExpired is in Python3.6.

      It seems that when I thought I was trying 3.6 my editor linked me to 2.7.

      Sorry.

  5. May I ask a question? I bought three of these sensors and am making my first steps. But as far as I see it, these sensors have no specific id-numbers which make then unique. So how do you recognize which data are from plant1, plant2 or plant3?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.