Xiaomi Mi Plants Monitor Flower

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…

Interesting, I’m currently using the plantgateway on a separate Raspberry PI, which feels like a lot of overkill.

Maybe we can use a ESP32, it is similar to the ESP8266, but has BLE integrated.

I looked at, and like the PlantGateway, but when you look at what it’s actually doing, it is overkill to run it on a dedicated machine, even a Pi. This OpenMQTTGateway is capable of pulling in data from all kinds of radios, and rebroadcast it via MQTT, all running on an ESP8266 @ roughly $8.

Using a ESP32 might be an option, for the onboard BT, though (I haven’t looked closely at the ESP32), you might loose the ability to attach an external BT antenna, which helps with range dramatically. Also, without looking at the code, I’m not sure if the OpenMQTTGateway would run on the EPS32, at least without heavy modification. Might be worth a shot though…

1 Like

I use a Pi Zero W which is pretty cheap

Any idea how to use it to monitor outside plants ? :slight_smile:

The flora is only for indoor use.

1 Like

I’ve set up two Mi Flora sensors using a Pi Zero and Plantgateway.

The sensors are updating as expected, but I’ve also set up the two plants using the “Plant” component. What I see is that the status of these two are updated on what seems like a rather erratic schedule. It can take several hours/days until all sensors within each “Plant” is populated, even though the the separate MQTT sensors are reporting fine.

Right now one of my plants say the lux value is >2600, but that was maybe 6 hours ago. The correct value is 249. Which is shown when I click on the icon within the plant. See these images:

!
!

Is this lag in updating the plant component normal?

I’ve noticed the same behaviour.

I’ve added “force_update: true” to all the MQTT sensors, now things seem to update in a much more predictable way.

@aherbjornsen/@Molodax , I think there might be a few different things going on here.

Firstly, the brightness value on the card is the “max_brightness” value recorded over the course of the last few days since start-up and not the real time situation (i.e. defaults to max value seen over last 3 days). This was a new feature added by the Plant component author and lets you evaluate whether the light environment for the plant is overall too low. So when I added the Plant Card, I decided to show the max_brightness value. But it might be more intuitive to change it to be real-time and let the “red” colour coding flag that there is a problem. Appreciate any thoughts on improving that card.

Secondly, as you mention, setting “force_update” on the mqtt sensor will cause the card to update even if the underlying sensor’s value hasn’t changed which can help keep things consistent. It also makes the more-info graph more accurate reflection of history.

But recently I’ve noticed the card does not always populate all values at start-up (e.g. looks like your battery on the second card above has not been populated). If I go to the RPi and run the plantgateway program manually then the plant card will fill in as the new mqtt messages are received. What should be happening at start-up is that the mqtt sensor gets initialised based on the last message retained by the mqtt broker and that gets propagated onto the Plant component. But, on occasion, some messages seem never to arrive at the plant entity. I am trying to find out what causes this as I have only been noticing it since going to release 0.63 and changing my mqtt broker server. I am curious if you or others are regularly seeing this at start-up?

Thanks for the detailed answer. I figured out the “max_brightness” thing myself after looking in the code. The current solution is IMHO not good, and what you suggest (showing real-time value indicating with red if a past value exceed “max_brightness”) is much better.

I’ve also noticed the problems with auto populate at startup. Last time i restarted, one of my plants was fully populated, the other one has only conductivity filled in. It’s not a very big deal, but if you’re able to fix it that would be great.

I can support @aherbjornsen in opinion that it’s not the best choice to show “max brightness”, it was very confusing for me (I didn’t look into the code). Moreover, in my case it is not informative at all since the weather is very shifting here, so 15 minutes of sun shine do not reflect the overall light environment. Real-time data is much better.

I have the same problem.
Now my plant sensor have 63075 lux :wink:
But miflora sensor have 10807 lux

Hi @PeteB, do you plan to change the “max_brightness” to the current one or keep as is?

I think the real-time value is more intuitive to display. We would still use max_brightness to register a problem and highlight the value so that provides the linkage. Seems this is common with a few people so I’ll make the change over the next week. Let me know if there is any other suggestions for improvement.

3 Likes

Somehow my sensors stopped working suddenly. Was working fine for months untill my sdcard crashed and I had to reinstall everything. After adding the 8th sensor, it worked for about 2 days and since then nothing at all. Not even when commenting out the last sensor.
sensors.yaml:

  - platform: miflora
    name: "Mi Flora 1"
    mac: 'C4:7C:8D:64:46:77'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 2"
    mac: 'C4:7C:8D:64:42:27'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 3"
    mac: 'C4:7C:8D:64:45:C7'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 4"
    mac: 'C4:7C:8D:64:45:D3'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 5"
    mac: 'C4:7C:8D:64:45:9C'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 6"
    mac: 'C4:7C:8D:65:BA:EB'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 7"
    mac: 'C4:7C:8D:65:BA:DB'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 8"
    mac: 'CC4:7C:8D:66:1E:6C'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery  

