Xiaomi Aqara devices and how they are managed in openhab

Hi all,

I have some questions on Xiaomi devices and OpenHab, I asked them in the big Xiaomi topic but did not get any answer, I fear it might have gone un-noticed, so I reask here.

Motion sensors from Xiaomi have the ability to report illumination or brightness, and I don’t see this info being reported in the available channels for motion sensors? I don’t see it either in the doc for Xiaomi Binding… Is there a reason for this?

Same for smoke detectors, I don’t see the channel for battery level and low battery appearing? Do I have a problem with my setup? And I don’t see either the “smoke density” and “ability to see in the smoke” info that are popping up in other plateforms for the same device…

What would be the right way for me to monitor the “reachability” or “aliveness” of a device? I just noticed that one of the Water leak sensors I have is out of reach and so basically is not connected to OH, and nothing mentioned it (it appears nicely “online” in the things list)…

Several channels seem to be mapped to a Switch type of item while I think they are more a read only info (e.g. LowBattery). Is this intentional or a mistake?

Thanks a lot for your attention,

For the illumination:

The documentation wasn’t yet upgraded. I think you have to switch to the 2.2.0 Snapshot binding if I recall correctly.

Hi @Simsal, thanks for sharing the info. I am on 2.2.0 snapshot binding, and the illumination thing did not show up in the UI:frowning:

I have added one extra item by means of text definition (on top of the other items for the other channels which I kept defined with Paper UI) and so far, nothing popped up in this channel.

Here are my thing & items file. Maybe this helps…

Thing mihome:sensor_motion_aq2:motion_sensor_aqara "Xiaomi Aqara Motion Sensor" @ "Xiaomi motion" [itemId="158d000xxxxxxx"]

Thing mihome:smoke:smoke_berging "Xiaomi Mijia Honeywell Fire Alarm Detector berging" @ "Xiaomi smoke" [itemId="158d000xxxxxxx"]

//Xiaomi Aqara Motion Sensor (with lux)
Switch Xiaomi_MotionSensorAqara_MotionStatus "Motion Status kelder [%s]" <motion> (Grp_Xiaomi_db) { channel="mihome:sensor_motion_aq2:motion_sensor_aqara:motion" }
// minimum 5 seconds - remember that the sensor only triggers every minute to save energy
Number Xiaomi_MotionSensorAqara_Illumination "Illumination kelder [%s]" <sun> (Grp_Xiaomi_db) { channel="mihome:sensor_motion_aq2:motion_sensor_aqara:illumination" }
Number Xiaomi_MotionSensorAqara_MotionOffTimer "Motion Off Timer kelder"  <clock> { channel="mihome:sensor_motion_aq2:motion_sensor_aqara:motionOffTimer" }
DateTime Xiaomi_MotionSensorAqara_LastMotion "Last Motion kelder [%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> (Grp_Xiaomi_db) { channel="mihome:sensor_motion_aq2:motion_sensor_aqara:lastMotion" }
Number Xiaomi_MotionSensorAqara_Battery "Battery level motion kelder" <battery> (Grp_Xiaomi_Chart_Battery) { channel="mihome:sensor_motion_aq2:motion_sensor_aqara:batteryLevel" }
Switch Xiaomi_MotionSensorAqara_BatteryLow "Low battery motion kelder" <energy> (Grp_Xiaomi_LowBattery) {channel="mihome:sensor_motion_aq2:motion_sensor_aqara:lowBattery" }

Xiaomi Mijia Honeywell Fire Alarm Detector
Number Xiaomi_SmokeDetector_berging_Density "Density smoke berging [%s]" <fire> (Grp_Xiaomi_db) { channel="mihome:smoke:smoke_berging:density" }
Switch Xiaomi_SmokeDetector_berging_Alarm "Alarm smoke berging [%s]" <fire> (Grp_Xiaomi_db) { channel="mihome:smoke:smoke_berging:alarm" }
String Xiaomi_SmokeDetector_berging_Status "Status smoke berging [%s]" <fire> (Grp_Xiaomi_db) { channel="mihome:smoke:smoke_berging:status" }
Number Xiaomi_SmokeDetector_berging_Battery "Battery level smoke berging" <battery> (Grp_Xiaomi_Chart_Battery) { channel="mihome:smoke:smoke_berging:batteryLevel" }
Switch Xiaomi_SmokeDetector_berging_BatteryLow "Low battery smoke berging" <energy> (Grp_Xiaomi_LowBattery) { channel="mihome:smoke:smoke_berging:lowBattery" }

