input:
door_or_window_open_recognition_time:
name: Door or window open recognition time
description: The time for which a door or window can be open before the heating switches off
selector:
time:
default: "00:03:00"
… then try to use it as a “for:” entry is a trigger …
trigger:
- type: opened
id: door_or_window_opened
platform: device
entity_id: !input door_or_window_opening_sensor
domain: binary_sensor
for: !input door_or_window_open_recognition_time. # <<-- not accepted
… the “for:” line is rejected as a “malformed message”.
I don’t think for: will work with a time input. You will have ti use a number input to enter the number of seconds (or do some calculations if you want your input in hours or minutes).
Something like:
input:
door_or_window_open_recognition_time:
name: Door or window open recognition time (in seconds)
description: The time for which a door or window can be open before the heating switches off
default: 180
selector:
number:
min: 0
max: 3600
step: 1
unit_of_measurement: seconds
mode: slider
And remove the “.” by the end or your input name (I believe this is the source of your error message):
Thanks for the tip but the problem seems to be more fundamental. I cannot find a way to use ANY template within a “for:” statement.
I did some experiments, with results below. It’s an odd one because most changes I make are accepted by the editor (Studio Code Server). I have to look back at the Automations page to see whether the automation created from the blueprint is still there! If not, the test fails. Luckily, correcting the code does bring it back, so it seems it is just disabled if there is an error in it, even if there is no message to say so.
The pertinent results are
After the for:key you cannot just put a number (of seconds). This fails:
for: 10
You CAN write just seconds without the hours or minutes:
for:
seconds: 10
The number of seconds can be more than 59. With the following it correctly waited 1 minute 20 seconds.
for:
seconds: 80
The number of seconds is treated as text. So this is OK too
for:
seconds: '10'
HOWEVER, it seems that no kind of template can be used to define the number of seconds. Even this fails
for:
seconds: '{{ 10 }}'
So, is it the case that
a) trigger “for:” statements cannot use templates? And
b) therefore, they cannot be set using a blueprint input?
input:
door_or_window_open_recognition_time:
name: Door or window open recognition time
description: The time for which a door or window can be open before the heating switches off
selector:
duration:
default: "00:03:00"
Further trial-and-error (I still get no error messages) shows that it does not matter whether the input is time or duration, or whether there is a default or not. What fixed it was changing the trigger platform from ‘device’ to ‘state’. It seems that only the ‘device’ platform has the problem. I cannot imagine why, but ‘state’ is actually more suitable anyway in my case, so this is solved
@AndySymons, I do remember someone else having a discussion around using an input into for:, that was a couple of months ago, and I remember he ended up creating a bug in Github about this. You probably can find there to understand if that is the same case that you have.
However, as other said, I also have a few blueprints using for: !input xxx and they are all working fine, like this, which I recently changed to use for: !input (replacing a delay: !input in the actions) and it is working fine:
Maybe you can download that blueprint and try it on your system. This one is pretty easy to test, as it will turn on some device when it is off for certain time and, if that works for you, then you know it is something on your code and might help you on the troubleshooting.
Thanks for responding. I’d like to know more about the bug report as I did not find it by searching “github bug homeassistant for: !input”.
As for your example, like @DarkWarden, you are also using the platform state, which works for me too. A bug report would have to refer specifically to the device platform.