Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon

Ok, The errors are ok, because we didi something wrong :-). Change the script as shown below.

rule "Check Plant Status"
when
   // Time cron "0 0 * ? * *" //every Hour
     Item testswitch changed to ON
then

    logInfo("Debugging", "Plant status update started")
    PlantThings.members.forEach[ Plants |
    logInfo("Debugging", "{}", Plants.name.toString)
        var ActualMoisture = PlantMoisture.members.filter[ pm | pm.name == Plants.name+"_Moisture"].head.state as DecimalType
        var ActualConductivity = PlantConductivity.members.filter[ pm | pm.name == Plants.name+"_Conductivity"].head.state as DecimalType
        var ActualStatus = 0
        logInfo("Debugging", "Moisture: {}; Conductivity: {}", ActualMoisture, ActualConductivity)
        if (ActualMoisture <= PlantDataMap.get(Plants.name+"_Moisture_Min")) {

            ActualStatus = ActualStatus + 1
        }
...

We should now se a line with “Plant status update started” and then more line with the plant names.

Adding the map was pretty good and how many plants are in the system?

Hi Thomas,

At the moment i have 1 plant. i am ready to add more however i wanted a working baseline before moving ahead.

I changed the script accordingly and now i am getting below messages

2020-01-23 19:59:38.264 [INFO ] [pse.smarthome.model.script.Debugging] - Plant status update started

2020-01-23 19:59:38.271 [INFO ] [pse.smarthome.model.script.Debugging] - PlantMonitoring

2020-01-23 19:59:38.283 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Check Plant Status': cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.items.Item.getState() on null

HM, not so easy to find the problem. Ti find the problem i would suggest to minimize the rule by commenting out everything that is not needed. Our goal is to make the foreach loop running and then fill it with more code step by step.

Should look like this

rule "Check Plant Status"
when
Item testswitch changed to ON
then
 
    logInfo("Debugging", "Plant status update started")   
    PlantThings.members.forEach[ Plant |
    
        logInfo("Debugging", "{}", Plant.name.toString)
    
    ]

end

Another option is too comment the whole rule and use this snippet as a new one

Okay, i feel we are getting further.

i made some changes on several spots. first, i added the planthings group to the .items file. This was a hunch because i read somewhere that group hierarchy isn’t implicit. i also added a second plant for testing purposes.
so my items now looks like this:

Group FernBlueStar "Fern Blue Star livingroom" <weather_pollen> (Plants)
        
DateTime    FernBlueStar_Brightness     "Last update time Fern Blue Star [%1$ta %1$tR]" <time>          (FernBlueStar)                      {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.timestamp)]"}
Number      FernBlueStar_Brightness     "Light Intensity Fern Blue Star [%d Lux]"       <light>         (FernBlueStar, PlantBrightness, PlantThings)     {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.light)]"}
Number      FernBlueStar_Temperature    "Temperature Fern Blue Star [%.1f °C]"          <temperature>   (FernBlueStar, PlantTemperature, PlantThings)    {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.temperature)]"}
Number      FernBlueStar_Conductivity   "Soil Fertility Fern Blue Star [%d µS/cm]"      <lawnmower>     (FernBlueStar, PlantConductivity, PlantThings)   {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.conductivity)]"}
Number      FernBlueStar_Moisture       "Soil Moisture Fern Blue Star [%d %%]"          <rain>          (FernBlueStar, PlantMoisture, PlantThings)       {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.moisture)]"}
Number      FernBlueStar_BatteryLevel   "Battery level Fern Blue Star [%d %%]"          <battery>       (FernBlueStar, BatteryLevel, PlantThings)        {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.battery)]"}
Switch      FernBlueStar_Battery        "Battery Fern Blue Star [MAP(battery.map):%s]"  <battery>       (FernBlueStar, Batteries, PlantThings)           {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JS(battery2switch.js)]"}
Number      FernBlueStar_Status         "Fern Blue Star [MAP(plantstatus.map):%s]"      <status>        (FernBlueStar, PlantStatus, PlantThings)

after i have done that i used the follow rule file to test:

