Help! Template Sensor

Hi folks,
I got myself a zwave door sensor, and have it working. I’m trying to use a template so HA displays open / closed, rather that 22 / 23 that the sensor sends. I’m not a programmer, and so some of this is beyond me. Thanks to youtube, I’ve gotten this far.

- platform: template
    sensors:
    kitchen_door_2_status:
      friendly_name: "Kitchen door 2"
      value_template: >-
        {% if is_state("sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2", "23")%}
          Closed
        {% elif is_state("sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2", "22")%}
          Open
        {% else %}
          Unknown
        {% endif %}

While the template editor doesn’t seem to have a problem with it, I performed a config check and the system returned the following;
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data[‘sensors’]. Got None. (See ?, line ?)

Can anyone see what I’m doing wrong? I’m assuming everything is wrong at this stage, but gotta start somewhere I suppose.

The other way is to put three backticks ( ` <-- this character, above the TAB key usually) on an empty line, hit ENTER, paste your code, ENTER again, then three more backticks.

1 Like

your spacing or indentation is wrong at or around the sensors line.

- platform: template
  sensors:
    kitchen_door_2_status:
      friendly_name: "Kitchen door 2"
      value_template: >-
        {% if is_state("sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2", "23") %}
        Closed
        {% elif is_state("sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2", "22") %}
        Open
        {% else %}
        Unknown
        {% endif %}
1 Like

Thank you! I’d been looking at it for so long, I couldn’t see anything anymore! System check says it’s cool now.