@wars, @Simsal - great, thanks for the inputs.

I have understood the cause of my problem for the motion sensor : I first used the older version of the binding to discover my sensors and I missed the “_aq2” part… I noticed I had one item in the inbox that was waiting for my inclusion and now I understand what that was : version aq2 was popping up while I had version 1 declared, it seems… I have deleted the first one, and then created again clean first as a thing in PaperUI and then I declared the items in text file.

For the smoke sensor, I have added the items definition in my text file and we’ll see if that changes something.

I think I have other issues like this for other sensors, and I really need to find a way to move from PaperUI to text files while keeping names as much as possible…

Also, bear with me, some more questions :slight_smile:

  • what is the difference betwen “alarm” and “status” for the smoke detector?
  • also, what am I supposed to be able to do with stuff like “MotionOffTimer”? Am I supposed to be able to set it from opehab or is it a read only info that appears only when different from default?


The MotionOffTimer is a value you can define, when the motion sensor sends his MotionDetected = false;

I think the standard behaviour ist that it recognizes a movement ->MotionDetected =true then it goes to sleep for 60 seconds and waits another 60 seconds if concurrent motion occurs. These second 60 seconds can be increased or decreased with the MotionOffTimer value.

1 Like

Thanks @Simsal for the answer on MotionOffTimer. This is what I had understood, but I can’t get basic UI to show me an interface to set this timer… How should I do this? What is the way I have to configure the item and the sitemap to be able to set this value and send it to the device?


I setup the MotionOffTimer via a rule:

rule "Xiaomi default values"
System started
sendCommand(Xiaomi_Gateway_Sound, 10000) // set sound to stop
sendCommand(Xiaomi_Gateway_SoundVolume, 0) // set volume to zero / off

Regarding the smoke sensor:
alarm is set to ON when smoke is detected. So I use this item in my rules to notify myself when something is wrong.
status … I actually don’t know :slight_smile: It says unknown in my config. I was not able to receive another output yet.

Ahhh! Got it! Thanks a lot! Very clear. Yes, for me as well, alarm is set to ON when there is smoke detected, and status is set to unknown…

I looked a bit for the “status” of the smoke detector and I see that other platforms have a concept of “optical sensor visibility” in % in addition to the smoke density, not sure if this helps… I’ll keep checking this just in case I could find the explanation of what this is about.


I am now able to set the timers on the devices like you suggested, this is great. Thanks a lot.

There are things that are not very clear to me, still:

For door sensors, how is the isOpenAlarm concept supposed to work within openHab?

I have tried to declare an Item for this, which I try to display as a switch but it never gets updated and i get is a line in the trace like this:

2017-11-18 10:57:42.025 [vent.ChannelTriggeredEvent] - mihome:sensor_magnet_aq2:158d0001ab429f:isOpenAlarm triggered ALARM

And I read in the doc http://docs.openhab.org/addons/bindings/mihome/readme.html that the example for a rule taking into account this alarm is not using an Item change but rather a channel:

when Channel "mihome:sensor_magnet:<ID>:isOpenAlarm" triggered ALARM

I’m not too sure if my problem is that I’m not able to connect the isOpenAlarm channel properly to an Item or if it is not supposed to be ever connected to an Item and it should be a channel and be handled as such???
A bit lost, at this stage :slight_smile:

