I have been working on dashbords. I want a tile to display the status of my Abode alarm system. I was able to do that using a String Hub Variable with a variable tile. So I am thinking it would be nice if I could get that variable tile to change color based on the String.
You can do that by manually editing the JSON Template in the dashboard settings under advanced.
You can add to the "customColors" section. Add sections for each value color you want. In this Case, the color is changed based on "OK" value in the state line:
I'm thinking now it must be made into a variable connector on the Hub Variables page for this to work. Then you add the variable connector device to the dashboard, and choose Variable String template for that device.
I haven't tried it with a non connector variable, apparently. That also explains why I felt the need to throw in the CSS to change the title that I use, as when you use a connector device on the dashboard, it just gets the title of "variable".
Sorry about that, it adds a bit more to it to have to add the CSS to change the title of the tile so it will not just read variable. If the title does not look like it is in the right place, play with the left and top % to get it where you want it.
Turns out all I needed to do after converting to a connector, was to relocate the default "state" to the bottom of the custom color section. The CSS part was not needed. Thank you for pointing me in the right direction. I learned a lot from this exercise.
Ah yes, I have seen where the default state messes with custom colors for templates like string-variable and attribute. You could just get rid of default state as well. Glad you got it working! Attribute template is handy with modified json too, to change colors based on any attribute value from any device.