I would like to use the template feature to change the way the below entity values are displayed my cards.
Example 1:
If I display the value for entity: sensor.sm_a505u_battery_level in a card, it will display as:
SM-N960U Geocoded Location 1234 Huntington Way, Bumington, WA 12345, USA
I would like to change it to say:
Joseph 1234 Huntington Way, Bumington, WA 12345, USA
…also, how do I override the respective icon for this entity? I tried specifying “- icon: mdi:xxx” in the card code, however that obviously wasn’t right.
Example 2:
If I display the value for entity: binary_sensor.ecolink_door_window_sensor_sensor in a card, it will display as:
On
I would like to change it to say:
Open
…and, if it displays, Off
to change it to display Closed
, respectively.
I was able to make a template for this, however, it’s still not right. I don’t get any errors, however, the value for sliding_glass_door
always shows as off
in lower case letters.
binary_sensor:
- platform: template
sensors:
sliding_glass_door:
value_template: "{%if states.binary_sensor.ecolink_door_window_sensor_sensor.state == 'On' %}Open{%elif states.binary_sensor.ecolink_door_window_sensor_sensor.state == 'Off' %}Closed{% endif %}"
friendly_name: 'Sliding Glass Door'
I tried using the template below; however, that resulted in my whole Home Assistant going into Safe Mode complaining about “mapping values are not allowed here”
- platform: template
sensors:
sliding_glass_door:
value_template: '{% if states.binary_sensor.ecolink_door_window_sensor_sensor %}
{% if states.binary_sensor.ecolink_door_window_sensor_sensor.state == "on" %}
Open
{% else %}
Closed
{% endif %}
{% else %}
n/a
{% endif %}'
friendly_name: 'Sliding Glass Door'
I really hope this isn’t too much to ask for someone to help out. But, I REALLY tried before posting. I would really appreciate the help to get two working templates.