where do you find isOpenAlarm (I see that this is used in the rules examples, but this seems to be incorrect)? There are 5 channels for the door sensors:

  • isOpen: reports OPEN or CLOSED
  • lastOpened: reports date/time when magnet was last opened
  • isOpenAlarmTimer: can’t remember exactly how or why this is used…
  • batteryLevel: battery level in %
  • lowBattery: switches to ON when batteryLevel is 10% or less

Contact Xiaomi_Magnet_garage_IsOpen “Open status garage magnet [%s]” (Grp_Xiaomi_db) { channel=“mihome:sensor_magnet:magnet_garage:isOpen” }
DateTime Xiaomi_Magnet_garage_LastOpened “Last opened garage magnet [%1$td.%1$tm.%1$tY %1$tH:%1$tM]” (Grp_Xiaomi_db) { channel=“mihome:sensor_magnet:magnet_garage:lastOpened” }
Number Xiaomi_Magnet_garage_AlarmTimer “Alarm timer garage magnet” { channel=“mihome:sensor_magnet:magnet_garage:isOpenAlarmTimer” }
Number Xiaomi_Magnet_garage_Battery “Battery level garage magnet” (Grp_Xiaomi_Chart_Battery) { channel=“mihome:sensor_magnet:magnet_garage:batteryLevel” }
Switch Xiaomi_Magnet_garage_BatteryLow “Low battery garage magnet” (Grp_Xiaomi_LowBattery) { channel=“mihome:sensor_magnet:magnet_garage:lowBattery” }

@wars, good question:-) I’m almost sure that it got created by openHab when I was declaring the things and items via paperUI.

But also, i think that this isOpenAlarm is the logical complement of the isOpenAlarmTimer and my tests showed it works as follows: set isOpenAlarmTimer to 120 seconds, then open the door, isOpen goes to ON and then if you don’t close the door for the next 120 seconds, an alarm is raised as I described.
The intent looks clear to me, what is less clear is how openHab manages it:slight_smile:

If you can test it on your side, we’d know if I’m dreaming or if there is something missing…


I saw in the binding code on github some explanations regarding the status:
ALARM_STATUS_MAP.put(1, "Fire alarm");
ALARM_STATUS_MAP.put(2, "Analog alarm");
ALARM_STATUS_MAP.put(8, "Battery fault alarm");
ALARM_STATUS_MAP.put(64, "Sensitivity fault alarm");
ALARM_STATUS_MAP.put(32768, "I2C communication failure");

It seems that the smoke sensors is not returning one of the numbers above…

same with mine. The Status never gets updated, as I see it.

Another Thing is “density” The smoke sensor sometimes Returns density with “1”, most times it’s “0”. is there a known Scala or what does density stand for?

I tested the density with some smoke and then it changed to 256, when the smoke was gone , it went back to 1 (never 0)

Hi there,

I’ve just added a few Aqara motion sensors v2 to my Openhab setup and I find the illumination values to be outdated. I am still not quite sure what is going on under the hood, but I have an impression that the illumination value is only updated in case of motion is detected.

I’ve done the following test:

  • entering the room, lights go on, luminosity is updated to some high value
  • leaving the room, the lights go off and the luminosity is expected around zero (since it is night and no lights)
  • monitoring the luminosity value and seeing its not getting any changes for a couple of minutes.
  • entering the room again and seeing the luminosity gets updated.

I wonder if anyone else is experiencing similar behaviour?

nope, I find the updates quite sensible:

legend: I use the Motion sensor in a remote place and I can’t see a difference between people in the room and moving (friday night till sunday noon) and an empty cottage. (despite the obvious use of lights in the after hours)…
obviously the weekend was very sunny - monday was cloudy…

But what I experience: the updates the Aqara-sensors do aren’t quite regularly like every 10mins or so, they seem do depent on other influences - so best would be to wait like an hour or so, usually they come at least evey 20mins…

after quite some more time and stumbling over this old thread: I experience more varianzes for the smoke sensor… usually the sensor tells something between 1 and 4, sometimes 8. Except, if you’re cooking bacon - then the firealarm triggers obviously like Saturday evening:

I wonder if it is possible to configure the update interval. Probably poll Xiaomi from openhab every second minute.