Template sensor icon

Is it possible to have the icon of a template_sensor mirror the icon of the underlying entity?

Specifically:
I want to have a template_sensor based on a switch. When the switch is on the sensor should display the yellow lighting flash icon and when off display the icon that is not yellow.

yes, you’d need to make sure your sensor is a binary_sensor.

1 Like

Yes, here example of weather template, “sensor.yr_symbol” is original sensor, and “sensor.weather” is new sensor taking icon from original with “entity_picture_template” line

sensor:
  - platform: template
    sensors:
      weather:
        value_template: '{blablabla}'
        entity_picture_template: "{{state_attr('sensor.yr_symbol','entity_picture')}}"
1 Like

Thank you to both of you!

EDIT:
But…
@g0g0 this may work if the sensor is based on another sensor but unfortunately doesn’t seem to work with a sensor based on a switch.

@lolouk44 I tried a binary_sensor based on my switch buit that didn’t work either. Is there something else I need to add?

I simply want ot display the state of a switch using the lightening bolt icons in the front end without allowing it to be changed.

tried like this?

    entity_picture_template: "{{state_attr('switch.myswitch','entity_picture')}}"

The Template binary_sensor has an icon_template that you can use:

I take it it was the icon you wanted to change, not the picture…
the icon is mdi:flash:

Or you could always set the icon in your customize area, but that’s kinda old school / not the way to go anymore,