I have the following automation which is working without problems
alias: Light Livingroom
description: ""
trigger:
- platform: state
entity_id:
- switch.light_livingroom_and_entrance_l1
from: "off"
to: "on"
id: light_off-on
- platform: state
entity_id:
- switch.light_livingroom_and_entrance_l1
from: "on"
to: "off"
id: light_on-off
- type: motion
platform: device
device_id: b2a46dba0cbae5d2c181012c2bd51def
entity_id: binary_sensor.motion_livingroom_occupancy
domain: binary_sensor
id: motion_occupancy_started
- type: no_motion
platform: device
device_id: b2a46dba0cbae5d2c181012c2bd51def
entity_id: binary_sensor.motion_livingroom_occupancy
domain: binary_sensor
id: motion_occupancy_stopped
for:
minutes: 5
seconds: 0
condition:
- condition: state
entity_id: input_boolean.disable_all_automations
state: "off"
action:
- choose:
- conditions:
- condition: trigger
id: light_off-on
- condition: not
conditions:
- condition: state
entity_id: timer.light_livingroom_helper_timer
state: active
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.light_livingroom_manual
- conditions:
- condition: trigger
id: motion_occupancy_started
- condition: and
conditions:
- condition: state
entity_id: sensor.illumination_low_livingroom
state: "True"
- condition: state
entity_id: input_boolean.markus_in_bed
state: "off"
sequence:
- type: turn_on
device_id: 9ab5e0d172b321dfb290973b3401f7dd
entity_id: switch.light_livingroom_and_entrance_l1
domain: switch
- service: timer.start
data: {}
target:
entity_id: timer.light_livingroom_helper_timer
- conditions:
- condition: trigger
id: motion_occupancy_stopped
- condition: state
entity_id: input_boolean.light_livingroom_manual
state: "off"
sequence:
- type: turn_off
device_id: 9ab5e0d172b321dfb290973b3401f7dd
entity_id: switch.light_livingroom_and_entrance_l1
domain: switch
- conditions:
- condition: trigger
id: light_on-off
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.light_livingroom_manual
mode: single
I would like to replace the values in the trigger âfor:â section
for:
minutes: 5
seconds: 0
with templates which get the minute and second values from a input_number
for:
minutes: "{{(states('input_number.motion_light_duration')|int/ 60)|round(0,'floor')}}"
seconds: "{{states('input_number.motion_light_duration')|int% 60}}"
Unfortunately this generates the error âMessage malformed: expected float for dictionary value @ data[âforâ][âminutesâ]â if I try to save the automation. I have tested the templates using the developer tools. They deliver the numbers 5 and 0.
Whatâs the problem here? The documentation states that " You can also use templates in the for
option." and gives the example
for:
minutes: "{{ states('input_number.high_temp_min')|int }}"
seconds: "{{ states('input_number.high_temp_sec')|int }}"