rule "Check Plant Status"
when
Item testswitch changed to ON
then
 
    logInfo("Debugging", "Plant status update started")   
    PlantThings.members.forEach[ Plants |
    
        logInfo("Debugging", "{}", Plants.name.toString)
    

//	var ActualMoisture = PlantMoisture.members.filter[ pm | pm.name == Plants.name+"_Moisture"].head.state as DecimalType
//        var ActualConductivity = PlantConductivity.members.filter[ pm | pm.name == Plants.name+"_Conductivity"].head.state as DecimalType
//        var ActualStatus = 0
//        logInfo("Debugging", "Moisture: {}; Conductivity: {}", ActualMoisture, ActualConductivity)
    ]

end

now runing the rules gives the follow log result:

2020-01-24 09:38:22.886 [INFO ] [pse.smarthome.model.script.Debugging] - Plant status update started

2020-01-24 09:38:22.893 [INFO ] [pse.smarthome.model.script.Debugging] - PlantMonitoring

2020-01-24 09:38:22.898 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Brightness

2020-01-24 09:38:22.903 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Temperature

2020-01-24 09:38:22.908 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Conductivity

2020-01-24 09:38:22.913 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Moisture

2020-01-24 09:38:22.918 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_BatteryLevel

2020-01-24 09:38:22.924 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Battery

2020-01-24 09:38:22.928 [INFO ] [pse.smarthome.model.script.Debugging] - FernBlueStar_Status

2020-01-24 09:38:22.933 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Brightness

2020-01-24 09:38:22.937 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Temperature

2020-01-24 09:38:22.942 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Conductivity

2020-01-24 09:38:22.947 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Moisture

2020-01-24 09:38:22.953 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_BatteryLevel

2020-01-24 09:38:22.958 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Battery

2020-01-24 09:38:22.962 [INFO ] [pse.smarthome.model.script.Debugging] - plant2_Status

I think this is what we should expect.

theni adjusted the rule file so one var is declared with the debug rule which i think should show that var.
.rule now looks like this:

rule "Check Plant Status"
when
Item testswitch changed to ON
then
 
    logInfo("Debugging", "Plant status update started")   
    PlantThings.members.forEach[ Plants |
    
        logInfo("Debugging", "{}", Plants.name.toString)
    

	var ActualMoisture = PlantMoisture.members.filter[ pm | pm.name == Plants.name+"_Moisture"].head.state as DecimalType
//        var ActualConductivity = PlantConductivity.members.filter[ pm | pm.name == Plants.name+"_Conductivity"].head.state as DecimalType
//        var ActualStatus = 0
        logInfo("Debugging", "Moisture: {}; Conductivity: {}", ActualMoisture, ActualConductivity)
    ]

end

running the rule like this gives an log error:

2020-01-24 09:41:26.769 [INFO ] [pse.smarthome.model.script.Debugging] - Plant status update started

2020-01-24 09:41:26.775 [INFO ] [pse.smarthome.model.script.Debugging] - PlantMonitoring

2020-01-24 09:41:26.789 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Check Plant Status': cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.items.Item.getState() on null

So somehow the debugging doens’t show the plantsthings anymore and throws a new error.

one step further but not there :slight_smile:

Ok, the idea is iterate trough all plants, take the specific data and calculate the status.

Your group and item structure is not correct at the moment. It should be like this


Group PlantThings "Group that contains all plants"
Group PlantStatus "Group that contains all status items"
Group PlantMoisture "Group that contains all moisture items"
Group PlantConductivity "Group that contains all conductivity items"


Group FernBlueStar "Fern Blue Star livingroom" <weather_pollen> (PlantThings)
    DateTime    FernBlueStar_LastUpdate     "Last update time Fern Blue Star [%1$ta %1$tR]" <time>          (FernBlueStar)                      {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.timestamp)]"}
    Number      FernBlueStar_Brightness     "Light Intensity Fern Blue Star [%d Lux]"       <light>         (FernBlueStar)     {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.light)]"}
    Number      FernBlueStar_Temperature    "Temperature Fern Blue Star [%.1f °C]"          <temperature>   (FernBlueStar)    {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.temperature)]"}
    Number      FernBlueStar_Conductivity   "Soil Fertility Fern Blue Star [%d µS/cm]"      <lawnmower>     (FernBlueStar, PlantConductivity)   {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.conductivity)]"}
    Number      FernBlueStar_Moisture       "Soil Moisture Fern Blue Star [%d %%]"          <rain>          (FernBlueStar, PlantMoisture)       {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.moisture)]"}
    Number      FernBlueStar_BatteryLevel   "Battery level Fern Blue Star [%d %%]"          <battery>       (FernBlueStar, BatteryLevel)        {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.battery)]"}
    Switch      FernBlueStar_Battery        "Battery Fern Blue Star [MAP(battery.map):%s]"  <battery>       (FernBlueStar, Batteries)           {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JS(battery2switch.js)]"}
    Number      FernBlueStar_Status         "Fern Blue Star [MAP(plantstatus.map):%s]"      <status>        (FernBlueStar, PlantStatus)

