Problem with templateing

Why does this only work on one of my sensors, the “balkong_door” one?

platform: template
sensors: 
  front_door: 
    friendly_name: "Front Door"
    value_template: >-
        {% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
          Open
        {% else %}
          Closed
        {% endif %}

    icon_template: >
        {% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
          mdi:door-open
        {% else %}
          mdi:door-closed
        {% endif %}

platform: template
sensors: 
  balkong_door: 
    friendly_name: "Balkong Door"
    value_template: >-
        {% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
          Open
        {% else %}
          Closed
        {% endif %}

    icon_template: >
        {% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
          mdi:door-open
        {% else %}
          mdi:door-closed
        {% endif %}

Can you edit your post and place the code tags </> around all of your code, not just the templates please :slight_smile:

because you are overwriting the section with the last template platform:

platform: template
sensors: 
  front_door: 
    friendly_name: "Front Door"
    value_template: >-
        {% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
          Open
        {% else %}
          Closed
        {% endif %}

    icon_template: >
        {% if is_state('binary_sensor.door_window_sensor_158d0001ef3410', 'on') %}
          mdi:door-open
        {% else %}
          mdi:door-closed
        {% endif %}
  balkong_door: 
    friendly_name: "Balkong Door"
    value_template: >-
        {% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
          Open
        {% else %}
          Closed
        {% endif %}

    icon_template: >
        {% if is_state('binary_sensor.door_window_sensor_158d0001f3cc19', 'on') %}
          mdi:door-open
        {% else %}
          mdi:door-closed
        {% endif %}

remove the second:

platform: template
sensors:

Thx working now. Guess this guide is not valid then…
https://smarthomehobby.wordpress.com/2017/11/22/using-the-xiaomi-door-window-sensor/

LOL nope. That’s not good. I read that the other day and didn’t even notice! Your best bet no matter what, is to come here for help and guides. I’ve rarely (maybe never) seen wrong information posted on any of the components pages.