Is there a way to access an entity's state when setting its icon? Like {{ state }}

I have some MQTT and Template sensors whose icon I want to change based on the state. The state templates for some of these are pretty complex, and I want to avoid code duplication when writing their icon templates. Is there a magic variable we can use to access their states, like {{ state }}, or do we have to just use states('sensor.name_here') by referencing its own self? (The latter isn’t preferable since you’d have to update the entity ID in multiple places if you want to change it.)

This one:

1 Like