configuration.yaml:

plant:
  Yucca:
    sensors:
      moisture: sensor.mi_flora_1_moisture
      battery: sensor.mi_flora_1_battery
      temperature: sensor.mi_flora_1_temperature
      conductivity: sensor.mi_flora_1_conductivity
      brightness: sensor.mi_flora_1_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  tafel_links:
    sensors:
      moisture: sensor.mi_flora_2_moisture
      battery: sensor.mi_flora_2_battery
      temperature: sensor.mi_flora_2_temperature
      conductivity: sensor.mi_flora_2_conductivity
      brightness: sensor.mi_flora_2_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  tafel_rechts:
    sensors:
      moisture: sensor.mi_flora_3_moisture
      battery: sensor.mi_flora_3_battery
      temperature: sensor.mi_flora_3_temperature
      conductivity: sensor.mi_flora_3_conductivity
      brightness: sensor.mi_flora_3_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  vensterbank_links:
    sensors:
      moisture: sensor.mi_flora_4_moisture
      battery: sensor.mi_flora_4_battery
      temperature: sensor.mi_flora_4_temperature
      conductivity: sensor.mi_flora_4_conductivity
      brightness: sensor.mi_flora_4_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  vensterbank_rechts:
    sensors:
      moisture: sensor.mi_flora_5_moisture
      battery: sensor.mi_flora_5_battery
      temperature: sensor.mi_flora_5_temperature
      conductivity: sensor.mi_flora_5_conductivity
      brightness: sensor.mi_flora_5_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  dressoir_links:
    sensors:
      moisture: sensor.mi_flora_6_moisture
      battery: sensor.mi_flora_6_battery
      temperature: sensor.mi_flora_6_temperature
      conductivity: sensor.mi_flora_6_conductivity
      brightness: sensor.mi_flora_6_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  dressoir_rechts:
    sensors:
      moisture: sensor.mi_flora_7_moisture
      battery: sensor.mi_flora_7_battery
      temperature: sensor.mi_flora_7_temperature
      conductivity: sensor.mi_flora_7_conductivity
      brightness: sensor.mi_flora_7_light_intensity
    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15
  dwarf_umbrella:
    sensors:
      moisture: sensor.mi_flora_8_moisture
      battery: sensor.mi_flora_8_battery
      temperature: sensor.mi_flora_8_temperature
      conductivity: sensor.mi_flora_8_conductivity
      brightness: sensor.mi_flora_8_light_intensity
#    min_moisture: 22
#    max_moisture: 60
#    min_battery: 15
#    min_conductivity: 350
#    min_temperature: 15

log:

2018-03-24 10:26:00 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_5_battery is taking over 10 seconds
2018-03-24 10:26:30 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_5_conductivity is taking over 10 seconds
2018-03-24 10:27:01 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_1_battery is taking over 10 seconds
2018-03-24 10:27:31 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_7_conductivity is taking over 10 seconds
2018-03-24 10:28:02 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_2_conductivity is taking over 10 seconds
2018-03-24 10:28:32 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_6_temperature is taking over 10 seconds
2018-03-24 10:29:03 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_7_battery is taking over 10 seconds
2018-03-24 10:29:33 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_4_battery is taking over 10 seconds
2018-03-24 10:30:04 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_3_conductivity is taking over 10 seconds
2018-03-24 10:30:35 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_4_light_intensity is taking over 10 seconds
2018-03-24 10:31:12 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_1_light_intensity is taking over 10 seconds
2018-03-24 10:31:43 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_5_battery is taking over 10 seconds
2018-03-24 10:32:13 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_4_battery is taking over 10 seconds
2018-03-24 10:32:44 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_1_battery is taking over 10 seconds
2018-03-24 10:33:14 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_7_temperature is taking over 10 seconds
2018-03-24 10:33:45 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_2_light_intensity is taking over 10 seconds
2018-03-24 10:34:15 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_3_battery is taking over 10 seconds
2018-03-24 10:34:46 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_6_light_intensity is taking over 10 seconds
2018-03-24 10:35:16 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_5_temperature is taking over 10 seconds
2018-03-24 10:35:47 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_3_conductivity is taking over 10 seconds
2018-03-24 10:36:18 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_4_light_intensity is taking over 10 seconds
2018-03-24 10:36:48 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_1_conductivity is taking over 10 seconds
2018-03-24 10:37:19 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_2_battery is taking over 10 seconds
2018-03-24 10:37:49 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_6_battery is taking over 10 seconds
2018-03-24 10:38:20 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_7_battery is taking over 10 seconds
2018-03-24 10:38:57 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_6_battery is taking over 10 seconds
2018-03-24 10:39:28 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_2_light_intensity is taking over 10 seconds
2018-03-24 10:39:58 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_5_battery is taking over 10 seconds
2018-03-24 10:40:29 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mi_flora_6_moisture is taking over 10 seconds