Invalid config for [automation]: offset {{ states.input_number.vent_min_timer.state | int }}:00:00 should be format 'HH:MM' or 'HH:MM:SS' for dictionary value @ data['trigger'][0]['for']. Got None. (See /config/configuration.yaml, line 388).
I use a script and a delay in the script. My automation turns on a script when triggered, and the action starts a script where the delay is the input number value. When the script ends (delay is over) it turns my switch off. This also allows me to stop the script or “cancel” it. The delay is not dynamic though, so if I change the input number while the script delay is running, it will continue with whatever value it started with.
that’s because triggers do not support templating, they are straight.
Do I get it right that you want to switch your fan off after a number of hours set by input_number?
If so, I think there is another way to do that.
The automation that reacts to input_boolean off->on writes current time into input_datetime entity
You need a template binary_sensor with entity_id: input_boolean, input_datetime (and sensor.time, for example, to update it every minute). In value_template return now() | as_timestamp - input_datetime | as_timestamp < input_number.state
An automation that turns input_boolean off (and resets to None input_datetime) on that binary_sensor on → off
I think it might do the job.
Actually, instead of the binary_sensor you can have a time_pattern automation with condition: platform: template where you will do exactly what that value_template did.
Another option is to use async_call_later service in a python script, but I have no idea if it will work at all.
I think this would work. If boolean is on and the difference in time is greater than or equal to the input_slider in hours then true. Maybe check in the template editor to see what you get.
trigger:
- platform: template
value_template: >
{% set bool = states('input_boolean.vent_min') %}
{% set now = as_timestamp(now()) | int %}
{% set last_changed = as_timestamp(states.input_boolean.vent_min.last_changed) | int %}
{% set limit = states('input_number.vent_min_timer') | int %}
{% if bool == 'on' and now - last_changed >= ( limit * 3600 ) %}true
{% else %}false
{% endif %}
Invalid config for [automation]: [delay] is an invalid option for [automation]. Check: automation->action->0->delay. (See /config/configuration.yaml, line 395). Please check the docs at https://home-assistant.io/components/automation/