Xiaomi Human / Body / Motion Sensor - Timeout

yeah, I haven’t actually timed it to be honest. Its works for me and I haven’t worried about reducing the time period. I suppose I could to reduce the on-time a bit

1 Like

if it works, then don’t touch it :smiley:

1 Like

Is this code serving you well?

Are the below related to two different sensors?

trigger:

  • platform: state
    entity_id: binary_sensor.motion_sensor_xxxxx
    to: ‘off’
    condition:
    condition: state
    entity_id: binary_sensor.motion_sensor_xxxxx
    state: ‘off’

It’s working as it should.
The light stay’s on for 2 minutes (xiaomi sensor timeout), and as soon the sensor closes, light’s turn off.
The sensors in the config I posted are for reference only, they are both the same sensor, i just didn’t add same amount of xxxx to replace original sensor name (xiaomi sensors). I have edit that post to avoid further confusion, sry about that.

Hi! I do have same problem as many others in this thread: how to solve the issue that when people are still in the room the lights do not go OFF.

  • in one room I have only one xiaomi sensor
  • in another room I have two xiaomi sensors (I made no group yet)
  • in another room I have one xiaomi sensor + a zwave motion sensor (I made a group)

apparently for each situation I need a different solution, right?

Now I am a bit confused on which …

but if people are in the room moving during that time, will the light continue to be ON?

Yes it will, sensor is in ‘ON’ state as long as it detect’s motion, and the light is ‘ON’ if the sensor is ‘ON’.

Ok, I will try your code. What do you think of adding some extra minutes just in case somebody is totally still for (example) 4 minutes , how to change the code accordingly?

use my code in post 72 and change the value- for: minutes: 2 (it will add that to the sensor timeout of 2 minutes, giving you 4 in total)

So you are not adding the condition (state off) as INTEL?

Sorry but I have been trying for a solution for like 6 months now … and always failed (now I just turn OFF without automation since family is totally upset at me, need to be sure about next solution :smiley: )

  - id: '1102'
    alias: Motion Kitchen - OFF light New type
    trigger:
      - platform: state
        entity_id: binary_sensor.pir_kitchen
        to: 'off'
    condition:
      condition: state
      entity_id: binary_sensor.pir_kitchen
      state: 'off'
    action:
      service: switch.turn_off
      entity_id: switch.light_kitchen

no, not needed. My automations for lighting have been working well for a year or so now

Yes, condition in OFF automation is not needed, you could just add something like this:

- id: '1101'
  alias: LIGHT ON
  trigger:
  - platform: state
    entity_id: binary_sensor.motion_sensor_1
    to: 'on'
  action:
    service: light.turn_on
    entity_id: light.bulb
    
- id: '1102'
  alias: LIGHT OFF
  trigger:
  - platform: state
    entity_id: binary_sensor.motion_sensor_1
    to: 'off'
  action:
    service: light.turn_off
    entity_id: light.bulb

This will keep light’s on for 2 minutes (with xiaomi sensors) after last motion, and if you need more, you could add time condition like this:

trigger:
- platform: state
  entity_id: binary_sensor.motion_sensor_1
  to: 'off'
  for:
    minutes: 2

No, your solution didn’t work in my case. Wife very angry, will try to add for:

In my experience this is a very hard one to fix! :wink:

Move to wife v2.0

Well I did get rid of wife v1 and replaced her with a gf… Not planning to move gf to wife V2 status. I figure it’s better keeping her at gf status, since they get too demanding at wife level :laughing:

1 Like

:joy::joy: If we spend the time invested in HA to automating our wifes, we would’t need HA at all!
They come preinstalled with voice command too! :joy:

3 Likes

I have problems in the two rooms mostly used: kitchen and livingroom

In the kitchen I have 1 xiaomi sensor, and I do need to put
for: ‘00:07:00’
to not have any problems of angry wife (well I understand her, is not nice that your lights go off while you are washing dishes, preparing food.
I can live with a 7 minutes time out, although is not really energy efficient, since I put the automation nobody is turning the lights off anymore, hence many times family go in the kitchen grabs something tro eat (30 seconds) and now light stays on for 7 minutes!!! And this happens 3/4 times every evening with 4 people in the house.

Same in the livingroom, there also 7 minutes is not enough, I did not try higher minutes, so I just eliminate the turn_off part … of course, now everybody in the family is NOT turning the lights off in the livingroom, and its always me that I have to remember to turn them off

Basically I put the automation for convenience and energy saving, but I feel I do consuime MORE now then in the past (nobody is turning the lights off anymore), and for me is less convenient because its always me that has to turn them off (when I remember).

YEah I know first world problem, but I really wish to solve this

p.s. in the livingroom I have a combination of xiaomi and zwave sensor, but I will get another zwave sensor so to have same brand/model of sensors in the same room.

Hard to understand your problem. Just have the light come on when the motion sensor comes on. The light will stay on while someone is detected, plus 2 minutes.

My 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:
  - after: '16:00'
    before: 01:00
    condition: time
  - below: '10'
    condition: numeric_state
    entity_id: sensor.illumination_xyz
  action:
  - data:
      entity_id: timer.lamp_on
    service: timer.start
  - data:
      entity_id: light.hal
    service: light.turn_on
- id: '1541264176539'
  alias: Lamp off after timer finished
  trigger:
  - event_data:
      entity_id: timer.lamp_on
    event_type: timer.finished
    platform: event
  action:
  - data:
      entity_id: light.hal
    service: light.turn_off

And the timer_on is set to 3:30 minutes.

1 Like