#cast it in the variable statement
1 messages · Page 1 of 1 (latest)
variables:
motion_sensor: !input motion_sensor
presence_sensor: !input presence_sensor
complimenting_light_mode: !input complimenting_light_mode
seconds_delay: !input seconds_delay | float(180)
i see. it's neat that you can pipe and use template vars when setting vars.
same issue when doing that though expected float for dictionary value @ data['for']['seconds']. Got None
i believe the resulting value from the template isn't being set into the seconds key for some reason
based on the other part of the code, default should be(180)
i'd expect it to say something like Got Text instead of Got None if my template was setting the wrong type
Did you take that broken code out of the for statement?
hours: 0
minutes: 0
seconds: >
{% if is_state('binary_sensor.night_mode', 'on') %}
180
{% else %}
{{ seconds_delay }}
{% endif %}``` yeah
Put an actual number in the template instead of seconds_delay to test
actually, looks like it doesnt like that | float (2) syntax.
error: Invalid blueprint: Missing input definition for seconds_delay | float(2) (See /config/configuration.yaml, line 9).
seconds_delay: !input seconds_delay | float(2)```
Here is how they do it in the docs...
automation:
trigger:
- platform: numeric_state
entity_id:
- sensor.temperature_1
- sensor.temperature_2
above: 80
for:
minutes: "{{ states('input_number.high_temp_min')|int }}"
seconds: "{{ states('input_number.high_temp_sec')|int }}"
except not you need a default, so add (180)after float.
i probably need to create a single template line that handles the if conditional, the 180, and the seconds_delay.
I pick 180 as default because that is your dark default, if number input is broken it wil all still work the same
seems like part of the problem is the syntax:
templating logic on next lines```
im not sure how that is processed differently from same-line template like in that docs example
yesthat could be also, but the variable is I think going to give you text.
it miiight be - though the input is using a numbers selector
just put it in a line. change the newlines into spaces.
play with it in the developer screen template tester
even a basic seconds: "{{ seconds_delay | float(2) }}" is giving the Expected float ... Got none error despite being a number in the dev template tester
('seconds_delay', 360) passed into the blueprint, expected float for dictionary value @ data['for']['seconds']. Got None error despite something simple like seconds: "{{ seconds_delay|int }}" and variables: seconds_delay: !input seconds_delay strange.
You must be running into limited templates. Look that up, memory it pinging me something about that.
hm yeah, definitely seems likely.
official docs say these arent supported in limited templates:
- states (strange that you saw it being used in the official docs trigger template)
- attributes (state_attr)
- groups (expand)
- device_attr
- is_device_attr
- time (now and utcnow)
- distance
so is_state wont work, dang.
doesn't explain exactly why {{ seconds_delay }} doesn't work - though i'd lean towards it being not documented that blueprint variables are not supported in limited templates.
i need to rethink the blueprint then, thanks for the help
It's still not that bad to do, just can't do it that way. I would assume that the night mode is the longest time, the 3 minutes.. Then trigger on seconds_delay, and have an action choose statement that checks for night mode. You may need the logic different, but think thru it, make the trigger simple and work it that way...
yeah thats exactly what i ended up doing, works nicely