Plantgateway and Home Assistant

I have installed Plantgateway on a Raspberry Pi Zero W to use with Mi Flora sensors.

I have configured the plantgw.yaml with mqtt config, this is how it’s configured:

    #url of your mqtt server, madatory
    server: x.x.x.x

    #prefix of the topic where the sensor data will be published, mandatory
    prefix: pgw01/plants
    #terminate topic with a trailing slash, optional as defaults to True
    #trailing_slash: False

    #port of the mqtt server, optional if using 8883
    port: 1883
    #client_id to use with the mqtt server, optional as defaults to unique numeric identifier
    client_id: homeassistant

    #credentials for the mqtt server, optional if you do not use authentication
    user: xxxx
    password: yyyy

    #format for timestamp string using strftime(), optional as defaults to ISO8601 format
    timestamp_format: "%y-/%m-%d %H:%M:%S"

and this is how the MQTT config I configuration.yaml looks like:

 broker: !secret broker_ip
 port: 1883
 client_id: home-assistant-1
 discovery: true
 discovery_prefix: home-assistant-1
 username: !secret mqtt_username
 password: !secret mqtt_password

But I can’t get anything in my HA, I wonder do I need to do some more configuration for the device to receive mqtt correctly or will it auto discover without needing to do anything more than the config I did above?

I have no idea how plantgateway works but you can check what’s been seen by the broker with mqtt.fx or similar.

You will need to configure the sensors in HA. See the “Plant Monitor” component for example config:

Hi, I got it working. Here are the steps to reproduce it:

You don’t need the component Plant Monitor. That is totally optional to change the look of your sensor in the UI.

1.You need a MQTT Server (Broker). I installed one in Docker from toke/mosquitto because the Home Assistant Broker did not work for me.
2.After that configure Home Assistant to connect to your broker:

  broker: your-mqtt-broker-ip

3.Configure a Home Assistant sensor for each value of your MiFlora sensor

  - platform: mqtt
    name: plant_3_moisture
    state_topic: /home/pizero_1/plant_3/
    value_template: '{{ value_json.moisture }}'
    unit_of_measurement: '%'
  - platform: mqtt
    name: plant_3_battery
    state_topic: /home/pizero_1/plant_3/
    value_template: '{{ value_json.battery }}'
  - platform: mqtt
    name: plant_3_temperature
    state_topic: /home/pizero_1/plant_3/
    value_template: '{{ value_json.temperature }}'
    unit_of_measurement: '°C'
  - platform: mqtt
    name: plant_3_conductivity
    state_topic: /home/pizero_1/plant_3/
    value_template: '{{ value_json.conductivity }}'
    unit_of_measurement: 'μS/cm'
  - platform: mqtt
    name: plant_3_brightness
    state_topic: /home/pizero_1/plant_3/
    value_template: '{{ value_json.brightness }}'
    unit_of_measurement: 'lux'

4.Restart Home Assistant
5.Install plantgateway on your Pi Zero W according to the instructions here:
6.Configure plantgateway. Example:

    server: your-mqtt-broker-ip
    prefix: /home/pizero_1
    port: 1883
    client_id: Plant Gateway
    - mac: your-miflora-mac-adress
      alias: plant_3
logfile: /home/plantgw.log

7.Execute plantgateway

The sensor values should show up on your Home Assistant Home tab.

You can use a mqtt client on your computer and connect to your broker to check if new messages are correctly published.
When everything works, you should secure your mqtt broker.

Now you can group your sensors in Home Assistant or use the Plant Monitor Component.
Example for grouping without Plant Monitor Component:



I have some challenge to cron this task in the pi zero w, what is the optimal implementation ?

Hi Did you need to write a cron job to start plantgateway? And if you did, where in hassio? I think that’s what i’m missing as my sensor goes offline after an hour or so

mine, on a pi0

[email protected]:~ $ crontab -l
@hourly /usr/local/bin/plantgateway