As title, i cannot figure out what’s the problem, this is the relevant portion of code:
trigger:
- platform: template
value_template: {{ (state_attr('binary_sensor.foo', 'battery_level') < 10 |int) or # line 28
(state_attr('binary_sensor.foo2', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo3', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo4', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo5', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo6', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo7', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo8', 'battery_level') < 10 |int) or
(state_attr('binary_sensor.foo9', 'battery_level') < 10 |int) or
(state_attr('sensor.foo10', 'battery_level') < 10 |int) or
(state_attr('sensor.foo11', 'battery_level') < 10 |int) }}
but i got this error in the log:
in "bla.yaml", line 28, column 26
expected ',' or '}', but got '<scalar>'
in "bla.yaml", line 28, column 99
2020-01-18 17:43:56 ERROR (MainThread) [homeassistant.components.automation] while parsing a flow mapping
in "bla.yaml", line 28, column 26
expected ',' or '}', but got '<scalar>'
in "bla.yaml", line 28, column 99
I’m very surprised if this actually works in the template editor.
I think you want : -
(state_attr(‘binary_sensor.foo’, ‘battery_level’) | int < 10 )
Though the construction of the template as a single trigger means that you will never get a second trigger for another battery falling below 10
Thats okay if you then check all your levels and sort your batteries out
How do you have battery level as a binary_sensor attribute ? (the others make sense)
As well as the |int thing you have a multi line template starting on the first line like a single line template - that would require it to be enclosed in quotes. Try using the multi line format:
value_template: >
{{ (state_attr('binary_sensor.foo', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo2', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo3', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo4', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo5', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo6', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo7', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo8', 'battery_level')|int < 10 ) or
(state_attr('binary_sensor.foo9', 'battery_level')|int < 10 ) or
(state_attr('sensor.foo10', 'battery_level')|int < 10 ) or
(state_attr('sensor.foo11', 'battery_level')|int < 10 ) }}
Error descriptions are notoriously vague but it looks from your 3 errors that you are comparing a text field with a number (you were) and the second one suggests that you are using node red ??? Though I’m guessing on that.