I’ve just recently got OpenHAB 3.4.1 up and running in Docker, and added some Label widgets to the default overview page showing things like temperature, humidity, air quality, etc…
What I would like to do is have conditional formatting of the text displayed, depending on the value. So for example, if the VOC levels get too high, change the color of the text value to yellow, and if they get very high, change it to red to make it stand out.
It turns out, this actually isn’t trivial. The label cards just weren’t designed with this particular modification in mind. It is easy to change the color of the card itself; just use the background property and set it to whatever css background style you like. However, there’s just no direct access to the element that sets the color of the label’s text, so doing this is a multi-step process.
First you have to set a css variable using style object in some container above the card: