Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

Tags: #<Tag:0x00007f014adb0108> #<Tag:0x00007f014869bf40> #<Tag:0x00007f014869bdd8>

( ) #61

Ah the sensor internally doesn’t update quicker than 30 seconds. That’s interesting to know :smiley:

(Thomas Bail) #62

Yes sir that does the trick. Thanks a lot.

( ) #63

But can you also store it in a DateTime Item?

(Thomas Bail) #64

No, got the following error message:

2018-01-16 16:40:54.355 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'Mo_Plant003_LastUpdate'

( ) #65

Seee, that’s why I said to try

or similar…

(Thomas Bail) #66

Now it is working. The timepattern should be:


The “T” was missing

( ) #67

There you go!
I’ll take note to add this. Will also need to add it to the openhab generator function.

(Mark Noe) #68


I am trying to install ThomDietrich’s python module on a Raspberry Pi2 running Wheezy. I need to run this operating system for another application that is running on the same machine. While I was able to follow the installation instructions successfully when this machine was running Raspbian, it now fails at the step where we run sudo pip install -r requirements.txt because it indicates that the command pip does not exist. The workaround is to replace pip with pip-3.2, which then runs, but it fails indicating that it could not find any downloads satisfying the requirements of line 2, etc. of the script. Looking at the log reveals a 403 error: SSL is required. Apparently this is an issue running pip-3.2. Do you have any ideas for a workaround?

Many thanks,


( ) #69

Hey Mark,
Please update your python (and pip) installation to at least v3.4

(Kim Skatun) #70

For the next version of the daemon it would be nice if we in the config file could define item specific update interval to override the global one:

I am trying to understand how this can be implemented in the pyton code:

        print('Internal name: "{}"'.format(name_clean))
        print('Device name:   "{}"'.format(flora_poller.name()))
        print('MAC address:   {}'.format(flora_poller._mac))
        print('Firmware:      {}'.format(flora_poller.firmware_version()))
        print('Update Interval:      {}'.format(flora_poller.Interval()))

(Mark Noe) #71


I found a way to use my other application (DV MEGA for amateur radio) using Raspbian. The scripts installed nicely reverting to that OS.

Many thanks,


( ) #72

Not sure why!? In general please report such an idea as a GitHub issue :wink:

(Kim Skatun) #73

My plant needs update interval of 600s, while my fridge needs update interval of 60s.(You want to make sure you get notified before you leave the flat that you forgot to close the door, rather than after. With 60s then I will notify the user if its been open for more than two measurements i.e 2-3 minuttes, with 600s this would have been 20-23minutes…). So instead of having the daemon spit out values for all 17 sensor at 60s, it would be awesome to define that the fridge differs from the default value.

I am just trying to reduce the load of the OH server.

( ) #74

I see.
Okay sounds reasonable, even though it’s imho a requirement only for users who “misuse” their sensors like you do. :smile: Could you please open an Issue? Also to be honest I’ll not have the time in the next few weeks. If you can look at the solution yourself, that would be great.

(Kim Skatun) #75

Think outside the box!!

(Gordan) #76

I ran into some deep trouble with the “vim” editor after the

-> vim /opt/miflora-mqtt-daemon/config.ini <- Comand.

not Knowing there were a differents between “nano”, “vim” and other editors and How to Close or Save the File.

This Helped me (JiC Somone has the same beginner problem):

( ) #77

That’s why I never mention one specific editor. The choice is up to you!
(of course vim is the one and only mighty one but you can use others if you really need to :stuck_out_tongue_winking_eye:)

Random fun fact: The “How to exit the Vim editor?” question got some fame recently:

(Curlyel) #78

Hi @ThomDietrich,
many thanks for your your work! Had that sensor laying around for a year or so, Few days ago I gave it a try with your deamon: Worked at the first try - excellent job, excellent tutorial!

The range is much better than expected (one reinforced concrete floor between Mi Flora and the bluetooth interface!). So I’m quite happy with it.

Just two questions:
I’ve set the readings to one every 10 minutes. Up to now (running just few days), there is no battery drain reported (still at 100%). What are your experiences of the battery life?

How to check for retries/unsuccessful readings to get a feeling of the signal quality? Probably an idea to include the RSSI/error count/retry count or similar into the MQTT topics?

(Carsten) #79

I did this but now…i got errors too :frowning:

[15:37:58] openhabian@openHABianPi:~$ nano /opt/miflora-mqtt-daemon/config.ini

  GNU nano 2.2.6     File: /opt/miflora-mqtt-daemon/config.ini                  

# Configuration file for Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
# Source: https://github.com/ThomDietrich/miflora-mqtt-daemon
# Uncomment and adapt all settings as needed.


# The operation mode of the program. Determines wether retrieved sensor data is$
# Currently supported:
#      mqtt-json - Publish to an mqtt broker, json encoded (Default)
#     mqtt-homie - Publish to an mqtt broker following the Homie MQTT conventio$
# mqtt-smarthome - Publish to an mqtt broker following the mqtt-smarthome propo$
#                  (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 (De$
adapter = hci0


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

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


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

# The TCP port the MQTT broker is listening on. SSL/TLS currently not implemen$
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:$
base_topic = miflora
#base_topic = homie

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

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


# Add your Mi Flora sensors here. Each sensor consists of a name and a Etherne$
# Additional location information can be added to the name, delimited by an '@$
# Scan for sensors from the command line with:
#    $ sudo hcitool lescan
# Examples:
#Schefflera@Living = C4:7C:8D:11:22:33
#JapaneseBonsai    = C4:7C:8D:44:55:66
#Petunia@Balcony   = C4:7C:8D:77:88:99
Einblatt@Bedroom = C4:7C:8D:65:DE:85
Begonia Corallina@Büeo = C4:7C:8D:65:DE:9F

[15:45:54] 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

[2018-02-15 15:45:59] Connecting to MQTT broker ...
[2018-02-15 15:45:59] MQTT connection error. Please check your settings in the configuration file "config.ini"

(Thomas Bail) #80

Hm at the first sight i do not see anything unusual. Maybe in this line

Begonia Corallina@Büeo = C4:7C:8D:65:DE:9F

the special german “ü” or the space is the problem