Hello.
I leverage the custom button card often. I am specifically trying to set the animation style based upon fan speed. This is easily done when working with a single entity. I however want to build a template so I can apply this to all fans with out having to code out each fan. I am able to get the template completed on everything except for when it depends on pulling an attribute from the entity that its applied too.
Here is my current code:
styles:
icon:
- color: rgb(255,255,255)
- animation: |
[[[
if (states['fan.brayden_fan'].attributes.percentage == '25')
return "rotating 2.5s linear infinite";
if (states['fan.brayden_fan'].attributes.percentage == '50')
return "rotating 1.5s linear infinite";
if (states['fan.brayden_fan'].attributes.percentage == '75')
return "rotating .75s linear infinite";
return "rotating 0.5s linear infinite";
]]]
In that code you will see where it picks up the Percentage of the fan.brayden_fan entity_id. How can I replace that with the entity that it is applied to so that I can use that code in a template.