Good Morning,
I have several motion detectors for turning on the lights in the house automatically for only 2 minutes. Is working fine so far, but there is one challange:. The light has to stay on when I’m in the room. Means the two minute Timer has to pause as long I’m in the room and the Motion detector is registering that.
And in some cases I have two motion sensors andI want to archive is that the countdown starts again, two minutes, when triggering the light e.g. now in the first floor. Assuming there is 30 seconds rest and I’m passing the second motion detector on the first floor, it is supposed to count down the two minutes again
Simply use the run mode ‘restart’ and have two triggers in your automation with trigger ID’s ‘on’ and ‘off’.
For the ‘off’ trigger have a time for: "00:02:00" such that the trigger only happens once the motion sensor has been ‘off’ for 2 minutes.
Next, in your Action section have the a Choose function and use the two trigger ID’s to turn the light ‘on’ of ‘off’ respectively.
Thanks.
Do have an whole example by accident, with yaml code?
Since until now I used a blueprint what is not working here and I want to write it from scratch or using the standard light automation what is integrated in HA
as mentioned above - it is working as explained by @tom_l@sparkydave
But now I hit another challenge since I have one light entitiy in three automations with each automation a different motion sensor. It is an big open livingroom and the sensors are distributet across the corners of the room.
Challenge:
I pass the first sensor and after couple of seconds the motion sensor detects no movement any longer (change of state) and the light will turn off after two minutes - like stated in the trigger section of the yaml file.
Now, after 90 seconds I pass the second sensor and I would expect that the light is going to tur off after again two minutes. But wrong of course since I passed the first sensor 90 seconds ago and is still counting down the time so the light will turn off in 30 seconds after passing the second or third sensor.
How can I solve that so that the automations overwrite each other and stop their countdown after passing another motion detector.
It looks like this right now, pretty easy but otherwise working like charme - at least with just one motion sensor in place.
The above is little more complicated than you need because I have two different ‘off timers’ depending on a schedule and it also has illuminance based conditions plus wait templates relating to presence sensing. You can trim out those functions to just do basic on/off using your triggers and a fixed time delay.
Example:
alias: Alfresco LED Strip Auto
description: Alfresco LED Strip Auto
trigger:
- platform: state
entity_id:
- binary_sensor.paradox_z6_alfresco_pir
to: "on"
- platform: state
entity_id:
- binary_sensor.alfresco_presence_sensor_f9a541_pir_sensor
to: "on"
- platform: state
entity_id:
- binary_sensor.paradox_z3_garage_door
to: "on"
action:
- service: light.turn_on
data:
brightness_pct: 90
target:
entity_id: light.alfresco_led_strip
- delay: "00:02:00"
- service: light.turn_off
data: {}
target:
entity_id: light.alfresco_led_strip
trace:
stored_traces: 20
mode: restart
This is working now:).
In some autmation I do have several light target which I want to behave differntly. When I want to illuminate them differnt I just can put the data straight below the corresponding “entitiy_id”, right?
No I#m creating for each bulb a corresponding service, so I can put it below each service, ok
I think something has been happened.
Now the light aren’t turning off again after a minute as it was before I putt the data section with the time and brightness optiones.
alias: Motion Detection - TRADFRI Leon Tür
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.tradfri_leon_tuer_bewegung
to: "on"
- platform: state
entity_id:
- binary_sensor.tradfri_leon_tuer_bewegung
to: "off"
for:
minutes: 1
condition: []
action:
- service: light.turn_{{ trigger.to_state.state }}
data:
brightness_pct: |
{% if 6 <= now().hour < 21 %}
60
{% else %}
20
{% endif %}
target:
entity_id: light.flur_oben_light
mode: restart
Any hint what that might cause? I guess (maybe) that even when the state is going back to “normal” it sets again the brightness below the service means the light will never switch off?