I agree that it would be nice to have faster updates. In the meantime, you could simply add a delay of about 1 minute or so before the lights switch off. In general, I don’t turn off my light immediately after an event (precisely to avoid such situations).
Hi, is it possible to listen for events from the motion sensor (like the Xiaomi button does) or do you just have to look for the state change in your automations?
I think someone in smartthings forums was able to change the timeout value. Is this also possible for homeassistant?
Here is the github page:
And the relevant forum:
@sendorm Did you read the description of the “motion reset feature”:
input "motionReset", "number", title: "Number of seconds after the last reported activity to report that motion is inactive (in seconds). \n\n(The device will always remain blind to motion for 60seconds following first detected motion. This value just clears the 'active' status after the number of seconds you set here but the device will still remain blind for 60seconds in normal operation.)", description: "", value:120, displayDuringSetup: false
This doesn’t improve the situation.
This is what got me rolling actually. It states that the information provided in the description is wrong.
@a4refillpad @ArstenA
Wayne, Brian,
I have found out that at least the Aqara Motion Sensors (not tried the original Xiaomi yet) do NOT stay blind to motion for 60 seconds. Well unless this is intentional coding of course. The Sensors do actually report motion far more frequently, to the value you set.
if you set the motionreset time in the Config page via the ST app, click ‘Done’ and then press the pairing button on the Motion Sensor a couple of times, waiting a few seconds between then this value will sync up to the sensor and hey presto you have far more control over the sensor.
It may be worth amending the text in the DH to this effect as it does state that the sensor will remain blind for 60 seconds which is not the case of course.
Thanks!
I thought this might be worth investigating.
I’ve read the whole topic but still got no idea; is it possible to change the frequency from 120 to 60 or lower or not? If so, how?
The period for consecutive motion triggers is 60 seconds. But as I’ve learned from other forums, if you press the button on the sensor, it goes into test mode. In the test mode the time out for consecutive motion triggers is 5 seconds. But this mode only goes on for 2 hours.
So in essence, no you can not lower the 60 seconds period.
From gearbest site:
Thank you for the clarification @sendorm, appreciated! So why is the interval 120 in Home Assistant and not 60?
It’s up to 120 seconds due to a combination of firmware limitations and HA polling time.
Has anyone noticed the same? I have noticed this already several times!
I have changed my automation-scripts to include a timer (on motion-detect start a timer and turn on the light, on motion-detect when the light is still on, restart the timer, and, when the timer has finished, turn off the light) but the problem is still there.
I am assuming that this is a “bug” in HA?
In my mind I think this happens: the automation-function receives a new trigger (motion-detect) but cannot process it because another triggered process (timer finished) is ongoing?
And there is not a waiting-queue that keeps the new trigger until it can be processed?
Actualy this is related to xiaomi motion sensor… It keeps ‘on’ state for 2 minutes.
What I did is to keep my light on when sensor is ‘on’ and turn light off when sensor is ‘off’, something like this:
- id: '1101'
alias: hodnik rasvjeta on
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_1
to: 'on'
condition:
condition: time
after: 06:30:00
before: '21:30:00'
action:
service: light.turn_on
entity_id: light.hodnik
- id: '1102'
alias: hodnik rasvjeta off
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_1
to: 'off'
condition:
condition: state
entity_id: binary_sensor.motion_sensor_1
state: 'off'
action:
service: light.turn_off
entity_id: light.hodnik
The problem with these sensor’s is the 120 seconds reset time, its hard coded, nothing you can do about it.
So if you have a timer that is anything less than that to turn off lights, it always going to run into problems.
My hallway lights dim to 50% after 30 seconds of no motion, then after 60 seconds, they turn off, but I wouldn’t be able to use the Xiaomi sensor to do this, as it would take 120 seconds before I could set them to dim, which is too long for the hallway lights, so I use a Hue sensor in there, as it has a 10 second reset time.
I just rigged up a £1.50/$2 PIR sensor to a Sonoff S20 plug, and that works over MQTT, so can set a time out of 1 second if needed.
I have a Xiaomi motion sensor in my ensuite and it seems to be working fine with the below automation set at only 1 minute. Note that the alias says 2 minutes because the sensor stays on for 1 minute, plus the automation waits a further minute. I have all my lights set for a 2 minute total off-delay.
alias: Ensuite light OFF after 2mins
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001ad43db
to: 'off'
for:
minutes: 1
action:
- service: homeassistant.turn_off
entity_id: light.ensuite_light
this is my ‘on’ automation… but in writing this I’m starting to wonder if maybe I’m just not in the room long enough to see the issue being discussed… since the one trigger is only going to work once the sensor has turned off first…
alias: Ensuite light auto ON motion
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001ad43db
to: 'on'
condition:
condition: or
conditions:
- condition: sun
after: sunset
after_offset: '-00:10:00'
- condition: sun
before: sunrise
before_offset: '-00:30:00'
action:
service: light.turn_on
data_template:
entity_id: light.ensuite_light
brightness: >
{%- if now().strftime('%H')| int >= 21 %}
13
{%- elif now().strftime('%H')| int < 5 %}
13
{%- elif now().strftime('%H')| int >= 5 %}
255
{%- endif %}
actually no, I dont have an issue since my total light on-time is greater than the Xiaomi sensor timeout. No wonder it works ok. I’ll shut up now!
@INTEL, @Cee, @ sparkydave, I had noticed the delay of 2 minutes and have worked around it by setting the timer to more than 2 minutes.
But, I think I understand what you mean: if I enter the room at the exact moment the light goes off, the light will stay off for 2 minutes due to the reported 2 minute delay of the xiaomi sensor. I cannot work around the delay in exactly that situation. If I would enter the room just before the light is turned off, or just after the light had been turned off, it would work normally. But this annoys me a bit as I seem to have the tendency to go into that room just when the light turns off
Also, nice idea to turn the brightness down, something to add to my automation!
I just replied to someone else about the for
command in automations, and on my mobile, so just going to post a link to it, but maybe you are having the same problem.
Thank you for the link.
After giving it some thought I realize it is another way to achieve the same, I hope you know what I mean?
I think something like this happens: the light-off automation is active for some (small) time-period. When during this time-period a new automation-trigger comes in, this one is ignored as the automation is working on the active task. In case of the xiaomi motion sensor this means wait for 2 minutes before a new trigger is generated. So, to get the effect that I want, either the xiaomi sensor delay time must go down to a few seconds, or the automation-function would need to have some kind of waiting-queue that can handle such kind of automation-collisions.
Or, maybe I should create the automation in the Xiaomi app. I don’t think the 2-minute delay is present in the app, I seem to remember. Back to re-reading this thread…
So basically with that automation, and your timing, it will be three minutes before your lights turn off, as the motion sensor will always stay active for 2 minutes, and then you are waiting for it to be off for 1 minute from there, so 180 seconds after last motion, your light will switch off.
If you obviously wanted your light to turn off after just two minutes, you just remove the whole for
section,
alias: Ensuite light OFF after 2mins
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001ad43db
to: 'off'
action:
- service: homeassistant.turn_off
entity_id: light.ensuite_light
Think you probably worked this out anyway, but just in case anyone else is reading this thread.
Can you post your automation here so we can see it. Don’t forget to put it into the code tag’s, the banner at the top tells you how.
You shouldn’t have a situation where the light doesn’t turn on from motion, even if you go in just as it turns it off, as soon as it detects motion again, it should run your automation, even if it is a under a second.