Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

I would by i not own a Flora Sensor since now…will take a look at the coming ads in the next day and will try to get one…

Did you get yours from aliexpress?

Yes. https://www.aliexpress.com/wholesale?SearchText=xiaomi+mi+flora+plant+sensor

Back then there were no different versions. Now there is an international Version which is basically more expensive but can be paired with the app outside of China. If you (like me) will not use the app, you can ignore that and go cheaper.

Installation of the daemon is pretty easy. Maybe I’ll add it to openHABian tonight.

1 Like

Thanks for the feedback. Yes, being able to call status on the daemon and get an overview of all plants would be awesome.
But no hurry. By now, I’ve integrated two sensors in my setup and I also added a “Last Update” time to each one that gets updated as soon as one of the values changed (and light intensity basically updates each time).
Set it to 15min and saw now, that both work flawlessly every 15min, so I expect to see almost 100% success rate in the status message. :smiley:

Here we go :smiley:

1 Like

I have 12 of them, really handy for me that does not have green fingers, unfortunately 2 of them is out of the reach for the rpi, so sometime this winter I will add a bridge as rpi0W. I also have some water irragation system that I am working on…

I have the same problem as you. The range does not reach from the pi to the MIflora. If you have any idea how to create a bridge increase the power would be very grateful to collaborate.

Hey, that problem is part of why the daemon relies on MQTT. You can simply set up another RPi0W in Bluetooth range: Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

A very expensive repeater turns out :frowning:

Very expensive is a relative term i guess :smirk: When i compared it to other solutions, this setup (even with one or two extra rpi0W) was still the cheapest for me if you want several sensors.

For Node-red users there is a node which auto detects your miflowers and get data from them. you need to install a few nodes also, but it works and it’s up and running without any hassel:

Can you confirm that 10 devices is maximum per rpi?

I am not really sure if I setup my config right cause i got an error after the start… :sweat_smile:

[21:24:44] openhabian@openHABianPi:~$ python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py

Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Source: https://github.com/ThomDietrich/miflora-mqtt-daemon

Traceback (most recent call last):
  File "/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 119, in <module>
    config.read([os.path.join(sys.path[0], 'config.ini.dist'), os.path.join(sys.path[0], 'config.ini')])
  File "/usr/lib/python3.4/configparser.py", line 672, in read
    self._read(fp, filename)
  File "/usr/lib/python3.4/configparser.py", line 1070, in _read
    fpname, lineno)
configparser.DuplicateOptionError: While reading from '/opt/miflora-mqtt-daemon/config.ini' [line 42]: option 'base_topic' in section 'MQTT' already exists

Config.ini

[General]

# The operation mode of the program. Determines wether retrieved sensor data is published via MQTT or stdout/file.
# Currently supported:
#      mqtt-json - Publish to an mqtt broker, json encoded (Default)
#     mqtt-homie - Publish to an mqtt broker following the Homie MQTT convention (https://github.com/marvinroger/homie)
# mqtt-smarthome - Publish to an mqtt broker following the mqtt-smarthome proposal
#                  (https://github.com/mqtt-smarthome/mqtt-smarthome)
#           json - Print to stdout as json encoded string
reporting_method = mqtt-json

# The bluetooth adapter that should be used to connect to Mi Flora devices (Default: hci0)
adapter = hci0

[Daemon]

# Enable or Disable an endless execution loop (Default: true)
enabled = true

# The period between two measurements in seconds (Default: 300)
period = 300

[MQTT]

# The hostname or IP address of the MQTT broker to connect to (Default: localhost)
hostname = localhost

# The TCP port the MQTT broker is listening on. SSL/TLS currently not implemented (Default: 1883)
port = 1883

# Maximum period in seconds between ping messages to the broker. (Default: 60)
keepalive = 60

# The MQTT base topic to publish all Mi Flora sensor data topics under.
# Default depends on the configured reporting_mode (mqtt-json, mqtt-smarthome: miflora, mqtt-homie: homie)
base_topic = miflora
base_topic = homie

# Homie specific: The device ID for this daemon instance (Default: miflora-mqtt-daemon)
homie_device_id = miflora-mqtt-daemon

# The MQTT broker authentification credentials (Default: no authentication)
#username = user
#password = pwd123

[Sensors]

# Add your Mi Flora sensors here. Each sensor consists of a name and a Ethernet MAC address.
# Additional location information can be added to the name, delimited by an '@'.
# Scan for sensors from the command line with:
#    $ sudo hcitool lescan
#
# Examples:
Einblatt@Bedroom = C4:7C:8D:65:DE:85

mmhh? :confused:

Thanks will check,that one out for sure

You’ve got one “base_topic” too much there. You configure the name of the mqtt base topic to publish the messages on, but you only chose one name for that.

Try to comment out the line by adding a # in front.

I can not confirm as I only have 6 sensors.
Not sure where the restriction would come from

Can anyone confirm that Miflora broadcast its values every 30s, which means that if we set up refresh interval in miflora deomon to 30s we will get updates in the interval 0-100s.

@ThomDietrich Hey ist it possible to add a timestamp to the plant data?

Thomas

As said the Miflora broadcast its values at a given interval, and you set up the dameon to forward the values at another interval. So no you can not get exact time when the miflora did its measurement as far as I know.

The question is how accurate do you need it? You can always see when the OH item was last updated and if this is more then 1h then either battery or range is wrong. Or what do you want with the timestamp?

I dont care about the interval the mifloras are braodcasting. I what to know when i last received data in openHAB or last send data from the miflora daemons

@skatun I’m not sure what you mean by broadcast. You can configure how often the daemons polls data from the sensor.
Besides that I’m not sure why you’d want to poll every 30 seconds. No plant sensor value will have fluctuations that high and it will drain your battery.

@Dibbler42 would definitely be possible. I feel like it’s already in there!?