Hello, complete new here, and searched many topics, and YouTube, but I can’t find a working solution.
I have the following situation: Motion sensor, and led strip. That’s it.
What I want: after movement, enable the led strip for a fixed time, e.g. 2 minutes. After the two minutes, motion can be detected again, for e.g. 15 seconds. And this time, when there is a new motion within these 15 seconds, the timer may start again for 15 seconds. And this goes on as long as there is motion.
Is this possible?
I have watched this YouTube tutorial, but in this example, the timer restarts after a new motion is detected. And I want a fixed time after the first motion.
I tried with delay, but just don’t know to make the second part.
This is the code from the Youtube tutorial
alias: Badkamer beweging copy original
description: ""
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.badkamer_timer
id: Timer finished
- type: no_motion
device_id: 7c9b2ceb48db904196b9aa1ae269caad
entity_id: 1434ddd41f85d7fccc3e9f6342a9204b
domain: binary_sensor
trigger: device
id: Motion stopped
- type: motion
device_id: 7c9b2ceb48db904196b9aa1ae269caad
entity_id: 1434ddd41f85d7fccc3e9f6342a9204b
domain: binary_sensor
trigger: device
id: Motion detected
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- Motion stopped
sequence:
- action: timer.start
data:
duration: "120"
target:
entity_id: timer.badkamer
- conditions:
- condition: trigger
id:
- Motion detected
sequence:
- action: timer.cancel
target:
entity_id: timer.badkamer_timer
data: {}
- type: turn_on
device_id: 7c9b2ceb48db904196b9aa1ae269caad
entity_id: 8243d8b162c2cc1f8f8a023b6391e913
domain: light
- conditions:
- condition: trigger
id:
- Timer finished
sequence:
- type: turn_off
device_id: 7c9b2ceb48db904196b9aa1ae269caad
entity_id: 8243d8b162c2cc1f8f8a023b6391e913
domain: light
mode: single
And this is my simple code
alias: Badkamer licht aan
description: ""
triggers:
- type: motion
device_id: 7c9b2ceb48db904196b9aa1ae269caad
entity_id: 1434ddd41f85d7fccc3e9f6342a9204b
domain: binary_sensor
trigger: device
conditions: []
actions:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 33
transition: 2
target:
entity_id: light.badkamer_esp32_badkamer_ledstrip
- action: timer.start
metadata: {}
data:
duration: "60"
target:
entity_id: timer.badkamer
- delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
- action: light.turn_off
metadata: {}
data:
transition: 0
target:
entity_id: light.badkamer_esp32_badkamer_ledstrip
mode: single
Regards, Peter