I can’t seem to work out how to put a data template in the for section of a trigger. can anyone show me some examples?
I have this automation and the for: is controlled via a slider.
- alias: 'Auto Switch Lights Off'
trigger:
platform: state
entity_id: binary_sensor.pir6
to: 'off'
for:
minutes: input_number.money_save_mode
action:
- service: light.turn_off
entity_id: light.kitchen
Tinkerer
(aka DubhAd on GitHub)
2
With a template:
trigger:
platform: state
entity_id: binary_sensor.pir6
to: 'off'
for:
minutes: "{{ states('input_number.money_save_mode') }}"
So i have this, and it doesnt work. But when i actually write 5 instead of having the variable it does…
- alias: 'Auto Lights - Kitchen'
trigger:
platform: state
entity_id: binary_sensor.pir9
to: 'off'
for:
minutes: "{{ states('input_number.money_save_mode') }}"
condition:
condition: state
entity_id: input_boolean.money_save_mode
state: 'on'
action:
- service: light.turn_off
entity_id: light.kitchen
- service: light.turn_off
entity_id: light.kitchen_2
- service: light.turn_off
entity_id: light.kitchen_4
Sorted. It was because i had to convert it to an int as it was a float with decimals
"{{ states('input_number.money_save_mode') | int }}"