I am trying to set the fan icon rotation speed based on fan speed percentage. The below jinja2 code is not being executed/ no action performed (i.e. fan icon is not rotating). Kindly help me in identifying and fixing the issue.
What you posted seems like a code for a custom button card (not mentioned in your post) with jinja templates (which are not supported by this card). The card supports templates in JS, see examples in the card Docs.
Noob question. I am getting “Unable to parse YAML: YAMLException: missed comma between flow collection entries” error for below modified code with JS. Am I missing something?
state:
- value: 'on'
styles:
icon:
- animation: |
[[[
if (entity.attributes.percentage == 0) {
return 'none';
} else if (entity.attributes.percentage <= 33) {
return 'rotating 2s linear infinite';
} else if (entity.attributes.percentage <= 66) {
return 'rotating 1s linear infinite';
} else {
return 'rotating .5s linear infinite';
}
]]]
- value: 'off'
styles:
icon:
- animation: none