Hello!
I have two lux sensors and I want to create a helper that, if one or both of the sensors have a value below 10, should be true and otherwise false.
I’ve already done that but it doesn’t work. Unfortunately I don’t know why. Does anyone have a tip.
binary_sensor:
- platform: template
sensors:
bewegungsmelder_illuminance_check:
friendly_name: "Bewegungsmelder Illuminance Check"
value_template: >-
{{ states('sensor.bewegungsmelder_1_illuminance_lux')|float < 50 and
states('sensor.bewegungsmelder_2_illuminance_lux')|float < 50 }}
device_class: 'light'
Upfront, what you’re using, is the old legacy format, which shouldn’t be used anymore.
But that’s not a problem, here you go:
template:
- binary_sensor:
- name: bewegungsmelder_illuminance_check
state: >
{{ states('sensor.bewegungsmelder_1_illuminance_lux')|float(0) < 10 or
states('sensor.bewegungsmelder_2_illuminance_lux')|float(0) < 10 }}
device_class: 'light'
This is the basic example, you could additionally set an availability
, if you want to. See here:
What I’ve changed:
- set a default value for the float filter
- changed the
and
to an or
. If the condition is one or both, the both isn’t needed. 
Hello!
Thanks for the answer.
How do I set this up correctly? Helper → Create helper → Template → Create template for a binary sensor
Is that right? Because it just doesn’t work.
Sounds about right!
You copy what’s under state
and paste it in the field in the UI. But I’m not using the UI, so that might be it. 
What isn’t working exactly? Is there an error, if so, any log entries?
Please try the state part in your Developer Tools. Let’s see, what’s the outcome. 