Code not working for "template sensor"

Hello

I am trying to make my first coded sensor in configuration.yaml and it is not going very well. I would like to make a sensor showing the difference between two temperature sensors.

Attached is a picture of my code and the error message. Hope to get some help to make the code work.

I think your line alignment is a bit off. It should be something like:

  - binary_sensor:
      - name: test
        device_class: door
        state: >
            {% if is_state('input_boolean.test', 'off') %}
              off
            {% elif is_state('input_boolean.test', 'on') %}
              on
            {% endif %}

Please read the forum category descriptions. This is not a feature request. Moved.

Also please do not post pictures of text. Post correctly formatted configuration text.

1 Like

Copy the code in file editor, then paste it into your post as preformatted text (</> in the toolbar). :slightly_smiling_face: