Change the state or ICON of a binary sensor for tilt

I have a tilt sensor that I am using to track if the garage door is open or closed…
Its name is:
binary_sensor.ecolink_garage_door_tilt_sensor_sensor

It currently is on (open) or off (closed)
How can I change its icon to show mdi:garage for closed and mdi-garage-open for when its open and change its results to be the same?

I tried creating a template to a fake garage_door entity but that didnt work

- platform: template
  sensors:
    garage_door:
      entity_id:
        - binary_sensor.ecolink_garage_door_tilt_sensor_sensor
      value_template: >-
        {{ is_state("binary_sensor.ecolink_garage_door_tilt_sensor_sensor") }}
      icon_template: >-
        {% if is_state("binary_sensor.ecolink_garage_door_tilt_sensor_sensor", "on") %}
          mdi:garage-open
        {% else %}
          mdi:garage
        {% endif %}

Just customize binary_sensor.ecolink_garage_door_tilt_sensor_sensor using device_class: garage. It will change the icon for you and you won’t need to create a template sensor.

1 Like

wow that was quick… what about its state of off and on - changing to Open and Closed?

Yep it will do that too, but only in ‘built in’ lovelace cards. Any custom card that doesn’t use translations will have on/off.

In the backend (states page) it will show on/off. But your UI will show Open/Closed.

1 Like

I tried this… says needs

Invalid config for [binary_sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 104).

here is the lines…

binary_sensor.ecolink_garage_door_tilt_sensor_sensor:
  friendly_name: Garage Door
  device_class: door

No, do it through the UI in.

1 Like

I have two sensors:
image
and

image

I have the following template for my cover:
image

When I Render the garage_door… it thinks its always Open and the tilt sensor does show off (closed) and when I click Down or stop it doesnt call the switch…

thoughts on what I am missing?

Got some spelling errors on your entity_ids for stop cover and you don’t need the icon template with device_class garage. Device class will handle translation and icon

so this?

- platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"