rule "Check Plant Status"
when
Item testswitch changed to ON
then
 
    logInfo("Debugging", "Plant status update started")   
    PlantThings.members.forEach[ Plant |
    
        logInfo("Debugging", "{}", Plant.name.toString)
    
    ]

end

The groupstrcuture is now as follows.

PlantThings contains all Groups the define a Plant like FernBlueStar and FernBlueStar contains all items that belong to that specific plant. The Moisture, status and conductivity group contain all items of the type.

Now our loop is able to iterate trough the plants.

Please try it

Hi Thomas,

Sorry for not coming back on this earlier but it took some time too test and understand everything that was happening.

What a victory :slight_smile: got it working like a charm now after some more step by step debugging. Your group layout pointed me to the right setup.

I think i also know where i went wrong.
1st - This might be a rookie mistake but…i used a group Plants in my group.items file. it seems that this group is not activated when its not called in the same file. dont really understand this but when i declared a group plants in the group file it was never populated eventhough the plant in the separate .items file was assigned to the plants group. The moment i declared the plants group in plants.items file it was populated with, in my case a FernBlueStar.
2nd - its maybe because of your different group setup ( ill have to look tat that later) but i changed the rule line:

PlantThings.members.forEach[ Plants |

To

Plants.members.forEach[ Plants |

The plantthings wasn’t populated with the plantnames which as a result wouldn’t construct a proper, lets call it look up name, for the plant in conjunction with the measure. Result: it wouldn’t return a value .
For other who want to set this up:
my rule now looks like this:


rule "Check Plant Status"
when
Item testswitch changed to ON
//Time cron "0 0/30 * 1/1 * ? *" //every half hour
then
 
    logInfo("Debugging", "Plant status update started")   
    Plants.members.forEach[ Plants |
    
        logInfo("Debugging 1", "{}", Plants.name)
    
		var nametest = Plants.name+"_Moisture" 
		var ActualMoisture = PlantMoisture.members.filter[ pm | pm.name == Plants.name+"_Moisture" ].head.state as DecimalType
    	var ActualConductivity = PlantConductivity.members.filter[ pm | pm.name == Plants.name+"_Conductivity"].head.state as DecimalType
        var ActualStatus = 0

        logInfo("Debugging 2", "nametest: {}", nametest)
        logInfo("Debugging 3", "Moisture: {}", ActualMoisture)
		logInfo("Debugging", "Moisture: {}; Conductivity: {}", ActualMoisture, ActualConductivity)

        if (ActualMoisture <= PlantDataMap.get(Plants.name+"_Moisture_Min")) {

            ActualStatus = ActualStatus + 1
        }

        if (ActualMoisture > PlantDataMap.get(Plants.name+"_Moisture_Max")) {
            ActualStatus = ActualStatus + 4
        }

        if (ActualConductivity <= PlantDataMap.get(Plants.name+"_Conductivity_Min")) {
            ActualStatus = ActualStatus + 2
        }

        if (ActualConductivity > PlantDataMap.get(Plants.name+"_Conductivity_Max")) {
            ActualStatus = ActualStatus + 8
        }

        PlantStatus.members.filter[ pm | pm.name == Plants.name+"_Status"].head.postUpdate(ActualStatus)

        logInfo("rule.CheckPlantStatus", "Update status of {} to {}", Plants.name, transform("MAP", "plantstatus.map", ActualStatus.toString))

    ]

end

My plants.items now looks like this:

Group Plants

Group FernBlueStar "Fern Blue Star livingroom" <weather_pollen> (Plants)
        
DateTime    FernBlueStar_update         "Last update time Fern Blue Star [%1$ta %1$tR]" <time>          (FernBlueStar)                      {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.timestamp)]"}
Number      FernBlueStar_Brightness     "Light Intensity Fern Blue Star [%d Lux]"       <light>         (FernBlueStar)                      {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.light)]"}
Number      FernBlueStar_Temperature    "Temperature Fern Blue Star [%.1f °C]"          <temperature>   (FernBlueStar)                      {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.temperature)]"}
Number      FernBlueStar_Conductivity   "Soil Fertility Fern Blue Star [%d µS/cm]"      <lawnmower>     (FernBlueStar, PlantConductivity)   {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.conductivity)]"}
Number      FernBlueStar_Moisture       "Soil Moisture Fern Blue Star [%d %%]"          <rain>          (FernBlueStar, PlantMoisture)       {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.moisture)]"}
Number      FernBlueStar_BatteryLevel   "Battery level Fern Blue Star [%d %%]"          <battery>       (FernBlueStar, BatteryLevel)        {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JSONPATH($.battery)]"}
Switch      FernBlueStar_Battery        "Battery Fern Blue Star [MAP(battery.map):%s]"  <battery>       (FernBlueStar, Batteries)           {mqtt="<[mosquitto:miflora/Fern-Blue_Star:state:JS(battery2switch.js)]"}
Number      FernBlueStar_Status         "Status Fern Blue Star [MAP(plantstatus.map):%s]"      <status>        (FernBlueStar, PlantStatus)

