Button state according to entity attribute state

I’d like to make button that has visual representation of entity state (on/off). For all standard applications state_color: true is enough, but for this particular buttons I’d like to use another entity attribute as trigger to change colour.


I’m using musiccast integration. My media_player has attribute “source: xxxx”. What I want is to use this attribute to trigger corresponding button color change, eg. source == spotify -> spotify button is yelllow, etc.
Is there any “easy” way to accomplish this? Probably it’s possible using template switches, but maybe there is easier method?