Sensor Badge icon instead of value

Is it possible to show sensor badge as icon instead of sensor value?
My custom command line sensor catch state in String form. I have created a template sensor to change icons depending on the state.
But when I put sensor in the frontend badges, only a string state is visible.

Is there any way to change the badge to show an icon instead of value using customUI?

Current code:

  - platform: template
    sensors:
      prediction:
        value_template: >
            {{ states('sensor.preassureprediction') }}
        friendly_name: 'Prediction'
        icon_template: "{% if is_state('sensor.preassureprediction' , 'Stable') %}
                        mdi:wave
                        {% elif is_state('sensor.preassureprediction' , 'Unstable') %}
                        mdi:weather-partly-lightning
                        {% elif is_state('sensor.preassureprediction' , 'Sun') %}
                        mdi:weather-sunny
                        {% elif is_state('sensor.preassureprediction' , 'Storm') %}
                        mdi:weather-lightning-rainy
                        {% elif is_state('sensor.preassureprediction' , 'Rain') %}
                        mdi:weather-rainy
                        {% else  %}
                        mdi:wave
                        {% endif %}"
1 Like

I search for the same question about moon: integration… Entity have the icon, and i just want to show icon in badge in place of value…

moon.yaml

- platform: moon

- platform: template
  sensors:
    fase_lunar:
      friendly_name: 'Fase lunar'
      value_template: >
        {% set fases = { 'full_moon':'luna llena', 'new_moon':'luna nueva', 'waxing_crescent':'luna creciente', 'first_quarter':'cuarto creciente', 'waxing_gibbous':'creciente convexa', 'waning_crescent':'cuarto creciente', 'waning_gibbous':'luna gibosa menguante', 'last_quarter':'cuarto menguante'} %}
        {% set fase = states('sensor.moon') %}
        {{ fases[fase] if fase in fases.keys() else 'fase lunar desconocida' }}
      entity_picture_template: >
        {% set state = states('sensor.moon').title().replace('_','').replace(' ','') %}
        {{ '/local/luna/N{}.jpg'.format(state) }}

badge

  - entity: sensor.fase_lunar
    style: |
      :host {
        --label-badge-red: purple;