and i have a separate group.items file that looks like this:

//Group Plants "plants" declared in Plants.items 
     Group PlantMonitoring "Monitoring"   
     Group PlantThings "Plants" <lawnmower> 
            Group PlantMoisture     "Soil Moisture" <rain> (PlantThings, PlantMonitoring)
            Group PlantConductivity "Soil Fertility" <lawnmower> (PlantThings, PlantMonitoring)
            Group PlantTemperature  "Temperature" <temperature> (PlantThings, PlantMonitoring)
            Group PlantBrightness   "Light Intensity" <light> (PlantMonitoring)
            Group PlantStatus       "Status" <weather_pollen> (PlantMonitoring)

Thomas, I really would like to thank you for helping with this. Its much appreciated. I see that i have still a lot to learn in Openhab but i feel that i’m getting there.

I think ill be able to continue building on this. My goal is to get a WAF solution that, based on this will sent out a notification which plants need attention.

2 Likes

I had the same problem as you, the openHAB items were not populated with the MQTT values. Eventually I switched to the homie standard and everything is working. As a side note, it did take a while before openHAB populated the first items.

NB. I’m using the fork with the temperature/humidty sensor support: https://github.com/MartinHaimberger/miflora-mqtt-daemon but that shouldn’t matter.

My config if you are interested:

config.ini

[General]

reporting_method = mqtt-homie
adapter = hci0

[Daemon]

[MQTT]
hostname = 10.0.0.153
port = 1883
keepalive = 60
username = miflora3
password = xxx
base_topic = homie
homie_device_id = mi_sensors

[MiFlora]

Olijfboom@Tuin          = C4:7C:8D:xxx
Lepelplant@Badkamer     = C4:7C:8D:xxx

[MiTempBt]

Woonkamer@Woonkamer     = 4C:65:A8:xxx
Slaapkamer@Slaapkamer   = 4C:65:A8:xxx
Badkamer@Badkamer       = 4C:65:A8:xxx

Things

Thing mqtt:topic:lepelplant "Lepelplant" (mqtt:broker:MosquittoMqttBroker) @ "Badkamer" {
        Channels:
            Type number : light         "Light Intensity"   [ stateTopic="homie/mi_sensors/Lepelplant/light" ]
            Type number : battery       "Battery Charge"    [ stateTopic="homie/mi_sensors/Lepelplant/battery" ]
            Type number : temperature   "Temperature"       [ stateTopic="homie/mi_sensors/Lepelplant/temperature" ]
            Type number : conductivity  "Soil Fertility"    [ stateTopic="homie/mi_sensors/Lepelplant/conductivity" ]
            Type number : moisture      "Soil Moisture"     [ stateTopic="homie/mi_sensors/Lepelplant/moisture" ]
    }

