Xiaomi Door Sensor Issue

Good Morning,

I’m trying to get my Xiaomi door sensor to show in the WebUI but having an issue getting it to work.

It’s showing up fine in HASSIO as ‘binary_sensor.door_window_sensor_158d0001f49c83’. This is what I have in my sensors.yaml.

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

The error I get is:

2018-01-21 22:24:50 ERROR (SyncWorker_0) [homeassistant.util.yaml] while scanning for the next token
found character '%' that cannot start any token
  in "/config/sensors/sensors.yaml", line 64, column 8
2018-01-21 22:24:50 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
  in "/config/sensors/sensors.yaml", line 64, column 8

Remove the space in the else statement of the icon template.

2 Likes

Doh!

Thank you for the fresh pair of eyes.