Note you can only do this in the sensor definition, not the card, unless you have the custom card template installed:
"{{ states('sensor.sm_a505u_battery_level')|replace('SM-N960U Geocoded Location', 'Joseph') }}"
The device class ‘door’ does what you want and comes with fancy changing icons;
binary_sensor:
- platform: template
sensors:
sliding_glass_door:
value_template: "{{ is_state('binary_sensor.ecolink_door_window_sensor_sensor', 'on') }}"
friendly_name: 'Sliding Glass Door'
device_class: 'door'
The other device classes are listed in the binary sensor documents.