Items

Number:Illuminance		PlantLepelplant_Sunlight	"Light Intensity Lepelplant [%d lx]"	<light>			(gVirtueel, gPlantSunlight)			{ channel="mqtt:topic:lepelplant:light" }
Number:Dimensionless	PlantLepelplant_Battery		"Battery Lepelplant [%d %%]"			<battery>		(gBadkamer, gBatteries)				{ channel="mqtt:topic:lepelplant:battery" }
Number:Temperature		PlantLepelplant_Temperature	"Temperature Lepelplant [%.1f °C]"		<temperature>	(gVirtueel, gPlantTemperatures)		{ channel="mqtt:topic:lepelplant:temperature" }
Number					PlantLepelplant_Fertility	"Soil Fertility Lepelplant [%d µS/cm]"	<lawnmower>		(gVirtueel, gFertilities)			{ channel="mqtt:topic:lepelplant:conductivity" }
Number:Dimensionless	PlantLepelplant_Moisture	"Soil Moisture Lepelplant [%d %%]"		<humidity>		(gVirtueel, gMoistures)				{ channel="mqtt:topic:lepelplant:moisture" }
1 Like

I came around and tried getting rid of moquette and switching over to mosquitto, the connection from the daemon to the broker works now… but, there are a ton of other problems awaiting.

So i am currently running on the latest OH Version (i believe 2.51),
i tried utilizing the standard MQTT config in the MMiflora Daemon with the JSONPath transformation as described a lot in this topic.
Doesn’t work, i just don’t get any values out of my items, the most they show is a “NaN” or a Null,
now i tried the textual configuration as is described here, didn’t work.
As i don’t use .Item or .things file configuration anyhow i tried it through PaperUI, same result.
I tried every combination of the Json Path Conversion, tried the System Broker Thing, the Standard MQTT Broker thing, every other combination i could think of, doesn’t work.

I then gave the Homie Standard setting a shot, can’t get it to work either, no matter what i try i get an error: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: Did not receive mandatory topic value:
Apparently Version 3.00 which the binding speaks isn’t compatible with the Daemon.

Last Tryout i did was the HomeAssistant standard in the Daemon, and low an behold all the sudden my inbox automatically gets populated with all the Sensors. Theres only one caviat: The different channels contain the entire payload, and for some reason i can’t apply a Json Path transformation there in PaperUI… EDIT: Correction, i found the JSON in the Channel Link to the Item, now i can display the individual channels with minor correction in PaperUI

For all the people running this solution on here, are you all running on older OH versions so that you dont seem to have any issues? The hassle to get this running is so frustrating.

Btw, apparently my raspi also has an issue keeping the bluetooth connection stable, over night the adapter just crashed, wasn’t able to restart the service and had to restart the entire Pi to get it running,
found some other folks on the web with the same issue, went to the latest firmware, let’s see if that fixed it… EDIT: didn’t fix it, seems after 6-7 hours it just crashes… so not really impressed with the entire solution. too bad i bought 5 of these sensors

Given that my Aqara Sensor runs just fine, i am looking forward to a sensor with display and zigbee, seems there are a couple pushing in the market soon, blitzwolf seeming to be the first ones. Lets hope they’ll be as easy as the aqara ones in setup

I am wondering how you would solve the following challenge: My RasberryPi sits in the basement in a 19’’ rack, but my plant is 2 floors above, no way the bluetooth signal is strong enough, what would you recommend? Setting up a new Pi device just as a Gateway?

Welcome to the community!

I have done that with three raspberries all over my home. Currently i have 11 sensors on two floors. covered with three raspis. The version one or a zero are doing the job. They are conneted using wifi.

1 Like

If you have your stuff in a 19 inch rack, you likely have sufficient Cat.5/6 cabling as well in your house.
If so, you might consider a dumb USB-via-RJ45 extender pair like this:

https://de.aliexpress.com/item/32554187701.html

I’ve tried them successfully with aprx. 20 meter Cat.6 in between with Zigbee and Bluetooth dongles.

Nice and simple idea! I did not thought about it :slight_smile: will try that! Thanks.

Hi guys,

