Hello,
I am trying to make a binary sensor from my sensor.dryer_power. I built it from a combo of suggestion on the forum but for the life of me I can get this one right.
Would greatly appreciate any help, thanks.
I’m getting this error:
Invalid config for [binary_sensor.template]: invalid template (TemplateSyntaxError: Encountered unknown tag ‘else’.) for dictionary value @ data[‘sensors’][‘dryer_status’][‘value_template’]. Got “{{ states(‘sensor.dryer_power’)|float > 100 }} Drying {%- else %} Off {%- endif %}” invalid template (TemplateSyntaxError: unexpected ‘}’) for dictionary value @ data[‘sensors’][‘dryer_status’][‘icon_template’]. Got “{% if states(‘sensor.dryer_power’) | float > 100 }}\n mdi:tumble-dryer\n{%- else -%}\n mdi:tumble-dryer-off\n{%- endif %}”
If you want a sensor that has states Drying and Off, use a sensor rather than a binary sensor. Also be sure to quote the word ‘Off’ or it will be interpreted as a boolean.
Wow, ok. Very helpful thank you. For some reason, it’s so hard to wrap my brain around YAML. Thank you for taking the time.
So if I want a Dryer sensor that reports two states, “Drying” and “off” should I add something to my “sensor.dryer_power” that currently is in my sensor.yaml as:
dryer_power:
friendly_name: Dryer Power
value_template: “{{ states.switch.dryer.attributes.current_power_w }}”
Or should I do something with this Binary sensor when I get it to work?
The error I am getting with that code @tom_I in binary_sesonrs.yaml is:
That worked. No errors. But even though “sensor.dryer_power” current state is 188, “binary_sensor.dryer_status” shows as off. Damn this is frustrating.