I have mushroom chip button that runs a script for my heating boost for 30 mins, but I have no way of telling that the script is running. I want the icon to change colour whilst it is running and revert back to normal when it is not. What is the best way to do this, as below does not work?
icon_color: |
{% set last = states.script.my_script.attributes.last_triggered %}
{% set condition = last is not none and now() - last < timedelta(minutes=30) %}
{{ 'amber' if condition else 'grey' }}
If script is running then the current attribute is greater than 0, so you can test for that. Usually it is 1 but script that can run in parallel can have 2 or higher.
What you have should also work (on scripts, not on automations - the current attribute works there too), but there are quotes after none, but not before. Test your template in developer tools first.