I’m working on a cloud Plants Database with API which I hope that can be useful for this integration.
At this stage, this database consists of temperature, light, soil moisture and fertility thresholds I found in open internet sources. It can be used with Xiaomi MiFlora plant sensor or any other sensor. It is also useful for different irrigation projects.

This is FREE service and it will always be free! Anyone can use information from the database for any purpose without permission.

It is intended to be community sourced and I see it as a GitHub for plant care recipes.

The purpose is to help the community with collecting and storing STRUCTURED information about plants care and potentially plants in general.

The service is in active development and it has already gone live so you can login https://open.plantbook.io , get API credentials and start using that. BTW, there is a social Single SignOn so you don’t even have to register.

The documentation is within Web UI and in GitHub (see below)

Currently, DB is read only so you can search plants and get their specific environmental/soil thresholds.

I will be adding sample clients to the below Github repo to give you an idea how to use the API.

https://github.com/slaxor505/OpenPlantbook-client

I’m honestly home-assistant user and as next step I will be building integration for home-assistant. Although, I’d love to build integration with OpenHab as well but it may take time for me as I’m not familiar with OpenHab so I’d be great if someone could help with this.

Roadmap:

  • Allow to add and update plants thresholds via WebUI
  • Ability to lodge request for specific plants information to be added to DB
  • Plant detection API from images
  • And many other ideas which are blowing my mind… :slight_smile:

Please take a look. Let me know what is working well and what is not working at all. Any thoughts and feedback will be much appreciated. I’m open to new feature requests and your ideas!

Slava

3 Likes

All,

with this binding I was able to connect to Miflora succussfully.
Thank you,
@ThomDietrich

I just have one issue (on OH3.0.1 on a Raspberry Pi4 8GB)
Sometimes I don’t get data and obviously the bluetooth service is the culprit:

sudo hcitool lescan
Set scan parameters failed: Input/output error

After a restart a scan works just fine, so does the python script.

Is this a known issue with BT on a Raspberry?

Hi All - wondering what sort of battery life others are seeing using the Mi Flora sensor with this Daemon.

I’ve had it set for 5 minute intervals - and started with a new battery, which was reporting 100%. It’s been 12 days, and the sensor is now reporting 11%.

Anyone else seeing such a short battery life with a similar polling interval?
Any other thoughts from the community?

Thanks

Never saw this fast reduction. My sensors last at least2-3 month (not measured).

But a scan interval of a hour or less should be enough.

Thanks - I’ve adjusted to an hour interval now. Will monitor and compare vs before.

After one of the firmware updates of the sensor I also noticed that the battery level got very inaccurate. It will drop to < 20% very quickly but the batteries will last for much longer after that.

Still, 5 minutes is probably very low as others have mentioned. Mine has problems reaching all sensors reliably because of the distance so I keep mine on 15 minutes in case it misses a few updates.

I also have this weird battery drops. Sometimes they are wildly different between readings and then it starts dropping over time, just to be stable for a longer time afterwards.

There’s now a fork of ESPresense (bluetooth based presense detection via ESP32s) that supports active polling of Mifloras and sending their data via MQTT in configurable intervals via the espresense ESP32, so one can use the same ESP32s for multiroom presense detection and connecting to the Mifloras across the house, circumventing range issues without additional hardware. You can configure which Mifloras to poll in the ESPresence UI so if a Miflora is in range of multiple ESP32s, it does not get polled from multiple sources.

For basic OpenHab/ESPresense integration, see, e.g. here Step-by-step presence detection with bluetooth tag (e.g., GTags) and ESPresense on ESP32 - #9 by simon20

ESPresense official: GitHub - ESPresense/ESPresense: An ESP32 based presence detection node for use with the Home Assistant mqtt_room component for localized device presence detection.

ESPresense fork with Miflora support: GitHub - 0Flush0/ESPresenseFlora: An Espresense fork that supports the MiFlora plant sensor

Not sure to what extent the fork will be maintained; and auto-updates will remove it, I guess. So, if you’d like to see this integrated in the ESPresense official releases, maybe add a comment to the relevant issue here: Feature implementation: Xiaomi Mi Flora plant sensor · Issue #720 · ESPresense/ESPresense · GitHub

2 Likes