Xiaomi Aqara Human Sensor PIR w. LUX - Things / Items

Hi, you can find the channel name in your mi Home app, and install it that way, thought your item files.
Good luck :smiley:

Works fine i forgot to add _aq2 on things file (I only changed .items !).
so snapshot is ok on 2.1 core.

my example for reschedule light:

Item:

Switch SensorMovimiento_MotionStatus_G_Color   "Activo"  <motion>  (gMovimiento, gGraficos)  { channel="mihome:sensor_motion_aq2:158d0001660f9f:motion" }
// minimum 5 seconds - remember that the sensor only triggers every minute to save energy
Text SensorMovimiento_illumination_G_Color "Iluminacion (lx)" <sun>  (gSalon)   { channel="mihome:sensor_motion_aq2:158d0001660f9f:illumination" }
DateTime SensorMovimiento_LastMotion_G_Color "Ultima Actividad [%1$td-%1$tm  %1$tH:%1$tM]" <time-on>  (gSalon)  { channel="mihome:sensor_motion_aq2:158d0001660f9f:lastMotion" }

Rule:
var Timer vTimerColor = null

rule "Luces ambiente Color ON 10 minutos" when
    Item SensorMovimiento_LastMotion_G_Color changed
then
    if (vTimerColor == null) {
        sendCommand(Luz1_G_Color, ON)
        sendCommand(Luz2_G_Color, ON)
        logInfo("notification.rules", "creo timer Color")
        vTimerColor = createTimer(now.plusMinutes(10)) [|
            logInfo("notification.rules", "termina timer Color")
            sendCommand(Luz1_G_Color, OFF)
            sendCommand(Luz2_G_Color, OFF) ]
    } else {
            logInfo("notification.rules", "reschedule Luz Color" + now.plusMinutes(5))
            vTimerColor.reschedule(now.plusMinutes(5))
    }
end

rule "Cancelo timer Color" when
    Item Luz1_G_Color received command OFF
then
    if (vTimerColor != null) {
        logInfo("notification.rules", "cancelo timer Luz Color")
        vTimerColor.cancel
        vTimerColor = null
    }
end

Thanks for posting the example, but it will be a lot easier to read if you use code fences:

```
code goes here
```

please check now, I corrected this.
Thanks!

I am currently trying to implement a rule that they only turn on when the illumination is below the value 50 but I can not seem to get it to work.

Without my if case the light is turning on normally as it should when motion is detected but with the if case it does not get triggered, where is my mistake?

rule "Archiv Motion Trigger"
when
    Item XAMSArchiv1_MotionStatus changed to ON or Item XAMSArchiv2_MotionStatus changed to ON 
then
	if(XAMSArchiv1_Illumination <=50 || XAMSArchiv2_Illumination <=50)
	{
		ArchivLicht.sendCommand(ON)
	}
end

When i have this rule set and walk into the room this is shown in the log:

2018-02-09 17:51:17.116 [vent.ItemStateChangedEvent] - XAMSArchiv1_Illumination changed from 12 to 0
2018-02-09 17:51:17.128 [vent.ItemStateChangedEvent] - XAMSArchiv1_MotionStatus changed from OFF to ON
2018-02-09 17:51:19.919 [vent.ItemStateChangedEvent] - XAMSArchiv2_Illumination changed from 6 to 4
2018-02-09 17:51:19.932 [vent.ItemStateChangedEvent] - XAMSArchiv2_MotionStatus changed from OFF to ON
2018-02-09 17:51:28.242 [vent.ItemStateChangedEvent] - XAMSArchiv1_Illumination changed from 0 to 3
2018-02-09 17:51:33.452 [vent.ItemStateChangedEvent] - XAMSArchiv1_Illumination changed from 3 to 0

Hey @salexes,

My rule is about the same, but it works without any problems :).

//Room 1

rule "RoomName Xiaomi Motion Sensor LUX"
when
    Item RoomName_MotionSensorLux_MotionStatus changed
