Change colour of device tracker badge dependant on state

Surprised I couldn’t find a previous example of this but I’m trying to achieve something like the example below…

Untitled-2

…so I can see at glance who’s home, which I know I could do with ‘hide if away: true’, but I’d like to keep the 'away’s visible so I can click the badge to see the time they left.

Any ideas?

1 Like

Solution is in the first few posts here…

Thanks to @andrey

1 Like

Actually this is all the info in one place. Nothing else worked for me but this has.

As of now the customization is broken for the top row of badges but not for the badges in cards. It affects Lovelace too.