Hi, I’m not getting any notifications from this, while for sure the valves are all opening less than 99%. Can anyone help explain why, please? The only potential issue I see is the device names are strings of characters instead if device.something.something.
I would put each of those conditions in the developer tools template section and see if any were not returning true as expected. I also don’t think you need the AND for the conditions but it also should work the same.
Unless you need it to run every five minutes and send you repeat notifications, I’d suggest creating a template trigger with a state like this:
{% set el = ['sensor.device2',
'sensor.device8',
'sensor.device4',
'sensor.device6',
'sensor.device3',
'sensor.device5',
'sensor.device9'] %}
{{ el|map('state_attr','valve_position')|map('float',0)|max < 99 }}
Assuming your entity IDs and the attribute name are correct, that should send a notification each time the template goes from false (all at 99 or above) to true (any valve below 99).
The default value in the float map will also force a trigger if any device isn’t working.
Thanks, when I Run action, I get a notification to my phone - so at least the action is working.
I found that in the automation editor UI, clicking the debug icon resulted in
ValueError: Template error: int got invalid input 'None' when rendering template '{{ (state_attr('sensor.device8', 'valve_position')|int) < 99 }}' but no default was specified
So the conditions are obviously where my issue lies. Honestly, I have adapted the conditions without really understanding the relevance.
My automation is intended to check when all radiator valves are open to the same degree (between 0% and 100%). Ultimately I want to activate a switch to close a zone valve when all radiator valves are closed (at 0%), but for now I am trying to generate a notification (based on a test that I know will be met, namely all valves at 99% or less).
Thanks for pointing me in the right direction. Changing all those pesky template conditions to plain old numeric state conditions seems to have done the trick. Thank you!
I’m very confused.
First it was an attribute called valve_position now you post entities called valve_position.
Anyways… remember there can be issues with integration failing or device failing. What would that do?
Could it break something, do you need to make double checks to make sure things something does not happen?
And also… are you sure this needs to run every five minutes?
Wouldn’t it be better to trigger when all is at 100?
The intent is to activate a switch if any of the valves is open (if the sensor value is > 0%) and close the switch if all of the valves are closed (value is = 0%).
Note that “activate” and “close” mean the same thing with regards to a switch. The solution below will turn the switch on if any valve is open.
Set up a Template Binary Sensor helper (see below) called “Valve open” with state:
{% set el = ['sensor.device2_valve_position',
'sensor.device8_valve_position',
'sensor.device4_valve_position',
'sensor.device6_valve_position',
'sensor.device3_valve_position',
'sensor.device5_valve_position',
'sensor.device9_valve_position'] %}
{{ el|map('states')|map('int',0)|max > 0 }}
This reports off if all the valves are at 0, and on in any other situation.
The default 0 value in the int filter means that an offline valve will be considered shut. Change the 0 to a positive number if you want an offline value considered open.
Thanks Troon, how do I set up a Template Binary Sensor helper? I looked at Helpers under Devices and services, but I don’t see an edit in yaml option there, so probably the wrong place.