Xiaomi Aqara devices and how they are managed in openhab

Hi everyone, sorry I missed this thread - I might have a couple of answers for you :slight_smile:

OpenAlarmTimer & NoMotionTimer:

To save battery the sensors only report events like “motion” or “opened”/“closed” when they happen. The rest of the time they sleep. The gateway then has a nice feature I discovered while looking at the raw message logs:
For motion sensors it reports, how long there was no movement → 120sec, 300sec, 600sec, 1800sec, 3600sec. Every time the gateway sends a message like “no_motion: 1800” - not the sensor (so it can stay asleep).
For Magnet sensors I actually don’t remember but I am sure it does the same, when the window is opened.

I thought it might be cooler if the user can choose the time instead of having fixed times. So I introduced the timer channels. For motion the timer controls, when the motion channel is switched to OFF - so everybody can have his own time period and also change it with rules - for example the timer can get longer and longer if motion is sensed more often.
The downside with values below 60sec is that the sensor stays asleep so it does not switch back to ON, if you set the timer to say 10sec and wave your hand in front of it. Thats why by default 120sec is set. Remember: You cannot configure the motion sensor with this value, just the binding.

For windows you have the same principle, but instead of switching the window to closed :laughing: an alarm channel is triggered. It is not linkable to an item as it’s just an event channel (to be used by rules).

The use case is: it’s winter and your wife has had a nice bath. Everything is cloudy in the bathroom so she opens the window but forgets about it. Now to the rescue, you have a rule: when it’s cold outside and the alarm is triggered, send by wife a message to shut the window :blush:

Battery levels:

All battery powered devices report the battery voltage every 60mins with a heartbeat message. It is converted to a value between 0 (2700mV) and 100% (3200mV). Of course when it’s cold the battery voltage drops, causing the level to drop as well. Also, when the value does not change, the log doesn’t show that anything was received (except in DEBUG or TRACE mode).
On OH restarts the gateway is polled by the binding once and retrieves the last battery and sensor values.

I am still waiting for any of my sensors to drain the battery, they all run on their first battery, some of them since more than two years. I set the 2700mV just by default, don’t know if it has to be higher or lower at the moment.

A good way of finding out when to replace the battery is actually when it died. If the binding doesn’t receive any heartbeat for 2 hours the then thing is set to OFFLINE. Try it out and put a temp sensor in a cooking pot with metal lid or any other metal case.
You can define a rule for things going offline and get notified - I would set up the rule as soon as the level gets low.

Smoke sensor status:

was included in the documentation for the sensor so I included it in the binding, don’t know when it shows :confused:
For my smoke sensor it also shows unknown all the time as well, even if I press the hardware button on it.

I didn’t find any better way to link a boolean state to items yet, so it’s intention. Any suggestions are appreciated - risking, that with an update of the binding many people will get angry because their automations fail :stuck_out_tongue:
But you’re right @thefathefa, there is no way to declare a switch as read only, a user can override a motion sensor in the sitemap. I actually don’t think it’s too bad though.

Thank you @dimalo for this explanation. Very useful.

As for the read only switches, I understand. I now simply put them in the sitemaps as Text, this way I don’t get the button.