Xiaomi Flora with PlantGateway and MQTT

Hello,

I’m very new to HASS and MQTT, and I hope someone can help me with my problem.

I want to add a Xiaomi Flora sensor to HASS and want to read the plant data with my Nuc7 over BTL and PlantGateway (https://github.com/ChristianKuehnel/plantgateway).

My Hass appliance is a virtual machine running on my Qnap, so I have to send the data from my NUC with MQTT to it, MQTT Server is Mosquitto on the appliance.

I discovered the MAC from the sensor and PlantGateway looks good so far, that’s the result if I run it:

Thu, 08 Aug 2019 13:10:07 INFO     PlantGateway version 0.6.2
Thu, 08 Aug 2019 13:10:07 INFO     loaded config file from /home/user1/.plantgw.yaml
Thu, 08 Aug 2019 13:10:07 INFO     Getting data from sensor feige
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_battery/config
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_temperature/config
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_brightness/config
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_moisture/config
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_conductivity/config
Thu, 08 Aug 2019 13:10:07 INFO     sent sensor config to topic homeassistant/sensor/plant_C47C8D6B2597_timestamp/config
Thu, 08 Aug 2019 13:10:07 INFO     MQTT connection returned result: Connection Accepted.
Thu, 08 Aug 2019 13:10:10 INFO     sent data to topic home/plants/feige/
Thu, 08 Aug 2019 13:10:10 INFO     Disconnected MQTT connection

For now I have discovery enabled in MQTT and the PlantGateway.

HASS shows my plant “Feige” but it’s empty:

grafik

Can somebody please have a look at my config and tell me what’s wrong? I’ve searched a lot and already read https://www.home-assistant.io/components/miflora/ and https://www.home-assistant.io/components/plant/ … but I don’t get it.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

mqtt:
  broker: localhost
  client_id: PlantGateway
  discovery: true
  discovery_prefix: homeassistant
  username: mqtt_user
  password: mqtt_pass
 
plant:
  Feige:
    sensors:
      moisture: sensor.feige_moisture
      temperature: sensor.feige_temperature
      brightness: sensor.feige_brightness
      battery: sensor.feige_battery
      conductivity: sensor.feige_conductivity
    min_moisture: 15
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    max_conductivity: 800
    min_temperature: 5
    max_temperature: 35
    min_brightness: 3000
    max_brightness: 70000

sensor:
  - platform: mqtt
    name: feige_moisture
    state_topic: "home/plants/feige/"
    value_template: '{{ value_json.moisture | int }}'
    unit_of_measurement: '%'
    force_update: true
  - platform: mqtt
    name: "feige_brightness"
    state_topic: "home/plants/feige/"
    value_template: '{{ value_json.brightness | int }}'
    unit_of_measurement: 'Lux'
    force_update: true
  - platform: mqtt
    name: "feige_temperature"
    state_topic: "home/plants/feige/"
    value_template: '{{ value_json.temperature | float }}'
    unit_of_measurement: '°C'
    force_update: true
  - platform: mqtt
    name: "feige_battery"
    state_topic: "home/plants/feige/"
    value_template: '{{ value_json.battery | int }}'
    unit_of_measurement: '%'
    force_update: true
  - platform: mqtt
    name: "feige_conductivity"
    state_topic: "home/plants/feige/"
    value_template: '{{ value_json.conductivity | int }}'
    unit_of_measurement: 'µS/cm'
    force_update: true

That’s my PlantGateway Config:

mqtt:
    server: hassio.home

    discovery_prefix: homeassistant

    prefix: home/plants
    port: 1883
    client_id: PlantGateway
    user: mqtt_user
    password: mqtt_pass

sensors:
    - mac: C4:7C:8D:6B:25:97
      alias: feige

Thanks in advance

Hi geeuz,
here is how I have mine working.

configuration.yaml

plant:
  aloe_vera:
    sensors:
      moisture: sensor.aloe_vera_moisture
      battery: sensor.aloe_vera_battery
      brightness: sensor.aloe_vera_brightness
      temperature: sensor.aloe_vera_temperature
    min_moisture: 20
    max_moisture: 50
    min_battery: 17

I do not have anything in sensor.yaml
Also I do not have any mqtt config in my configuration.yaml.

Instead I used the MQTT integration page with discovery enabled.

Here is what my plantgateway looks like



mqtt:
    server: 192.168.68.102
    discovery_prefix: homeassistant

    prefix: miflora
    port: 1883
    client_id: PlantGateway

    user: mqttuser
    password: mqttpassword

sensors:
    - mac: C4:7C:8D:6A:F4:3A
      alias: aloe_vera

logfile: plantgw.log

Also you could try keeping your configs as it is and removing the discovery_prefix in plantgateay.

Let me know if it works.

1 Like

Hi!

thank you very very much, both ways you described are working now, pretty cool!

Thanks a lot.