OpenHAB 2 and Xiaomi MiHome Temperature & Humidity Sensor - Sensor Offline but Thing is online


I have I Xiaomi Gateway and two Temp and Hum sensor with pressure (V2).

Configuration like this:

Bridge mihome:bridge:7811dcb7e00d "Xiaomi Gateway" @ "Xiaomi" [ serialNumber="7811dcb7e00d", ipAddress="XXXXXXXXXX", port=9898, key="XXXXXXXX", pollingInterval=6000 ] {
   Thing mihome:gateway:7811dcb7e00d "Xiaomi Mi Smart Home Gateway" @ "Xiaomi"  [itemId="7811dcb7e00d"]
   Thing mihome:sensor_weather_v1:158d0001f508a6 "Xiaomi Aqara Temperature, Humidity & Pressure Sensor TH1" @ "Xiaomi" [itemId="158d0001f508a6"]
   Thing mihome:sensor_weather_v1:158d0001fa5b23 "Xiaomi Aqara Temperature, Humidity & Pressure Sensor TH2" @ "Xiaomi" [itemId="158d0001fa5b23"]

In Karaf console:

mihome:bridge:7811dcb7e00d (Type=Bridge, Status=ONLINE, Label=Xiaomi Gateway, Bridge=null)
mihome:gateway:7811dcb7e00d (Type=Thing, Status=ONLINE, Label=Xiaomi Mi Smart Home Gateway, Bridge=mihome:bridge:7811dcb7e00d)
mihome:sensor_weather_v1:158d0001f508a6 (Type=Thing, Status=ONLINE, Label=Xiaomi Aqara Temperature, Humidity & Pressure Sensor TH1, Bridge=mihome:bridge:7811dcb7e00d)
mihome:sensor_weather_v1:158d0001fa5b23 (Type=Thing, Status=ONLINE, Label=Xiaomi Aqara Temperature, Humidity & Pressure Sensor TH2, Bridge=mihome:bridge:7811dcb7e00d)

But from time to time I lose connection with one sensor. In the original mobile application MiHome, I see that the sensor is unavailable. But unfortunately in mihome binding thing is still online.

Where does the original application know that the sensor is unavailable and can you implement such functionality in mihome binding?

I use stable version of OpenHab2:

majherek@atom:~$ dpkg -l |grep openhab
ii  openhab2                                              2.2.0-1                                        all          openhab2
ii  openhab2-addons                                       2.2.0-1                                        all          openhab2-addons

openhab> feature:list |grep -i mihome
openhab-binding-mihome                      │ 2.2.0            │ x        │ Started     │ openhab-addons-2.2.0    │ Xiaomi Mi Smart Home Binding

Is there anything in the logs when the sensor “drops”?

Nothing in openhab.log, last update on 20:56 in events.log.

Can we see the logs, please?

There are logs and screen from Grafana: OH2 Logs
From one restart to another. Over 24h.

The sensor is TH2. Another -> TH1 is OK.

It is not the fisrt time.

You could implement a “watchdog”
You will need the expire binding
It looks like you get an update from the sensor every hour or so.

Switch TH2_watchdog { expire="1h05m" } //If ON the switch will go back to OFF after 1h5m
rule "TH2 changed"
    TH2 changed
    TH2_watchdog.sendCommand(ON) // resets the watchdog

rule "TH2 Watchdog"
    Item TH2_watchdog changed from ON to OFF
    // Do what you want if watchdog triggered
    logInfo("WARNING","TH2 OFFLINE")

It is only workaround.

In this way, there is no different between RF433 sensor and ZigBee sensor ;-(