Xiaomi Mi Plants Monitor Flower

Hey there,

im new to the Hassio community =)
My Mi Flora wont get any updates in the Hassio UI…, all values are 0 or unknow.

so first i added

  - platform: miflora
    mac: 'C4:7C:XX:XX:XX:XX'
    name: Pflanze1
    median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

to the configuration.yaml and restartet, so it showed up in the ui… no updates so far…
than i conneceted throu

gatttoool -b XX:XX:XX:XX:XX -I
connect
to the device:
so it retourned:

Connection successful

Notification handle = 0x0021 value: 00
Notification handle = 0x0021 value: 00
Notification handle = 0x0021 value: 00
[XX:XX:XX:XX:XX:XX][LE]>
(gatttool:6502): GLib-WARNING **: Invalid file descriptor.

it took about 4-5sek to spam the Notfication handle… and when i send the command Primary
i got

attr handle: 0x0001, end grp handle: 0x0009 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0022 uuid: 0000fe95-0000-1000-8000-00805f9b34fb
attr handle: 0x0023, end grp handle: 0x0030 uuid: 0000fef5-0000-1000-8000-00805f9b34fb
attr handle: 0x0031, end grp handle: 0x0039 uuid: 00001204-0000-1000-8000-00805f9b34fb
attr handle: 0x003a, end grp handle: 0x0042 uuid: 00001206-0000-1000-8000-00805f9b34fb

i enabled the debugmode for the MiFlora sensor and it post this errors in the log:

2017-10-10 11:13:25 DEBUG (SyncWorker_0) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Moisture
2017-10-10 11:13:25 INFO (SyncWorker_0) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_9) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Conductivity
2017-10-10 11:13:25 INFO (SyncWorker_9) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_11) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Light intensity
2017-10-10 11:13:25 INFO (SyncWorker_11) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_5) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Temperature
2017-10-10 11:13:25 INFO (SyncWorker_5) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Battery
2017-10-10 11:13:35 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.pflanze1_battery is taking over 10 seconds
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Pflanze1 Battery = 0
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Data collected: [0, 0, 0, 0]
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Median is: 0

so any one an idea how i could fix that?
thanks budys =)

miflora

I have the same problem as friend
Any idea ?

For several releases my logs are filled with

Updating miflora sensor took longer than the scheduled update interval 0:00:30

Although everything works and values are reported correctly - is there any remedy for this?

I’ve been using MiFlora component with 5 sensors. They worked more or less ok before. After upgrading my RPi3 to Stretch and Python 3.5 since HASS 0.55.x, the component doesn’t update sensors which are not close enough to the RPi3 (literally 1-2 meeters). I use integrated bt module on RPi3.

I’ve noticed this too! Must be linked to BT drives though?

I think you need gatttool to work Mi Flora. My system was missing it, so I compiled it. Mi Flora plant sensor

the gatttool binary is part of the bluez package:
a simple

apt-get install bluez

should do the trick

edit: if it is already installed:

apt-get install --reinstall bluez

Yes, gatttool is a part of bluez, but my system was missing it. Reinstall does not add gatttool in my case.

Then the easiest way to get gatttool would be to download the package, unpack it (it’s just a gzipped archive containing two more archives) and copy gatttool from there to /usr/bin
plus I would file a bug report that gatttool is not being installed when installing the bluez package, because if the maintainer doesn’t know, he can’t fix it.

edit: the linked package is for ARM hard float (suitable for e.g. raspis)

I dont get very good range with my sensor, probably only around 6 m through a wall.

Is there a way to boost the signal, such that the sensor can actually make it outdoors?

You could get a better BT adapter for the raspberry pi. Or you could get yourself a pi zero w, plug it in close to the outside wall and load it up with this:

1 Like

I plant to use an esp32 to do the bluetooth to mqtt and also control some of these.

Seems the most efficient solution, but requires alot of custom code ;p

Have you already coded this on esp32? I’m thinking of doing the same, but can’t figure ins and outs of Arduino ide ble esp32 examples.

When setting my sensors up I always used hcitool lescan to test the range. Since I have 2 of my Miflora sensors in my green house i had to do some testing before i found a good position for both sensors and receiving Pi3. So if lescan can find your sensor address then you’re good.
Otherwise, reposition.

I have about 30 m to my greenhouse but there are only windows in the way. It’s also a good idea to know where the antenna for Bluetooth is on your Pi3.

Also, since you have added a median to your sensor it will take 3 readings before a value is displayed in HA (FYI).

Another tip is to make sure the sensor is updated. You can do that with the Xiaomi plant app, but before any data can be read by HA it must be unpaired from the app.

I hope these tips help you.

Hey mate,
Na, still waiting for all my HW to arrive.
Will GIThub it up when it’s done.

Thank you! Finally had some time and set this up on a spare PiZero.
Working well!

Figured I’d chime in here, as I’ve got the same issue a lot of people are reporting: Updating miflora sensor took longer than the scheduled update interval 0:00:30
Last time I checked, I had 782 entries in my current log file, which is absurd IMO.

Found this awesome project called OpenMQTTGateway, which can be used for connecting lots of sensors to MQTT, via an ESP8266. I should mention, it also supports BT presence detection, 933mhz sensors, IR, and a plethora of other devices. It’s a great project, and the credit should go to the devs of said project.

Then I found this issue. Which (at the time of this writing) was committed 17 days later. Here’s a post by the dev, explaining how he implemented the Mi Flora sensor into the OpenMQTTGateway.

Long story short, the OpenMQTTGateway can now read the values from the Mi Flora sensors, and rebroadcast them via MQTT, which can then be pulled into HA; all running on an arduino platform (ESP8266).

For anyone who takes this route, please keep in mind, you’ll probably need to be familiar with programming and electronics; I wouldn’t recommend trying to implement this as your first Arduino project. Also, the firmware on the HM10/11 needs to be updated to at least v601 (This had me scratching my head for a bit). Instructions for this can be found here.

Hopefully this is a good alternative for a few of you (like myself) suffering from enormous, unnecessary log file entries caused by the above “sensor took longer than …” messages.

2 Likes

Has someone been able to pinpoint where to problem lies in this case? Is it that everyone is using raspbi with integrated bluetooth chipset, which breaks it? Or is the problem somewhere in homeassistant / some library used to communicate with these devices?

Did you get it to work? Flic and mi flora?
I’m having the same issue I think… but on hassio with flic add-on.

No, I gave up… So now I only run Flic, skipped the flower sensor. What about Hassio, flic works well there? :slight_smile: Might migrate from Hassbian soon…