then
    if (RoomName_MotionSensorLux_Illumination.state < 70 && RoomName_MotionSensorLux_MotionStatus.state == ON ) {
        RoomName_MotionSensorLux_MotionTimer.sendCommand(300)
        RoomName_LEDs_switch.sendCommand(ON)
    } else if (RoomName_MotionSensorLux_MotionStatus.state == OFF && SW_Spot.state == OFF ) {
        RoomName_LEDs_switch.sendCommand(OFF)
    }
end

So I would try to use the .state at the end of the illumination - maybe that could trigger the rest?

1 Like

Using .state works! Thanks a lot for the hint/tip!

Hello, where I can download lastest 2.2 version of Mi Home Bindings?
I have OH 2.2 and 2.2.0.201707150819 │ Xiaomi Mi Smart Home Binding and Aqara Motion doesn’t works for me :frowning:

OH 2.2 has been released and there have been no updates to it since the release. If there have been additions to the binding since then, you will need to upgrade OH to 2.3 SNAPSHOT or wait for the 2.3 release.

Theoretically you might be able to run the 2.3 SNAPSHOT version of the binding on OH 2.2, but that is not always guaranteed to work because of changes made to the core that could make the binding no longer backwards compatible. I recommend upgrading the whole OH.

hey guys,

question about the xiaomi motions sensors and openhab:

currently I use philips hue motion. my main problem: I cannot detect motion instantly and fire a rule (e.g. to turn the light on) as the hue motion sensors are (today) supported via the http binding which fetch the motion state like every 3000ms.

How does it work with xiaomi? when I enter the room, can openhab “instantly” turn on the light?

Stefan

Hi Stefan,

Yes you can. I use the Xiaomi Motion Sensors (Aqara) all over the house. When it triggers my light turns on instantly. I’m using it both on WiFi LED and also IKEA Smart Bulbs and if works like a charm.

Awesome! but you’ll need each of the systems own gateway, like tradfri gateway for ikea and of course the xiaomi gateway, right?

btw: any idea what’s the difference between xiaomi motion sensor and the xiaomi aqara motion sensor?

I have both of them.

The Motion Sensor only detects movements, where the Aqara has a LUX sensor as well. I use that to determine whether the light should be turned on, in case that the daylight should be more than enough (especially for the outdoor light).

Yeah unfortunately. But you should be able to use the Philips HUE lights that you already got. This is just a matter of getting the XIAOMI equipment and then tell the rule to trigger the HUE light when Motions is detected :slight_smile:

1 Like

thanks, ordered the gateway and a motion sensor :slight_smile:

Sounds good :slight_smile:
I’m about to order a few more as well and also their flower units so my better half can control her things in the greenhouse. I really love the products. Really good build quality / small and nice looking.

mine arrived. would highy appreciate if you could have a look over here (see below)
Btw: I am still unsure if it’s possible to frequently poll the illumination value (like every 30s). At the moment I assume that I need to check first if the motionstatus has been turned on, followed by checking the illumination value (which will be updated at the same time the switch turned ON). Not sure if this will lead to problems.

Well, I’m not 100% sure, but I don’t think you can change the value to below 60s. At least that’s what I have learned so far.

When I trigger my LED’s to turn on I meassure both on the MotionDetection is ON and if thats the case then I also measure how much Illumination that is present. If the value is greater than what I’ve set, then the light shouldn’t turn on, but if it is less, then it should. Of course if the Light suddenly drops dramatically - then I will have to wait at least 60s. In my case I only trigger this every 5 minutes, because I don’t want the light to turn off while I’m in the middle of something. This is just in one room. Other rooms are modified for “motion” behaviour which of course is different from room to room.

thanks, so the hint in the documentation (that MotionOffTimer can be set to 5s) doesn’t really make sense.

I’m not sure about that - haven’t tested it :slight_smile: