Change Text Color on State

Hi All,

I currently have a tracker on my iphone, which when on my wifi, show’s me at home, when disconnected it shows me as away - I was wondering if it was possible to change the text color when the state changes - I tried the following code, but I still just get black text:

device_tracker.iphoneno1:
     friendly_name: Number 1 iPhone
     templates:
       theme: if (State === 'home') return 'green'; else return 'red';

Is it actually possible to change the text color?

Thanks

Do you have the custom-UI installed that supports that?

I didn’t think I needed a custom UI? I’ve just got a themes section in my config that has a red theme and green theme?

The themes in the standard HA only allows you to theme the entire frontend all at once. There is no example in the HA themes docs that say you can do it like you are trying to do.

I see in the Lovelace UI that you can set a theme for the entire card but I still don’t see anything about templating a theme for an individual entity.

OTOH, if you look in the docs for the custom-ui from @andrey in the “templates” section you will see pretty much the exact format of the code you are trying to use above.

https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/templates.md

If this has been integrated into I can’t find any documentation for it. But that doesn’t necessarily mean it’s not there but just that I’m not aware of it.