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

Hey,

I’ve got some of the Xiaomi PIR sensors but I can’t find the things configuration nor the items. Is it not supported in Openhab 2.1?

If, could someone provide me with the things / Items and perhaps a sample of how they use it in a rule both motion and LUX?

Thanks!

The binding readme lists all the supported devices:

http://docs.openhab.org/addons/bindings/mihome/readme.html

It appears to be listed as supported:

Xiaomi Aqara Motion Sensor (with light intensity support)

There are example Things for that device further down in the readme.

See the Beginner’s Tutorial, the Items page and the Rules page in the docs for how to link a Thing’s channel to an Item and hot to use the Items in Rules.

@rlkoshak I’m sorry, but I can see it is listed but I can’t find the Aware PIR nor the item for that device? Only that it is supported?

Is it me that are totally blind here?

Thing mihome:sensor_motion:158d0001XXXXXX "Xiaomi Motion Sensor" [itemId="158d0001XXXXXX"]

// Xiaomi Motion Sensor
Switch MotionSensor_MotionStatus <motion> { channel="mihome:sensor_motion:<ID>:motion" } // minimum 5 seconds - remember that the sensor only triggers every minute to save energy
Number MotionSensor_MotionTimer <clock> { channel="mihome:sensor_motion:<ID>:motionOffTimer" }
DateTime MotionSensor_LastMotion "[%1$tY-%1$tm-%1$td %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_motion:<ID>:lastMotion" }
Number MotionSensor_Battery <battery> { channel="mihome:sensor_motion:<ID>:batteryLevel" }
Switch MotionSensor_BatteryLow <energy> { channel="mihome:sensor_motion:<ID>:lowBattery" }

@rlkoshak, thanks but isn’t that for the standard one? I do already have one normal Xiaomi OUT working with that things and items code, but the ones I have now are the ones with LUX light sensor built in (Aqara). I can’t see how the LUX should be determined in any of those items?

Hey @Yoinkz,

I’ve added support to the new motion sensor almost a month ago. See this file for example.
Make sure you’re on latest snapshot.

Is the sensor automatically discovered in your environment?

Your textual thing definition would look like this:

Thing mihome:sensor_motion_aq2:158d0001XXXXXX "Xiaomi Motion Sensor" [itemId="158d0001XXXXXX"]

And you’ll have a new illumination channel available:

Number MotionSensor_Illumination { channel="mihome:sensor_motion_aq2:<ID>:illumination" }

Hope that helps!
It would be worth to update the README file with those…

Cheers

Dear @kubawolanin,

Thanks - I will go ahead and update to the latest snapshot then.
Do you have a rule that triggers some sort of light when the Motion is detected and the LUX = XX ?

@Yoinkz

hey mate,

did your new sensors get discovered? I upgraded to 2.2 Snapshot, but they aren’t showing in my things.
Also i have configured them in my xiaomi.things:

Thing mihome:sensor_motion_aq2:158d00016dac36 "Badezimmer - Body Sensor" [itemId="158d00016dac36"]

and corresponding items:

Switch Badezimmer_MotionStatus <motion> { channel="mihome:sensor_motion_aq2:158d00016dac36:motion" }
and so on.

But neither do they show in paperui or in one of the log files.

@Simsal,

Hey…

Yes I did get it working after upgrading to the latest snapshot. Currently my sensors shows up just fine and so also work the way my rules are set.

Here is my current set up:

Things file:
//This is the Things file

//Xiaomi Mi Smart Home

Bridge mihome:bridge:34ce0088ed14 "Xiaomi Gateway" [ serialNumber="xxXXXxXXxxXX", ipAddress="xxx.xxx.xxx.xxx", port=9898, key="XxxxXxXxxxxXxxXxx", pollingInterval=6000 ] {

Thing mihome:sensor_motion_aq2:xxXXXxXXxxXX "Hobbyroom Xiaomi Motion Sensor LUX" [itemId="xxXXXxXXxxXX"] }

items file:
Switch Hobbyroom_MotionSensorLux_MotionStatus "Motion" <motion> (gHobbyroom,gHobbyroom_motion,gMotion,gLux) { channel="mihome:sensor_motion_aq2:xXXxXxXXxxXXXx:motion" }

So it looks pretty similiar?

Maybe a dumb question, but you did add the Aqara to your gateway through the MiHome app?

I’m on OH 2.1 and I need to manually install the Aqara motion sensors, I get the needed id’s from me xiaomi app, from the gateway -> bruger icon- > about -> gateway information

@Moellegaard

Hi Moellegaard,

Do you have some nice rules using your Aqara Motion PIR’s?

I use the Motion sensors, both original and auqa for light control at the moment, I made an switch item for each room and a rule that activates the motion sensor is triggered. The Item is only on for 10 min, which is a bit too short I think, by using the expire binding.
If it is dark and the “room item” is on then I will turn on the light. I also use the motion sensors for checking if somebody is home. If not I switch off most of the power (with xiaomi plugs) and turn down the temperature.
I can post some of the rules if you like.

@Moellegaard

Sounds really nice! What you mention is a lot of what I want to achieve. Currently my Motion Sensors register when I enter a room and the LUX is met. But in my case it turns off after I think 1 minute which might be the standard value where the motion sensor goes to sleep to save battery (not sure on this though). I was wondering if a sleep function would suite me if I wanted to postpone the lights from going off, but maybe I could get some clues from your rule.

Please post or PM. me some of yours, that would be much appreciated.

Items:
Switch KitchenLightActivity “KitchenLightActivity” { expire=“10m,command=OFF” }
Switch GangLightActivity “GangLightActivity” { expire=“10m,command=OFF” }
Switch SoveLightActivity “BedroomLightActivity” { expire=“10m,command=OFF” }
Switch StueLightActivity “StueLightActivity” { expire=“10m,command=OFF” }

Rules:

rule "HomeActivity turn - away off"
when
    
  Item HomeActivity changed
     
    then
    logInfo("rules", "HomeActivity changed")
    
    if (HomeActivity.state == ON) //ingen hjemme
     {
    AwaySwitch.sendCommand(OFF)
    }
    
    if (HomeActivity.state == OFF) //ingen hjemme
    {
      if (SwGoodNight.state == OFF) //If not sleeping then assum nobody is home
      {
      AwaySwitch.sendCommand(ON)
      }
    }    
         
end

rule "Turn on Motion_Sensor_Stue_Status if dark "
when
    Item Motion_Sensor_Stue_Status received update ON
then
      StueLightActivity.sendCommand(ON)
end

rule "Turn on Motion_Sensor_Kitchen_Status if dark "
when
    Item Motion_Sensor_Kitchen_Status received update ON
then
      KitchenLightActivity.sendCommand(ON)
end

rule "Turn on Motion_Sensor_Gang_Status if dark "
when
    Item Motion_Sensor_Gang_Status received update ON
then
      GangLightActivity.sendCommand(ON)
end

rule "Turn on Motion_Sensor_Sove_Status if dark "
when
    Item Motion_Sensor_Sove_Status received update ON
then
      SoveLightActivity.sendCommand(ON)
end

// Light controllers----------------
rule "Turn on Light in Stue if dark "
when
    Item StueLightActivity received update
then
  if(StueLightActivity.state == ON && IsDark_SW.state == ON && SwGoodNight.state != ON)
    {
      Color_Stue_LED.sendCommand(ON)
      Color_Kaempe.sendCommand(ON)
    }
  if(StueLightActivity.state == OFF && IsDark_SW.state == ON)  
    {
      Color_Stue_LED.sendCommand(OFF)
      Color_Kaempe.sendCommand(OFF)
    }
    
end

rule "Turn on Light in Kitchen if dark "
when
    Item KitchenLightActivity received update
then
  if(KitchenLightActivity.state == ON && IsDark_SW.state == ON && SwGoodNight.state != ON)
    {
      Color_Kokken.sendCommand(ON)
    
    }
  if(KitchenLightActivity.state == OFF && IsDark_SW.state == ON)  
    {
      Color_Kokken.sendCommand(OFF)      
    }
end

rule "Turn on Light in Gang if dark "
when
    Item GangLightActivity received update
then
  if(GangLightActivity.state == ON && IsDark_SW.state == ON && SwGoodNight.state != ON)
    {
      Color_Gang_LED.sendCommand(ON)
    
    }
  if(GangLightActivity.state == OFF && IsDark_SW.state == ON)  
    {
      Color_Gang_LED.sendCommand(OFF)      
    }
end

rule "Turn on Light in Gang if dark "
when
    Item SoveLightActivity received update
then
  if(SoveLightActivity.state == ON && IsDark_SW.state == ON && SwGoodNight.state != ON)
    {
      Color_Loft.sendCommand(ON)
      Color_MiHome.sendCommand(ON)
    
    }
  if(SoveLightActivity.state == OFF && IsDark_SW.state == ON)  
    {
      Color_Loft.sendCommand(OFF)      
      Color_MiHome.sendCommand(OFF)
    }
end

Hi! Could anybody tell that the sensors are working without their Gateway(hub)? I don’t waste my money to buy the Gateway, if doesn’t necessary

Thanks for your reply!

You need the gateway to use the xiaomi aqara and the (i forgot the name) motion sensor.

Hi,
I install nightly bindings (unziping .kar file and copy org.openhab.binding.mihome-2.2.0-SNAPSHOT.jar in /usr/share/openhab2/addons folder) but I can’t see illumination channel.
Can you help me ? I don’t want to switch all my openhab installation to 2.2 (too buggy for me).

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