Quick templates for wifi, batteries and the like

Hi all,

Hopefully a quick one - I’m fairly noob-like when it comes to templates, however I’m finding myself creating lots of identical interfaces in my HA install - for example converting wifi strength entity values into the various strength indicator icons.

I know I can do this with templates, however is there a smarter way I can do this? I’ve seen how you can manually do it for each entity, eg:

sensor:
  - platform: template
    sensors:
      icono_nivel_senal_wifi_despacho:
        friendly_name: Nivel Señal Wifi Despacho
        unit_of_measurement: 'dBm'
        value_template: '{{ states("sensor.nivel_senal_wifi_despacho") }}' 
        icon_template: >-
          {% set rssi_level = states("sensor.nivel_senal_wifi_despacho") | int %}
          {% if -1 > rssi_level >= -50 %}
            mdi:wifi-strength-4
          {% elif -51 >= rssi_level > -61 %}
            mdi:wifi-strength-3
          {% elif -62 >= rssi_level > -72 %}
            mdi:wifi-strength-2
          {% elif -73 >= rssi_level > -83 %}
            mdi:wifi-strength-1
          {% elif -84 >= rssi_level > -94 %}
            mdi:wifi-strength-outline
          {% else %}
            mdi:wifi-strength-off-outline
          {% endif %}

However, this becomes far too much overhead to be useful.

In short, I’m thinking about something like css classes that I can just call to style things - I’m sure it’s possible, I just don’t know what it’s called!

Set its device_class to signal_strength.

sensor:
  - platform: template
    sensors:
      icono_nivel_senal_wifi_despacho:
        friendly_name: Nivel Señal Wifi Despacho
        unit_of_measurement: 'dBm'
        device_class: signal_strength

I was recommended this highly customizable card that does all this for me. I installed it 2 weeks ago and never looked back: Battery State Card in HACS