Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

Used underscore for the space and office as “büro”…still the same error

OK, now i read the error message. Are you are using password and user in mqtt?

maybe a dump question but do i need to setup any other step besides the installation guide from thom?

Never did something with mqtt…so i need to install mqtt separately?

Yes a mqtt broker is needed. the miflora daemon collects the plant data and publishes it to a mqtt broker and to this mqtt broker openhab is connected.

In the openhabian image you will find a mqtt broker (mosquitto). If it is on the same host like the miflora daemon the localhost is ok. i am not sure about the default mqtt user that is installed in the openhabian package.

But thats the first step. Install mqtt

ok i think i got the mqtt broker working…

but when i try to load the item file it seems it is not working

2018-02-15 20:07:57.337 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'miflora.items'

2018-02-15 20:07:57.713 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'miflora.items'

2018-02-15 20:07:57.798 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'miflora.items'

2018-02-15 20:07:57.871 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JSONPATH

2018-02-15 20:07:57.875 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JSONPATH

You need to install jsonpath transformation in paper ui

1 Like

I think it is going to come to an end :smiley:

Feb 15 20:25:44 openHABianPi miflora-mqtt-daemon.py[29266]: connect error: Transport endpoint is not connected (107)

Is there something wrong with my mqtt.config?

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
miflora.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
miflora.clientId=miflora

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
miflora.user=openhabian

# Optional. Password to authenticate with the broker.
miflora.pwd=testblabla

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

Hi,

just to bring us in the same level. The broker ist in the middle and openhab and miflora are connecting to the broker. Based on this you need to understand that the mqtt binding establishes the connection between broker and openhab. If you restart openhab you should find some kind off connection message in the openhab log. Next part is then to connect miflora. It should be possible to use the same credentials as in opnehab. If you have success with that is shown within the miflora status.

To check if the broker is working you should use a tool like mqttspy. With this tool it is possible to establish ab connection to the broker and read all miflora readings.

Miflora ---- ------ Mqtt broker -------- openhab

So i think we should first check if the broker is running

Hey Carsten,

setting up and working with MQTT is out of the scope of the daemon documentation but you should find everything you need to first make sure MQTT is up and running here:

@curlyel happy you got it working right away. The battery information would certainly be something we can add. Please create a GitHub issue! The battery use is something I never looked at closely but I’ve been polling my sensors at home for quite some time now and they report 90-something percent. I wonder if those readings are correct. @skatun do you know more?
Regarding signal quality: Please check the output of sudo systemctl status miflora.service, also there is the idea to enhance this: Use systemd status for a summary · Issue #16 · ThomDietrich/miflora-mqtt-daemon · GitHub

1 Like

One of my miflora is down to 19% now! I bought it 26/10/2016 add 3 weeks for shipping from china, and we probably end up with 1.5-1.8 years of battery time at 20C

One thing @ThomDietrich I would like to mentioned what I recently implemented lately is this:
Number Miflora_Sensor4_Moisture “Sensor4 Soil Moisture [%d %%]” <text> (gMiflora, Group_Moisture,Group_Moisture_LivingRoom) {mqtt="<[mosquitto:miflora/sensor4:state:JSONPATH($.moisture)]", expire=“1h” }

Which will tell me if i have not got an update from my sensor in the last hour! Works like a charm.

Also I know that the py script says something about signal strength, maybe we could also forward this info to the broker? And finally I were wondering if you do check if the sensor have changed its value(any of the 4 value it reports) from last reading or not, if it hasn’t the sensor needs to be reset.

1 Like

Wow, that’s impressive: One and a half year out of that tiny battery.
Thanks @skatun for coming back on this!

btw.: How often are you querying your sensors? Is it on the five minute default or have you set a longer interval?

… would be really appreciated too :wink:

That’s some good and interesting news! Could you please file issues for all of them?

  1. Add the battery time to the readme
  2. Add expire to the openHAB generation function
  3. Add signal info to MQTT messages
  4. The changed value question. I’m not sure about the answer.
1 Like

@ThomDietrich I Will file those issues, a bit busy these days due to Olympics :slight_smile:
also
5. Possibility to Overide default polling interval for each sensor.

See this link for more info:

In generally the connection miflora -> RasPi3 -> WLAN -> mqtt-broker -> OpenHAB works for me.
Credentials are correct.
But only ~3-4 packages per day are reaching the broker.

“sudo hcitool lescan” lists a lot of Bluetoothdevices but nearly never the miflora sensor.

It’s not a problem of distance to the sensor.

And sometimes there ar Input/output errors:

[17:35:26] openhabian@ohdata:~$ sudo hcitool lescan
LE Scan …
7E:3E:3E:BC:E4:26 (unknown)
7E:3E:3E:BC:E4:26 (unknown)
49:B0:2C:E1:20:FA (unknown)
49:B0:2C:E1:20:FA (unknown)
48:23:56:6A:0C:F6 (unknown)
48:23:56:6A:0C:F6 (unknown)
6D:E5:81:C7:4D:CC (unknown)
6D:E5:81:C7:4D:CC (unknown)
73:AD:22:D4:1A:D9 (unknown)
73:AD:22:D4:1A:D9 (unknown)
74:D3:40:03:46:E6 (unknown)
74:D3:40:03:46:E6 (unknown)
24:4B:03:F6:E9:F4 (unknown)
E9:74:90:A2:9D:3C SM-9D3C
E9:74:90:A2:9D:3C (unknown)
4C:64:F0:04:61:82 (unknown)
^C[17:35:28] openhabian@ohdata:~$ sudo hcitool lescan
Set scan parameters failed: Input/output error
[17:35:28] openhabian@ohdata:~$ sudo hcitool lescan
Set scan parameters failed: Input/output error
[17:35:30] openhabian@ohdata:~$ sudo hcitool lescan
Set scan parameters failed: Input/output error
[17:35:30] openhabian@ohdata:~$ sudo hcitool lescan
Set scan parameters failed: Input/output error
[17:35:31] openhabian@ohdata:~$

I’m using a new Raspi3 with clean openhabian-install and nothing else.

Is there a way to block all the unwanted MAC-adresses?

(The miflora/$announce message works nearly every 5 minutes)

Hello, just to let you know, I tried to install the Daemon directly from openhabian, with the optional component installation, but it didn’t work (something wrong with the colorama module in python).
for more details, see below

Thank you

HI all,

the miflora service stopped working with the upgrade to openhabian 2.3 any idea what to do?

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-05-31 22:24:00] Connecting to MQTT broker ...
[2018-05-31 22:24:00] MQTT connection established

Adding sensor to device list and testing connection ...
Name:          "Glueckskastanie"

and

sudo systemctl status miflora.service 
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
   Loaded: loaded (/etc/systemd/system/miflora.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-05-31 22:25:41 CEST; 2s ago
     Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
 Main PID: 22458 (python3)
   Status: "May 31 22:25:40 - MQTT connection established."
   CGroup: /system.slice/miflora.service
           ├─ 3467 gatttool --device=C4:7C:8D:66:44:DB --char-read -a 0x38 --adapter=hci0
           ├─22458 python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py
           ├─22467 /bin/sh -c gatttool --device=C4:7C:8D:66:44:D5 --char-read -a 0x38 --adapter=hci0
           └─22468 gatttool --device=C4:7C:8D:66:44:D5 --char-read -a 0x38 --adapter=hci0

May 31 22:25:40 openHABianPi systemd[1]: Starting Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon...
May 31 22:25:41 openHABianPi systemd[1]: Started Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.

Excited to get this up and going. Want to use it in our greenhouse. Will be quite awesome to keep track of the state of our seedlings. I have two that I have used for some time on the android app but want to integrate into openhab. Having issues right off the bat though.

I’m on OH2.3 and raspi. Installed Bluez per the instructions. Checked I have version 5.43 running. When I run

sudo hcitool lescan

I get Set scan parameters failed: Input/output error. Did some reading but could not overcome that. Found an article here that uses the bluetoothctl to search for bluetooth. That worked in a sense. It finds the controller and says searching but never finds the sensor even though its right by the raspi. I have connect the sensor to my phone and it has the latest version of the plant care software running on it.

Thoughts on how to get them connected? Sounds like most people on here it just connects.

thanks!

Just be aware that the light detection freaks out if placed outside in sunshine…

Same problem here after the upgrade to 2.3… Before it worked so this must be a problem of the new version…

Hmm interestingly it works again today! I did not do anything… and the hcitool lescan works as well… maaagic! :slight_smile:

Unfortunately my status does not show how many missed connection retries have been going on:

sudo systemctl status miflora.service
[sudo] password for openhabian:
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-06-02 00:34:49 CEST; 25s ago
Docs: GitHub - ThomDietrich/miflora-mqtt-daemon: Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼🥀🏡🌳
Main PID: 5265 (python3)
Status: “Jun 02 00:34:48 - MQTT connection established.”
CGroup: /system.slice/miflora.service
└─5265 python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py

Jun 02 00:34:48 openHABianPi systemd[1]: miflora.service: Service hold-off time over, scheduling restart.
Jun 02 00:34:48 openHABianPi systemd[1]: Stopped Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Jun 02 00:34:48 openHABianPi systemd[1]: Starting Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon…
Jun 02 00:34:49 openHABianPi systemd[1]: Started Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.

Any idea how I could get them? I cannot know at the moment wether the sensor is connected or not… :confused:

No one? :frowning: