Xiaomi Human / Body / Motion Sensor - Timeout

The lights go on when peoplke enter the room
the problem is that the lights go off (dark) even when people are continuing to be in the room, this happens too many time to think that the reason is people beeing totally still for a long amount of time.

p.s. English language to me sometimes is a mistery, please note that when I write
“lights off” I mean OFF= DARK

You need to post your current automation as this should not happen if you do it the way @INTEL explained. Please note you write for: ‘00:07:00’ while I think it should be

for:
  minutes: 7

I can change that, but it is working with my format (lights go off=dark after 7 minutes, problem is they do not stay ON if people is in the room)

  - id: '1101'
    alias: Motion Kitchen - ON light New type
    trigger:
      - platform: state
        entity_id: binary_sensor.pir_kitchen
        to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sun.sun
        value_template: '{{ state.attributes.elevation }}'
        below: 5
    action:
      service: switch.turn_on
      entity_id: switch.light_kitchen
    
  - id: '1102'
    alias: Motion Kitchen - OFF light New type
    trigger:
      - platform: state
        entity_id: binary_sensor.pir_kitchen
        to: 'off'
        for: 
          minutes: 5
    action:
      service: switch.turn_off
      entity_id: switch.light_kitchen

That probably depends on you motion sensor placement.
Sensor placement is crucial for this to work as intended.
The code that I posted work’s in all of my rooms with motion sensors, even in bathroom (I don’t have any delay), just put the sensor in place where you sit still (above table, kitchen counter, etc…), and ur problems should be solved. If you have larger room to cover, you could add one more motion sensor and add it to condition (something like I posted in post #71).
You should experiment with sensor placement some more, the code is rock solid here.

Possibly, now I find hard to describe in writing the placement, I will try: the kitchen is relatively small around 2,5meter x 4.5 meter; the sensor is above the entrance door pointed to the stove/sink area (opposite). In my opinion covers well all area, but hard to tell if its really so.

I can try to add another one, but its strange, room is small

In livingroom I have 3 … and I have the same problem, but there I have 2 different brand/technology (1+2), will try to use 3 sensors with the same brand/techonology and see how it goes

I found out with trial and error, that sensor placement work’s best when placed in body height (1-1,5 meter from floor level). I tried to put sensor on the ceiling, and I got a lot worst response time and detection.

I see. Mine is at around 2 meter high, but slightly tilted pointing a bit down (20-30 degrees angle)

Positioned like that,I had issues with detecting motion, but when I moved sensor at 1,5 meter and no angle (pointing forward), I have much better detection, actualy it’s flawless now.

mmhhh, I will try that. Thank you.

edit_ 1 meter is very low (average waist level), 1.5 meter is at, average, chest level

Hi Klagio, maybe you can try the way that I have written my automation, with a timer. See my post #99, a few posts up.
It works in such a way that the timer is restarted every time a movement is detected. So as long as there is a movement before the timer ends, the light stays on.

Next to the automations shown in my post, you will also need to define the timer in configuration.yaml:

timer:
  lamp_on:
    duration: '0:03:30'

3:30 minutes is the value I use, change it to any value you like.

I saw your automation, but isn’t a timer the same as the “for:” in the turn_off automation?
?

I mainly used the timer to make sure that the lamp would stay on when there were more movements detected while the lamp was on.
And then it made sense to use the timer for the off-automation too.

I tried your automation and it works for the minutes i set in the timer, but after those minutes the lights go off also if there is movement and i have the sensor just near me.
What’s wrong?

There could be some mistakes in my code. My latest code looks like this:

- id: '1541182668961'
  alias: Lamp on at movement
  trigger:
  - entity_id: binary_sensor.motion_sensor_xyz
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: timer.lamp_on
    service: timer.start
  - after: '16:00:00'
    before: 01:00:00
    condition: time
  - below: '10'
    condition: numeric_state
    entity_id: sensor.illumination_xyz
  - data:
      entity_id: light.something
    service: light.turn_on
- id: '1541264176539'
  alias: Lamp off after some time
  trigger:
  - event_data:
      entity_id: timer.lamp_on
    event_type: timer.finished
    platform: event
  action:
  - data:
      entity_id: light.something
    service: light.turn_off

This is a 1-to-1 copy of the code in my automations.yaml
I see something strange: there are no quotes around the time of 01:00:00, I wonder whether this is a bug, or not?

The timer is always started, no conditions anymore. This helps when someone turns on the light manually. Because the sensor is in the same room as the switch, the light will automatically go off when the timer finishes.

I do see sometimes that the light goes off while it is supposed to stay on, but only when the “next” movement comes at the same time as the timer finishes. When the “next” movement comes well before end of the timer, then the lamp stays on for some more time.

I’m still looking for a solution for this “bug”. I don’t think it can be solved in the automation-code. I think the solution could be found in the way automation-triggers that happen at the same time are handled within HA.

Is this working?

It should never be met (same day event)

Update: I have tested the construct “condition: or” and it seems to be accepted; no error-message in the logs.
Just the message in the Automation-page.

I hope so? I tried to code it as shown in another post on this forum, using the construct “condition: or” but then the automation-page shows the message: unsupported condition “or”.

If I understand that right, the Aqara motion sensor (PIR) had internal (hard-coded) delay of 60 seconds to send the new status. Status could be: Something is moving or nothing is moving. Right?

I saw this great-Xiaomi Zigbee-Temp-Sensor hack here:
hackaday.io - This project is a hack of a Xiaomi Mi smart sensor in aim to develop your proper code with a zigbee protocol
and here another too:

I buy a lot of motion sensors from Aqara (RTCGQ11LM) to use them in my house. The goal of 60 second delay is something that I really dont like. I really really hope that It would be possible to manipulate the firmware. Changing the value from 60 seconds to anything else, would be nice.

Yesterday I made some photos of the PCB of the Aqara RTCGQ11LM



7 aqara PIR pcb photos
There are 6 unamed solder-points and it could be that theese are GND, RST, VCC, DO1, RX & TX. But I do not know the 100% right order.

I hope here is somebody who can help me.

Greetings by JamieMe

If you look at that French site, he says he thinks that the programming pin layout is the same on the motion sensor as on the temp/hum sensor.

I find it quite hard following his site as my French is no good, and google translate is a little bizarre at times.

In the past, see earlier posts, some people (me too) complained about lights not turning on when the xiaomi motion sensor was triggered. Also, it was noticed that there’s a “dead-time”: when triggered, the xiaomi motion sensor does not respond to movement for some time (120 seconds in my HA system).

I have been playing with a lot of options to try to solve the first problem: lights not turning on when the motion sensor was triggered. Nothing worked until I realized this: the light(s) being triggered by the sensor must be turned off before the motion sensor becomes active again. Only then will the light turn on properly when the sensor becomes active again. When the lights are turned off sometime later, the sensor can be triggered before the lights are turned off and will be in “dead-time” state when the sensor is triggered a next time. Result: lights will not turn on.
I thought this could be solved by using a timer; restarting a running timer by a next movement. This worked most of the time but still not always.

When I was testing this realization, I noticed it still did not work sometimes. I checked in detail and found that the dead-time of the motion sensor is sometime longer than 120 secs, sometimes it is a multiple of this period. I guess this is because the sensor gets triggered again before it has sent the message to the HA that it is off.
image

So, my hopefully final automation-solution turns off the lights when the motion sensor state goes from on to off. Will follow up with results some time later.