I’m trying to template a time in the wait_for_trigger action
Here’s the whole automation for reference
alias: Pantry Light - delayed timer
description: Controls the Pantry light and turns if off after xx time
trigger:
- type: motion
platform: device
device_id: a2f3426f9ebd8ccb8a486a2ff8e107b7
entity_id: 7ee585329c2b079ed28428fb2e0cf50b
domain: binary_sensor
condition: []
action:
- service: adaptive_lighting.apply
data:
entity_id: switch.adaptive_lighting_pantry_storeroom
lights:
- light.pantry_light
transition: "1"
adapt_brightness: true
turn_on_lights: true
- wait_for_trigger:
- type: no_motion
platform: device
device_id: a2f3426f9ebd8ccb8a486a2ff8e107b7
entity_id: 7ee585329c2b079ed28428fb2e0cf50b
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
continue_on_timeout: true
- type: turn_off
device_id: ccb23a71382bdd7150b846251db03989
entity_id: 39b084358cb59aad38026c03cdb2f263
domain: light
- service: counter.increment
target:
entity_id: counter.pantry_toggle
data: {}
- delay:
seconds: 10
- service: counter.reset
target:
entity_id: counter.pantry_toggle
data: {}
mode: restart
The issue i’m having is it won’t accept a templated entry for this part of it
- wait_for_trigger:
- type: no_motion
platform: device
device_id: a2f3426f9ebd8ccb8a486a2ff8e107b7
entity_id: 7ee585329c2b079ed28428fb2e0cf50b
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
Every time i try to put in something it says…
Message malformed: expected dict for dictionary value @ data[‘for’]
I’ve tried basics like this…
{% set blah = 22 %}
{% set my_dict = {
"hours": 0,
"minutes": 0,
"seconds": blah
}%}
{{ my_dict }}
and still doesn’t work. Ideally I want to convert xxxx seconds to ‘00:01:20’ and put it in for: , but it doesn’t even accept that .
Script Syntax - Home Assistant seems to indicate even basic values should work eg for: 10, but i get the same error.
My end goal is simple, and perhaps i’m overcomplicating it… but a real example will be
Motion detect 1 : light on 20s
light turns off, but then detects motion again within 10s
Motion detect 2 : light on 20 * 2+2
Motion detect 3 : light on 20 * 4+2
Motion detect 4 : light on 20 * 5+2
I think you get the idea, and there is an upper limit
logic something like this
for:
hours: 0
minutes: 0
seconds: >
{% set base_duration = 20 %}
{% set counter_value = state_attr('counter.pantry_toggle', 'value') | int %}
{% set max_duration = 180 %}
{{ min(base_duration * (counter_value + 1) + 2, max_duration) }}