Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

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

Yes sir that does the trick. Thanks a lot.

But can you also store it in a DateTime Item?

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'

Seee, that’s why I said to try

or similar…

Now it is working. The timepattern should be:

’%Y-%m-%dT%H:%M:%S’

The “T” was missing

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

All-

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,

-Mark

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

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()))

All-

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,

-Mark

1 Like

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

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.

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.

Think outside the box!!

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):

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:

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?

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.

[General]

# 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

[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: 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

[Sensors]

# 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"

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