I have multiple widgets in my HabPanel wich show states of some items (e.g. Battery (Off->okay; On->empty)).
Is it possible to change the background color of the Widget based on the state (e.g. OFF->Green; On->Red)?
I’m a complete Newbie in OpenHab. Thanks for your help.
Greetings from Germany
I don’t think that you can do this for the “standard” widgets (like switch etc)
You could try to use a template and do the following:
<div style="position: absolute;
left: -10px; right: -10px;
<img ng-src="../static/HomeR/Motion/Disarmed.png" style="position: absolute; top: 5%; left: 55%" />
<img ng-src="../static/HomeR/Motion/Armed.png" style="position: absolute; top: 5%; left: 55%" />
In this example, I change the image (not the background) based on the state of my item (it’s String type)
Maybe you can play with the
ng-if code and change the background too… not sure
Have a look here
If you want to keep things simple, the standard Button widget can also act as a Switch.
Just set it up like so:
Action type to Alternate item between 2 states
Command value to ON
Alternate command value to OFF
There are options in the Active and Inactive tab to configure colors for the “active” state (ON in this case) and others.
Thanks. To use a button… very simple idea.
Very helpful hint!
I needed a few days to find this out.
This should be way easier.
Alternate command value: CLOSED
View: disable “show value”
Inactive-Tab: both to “transparent”
Active-Tab: Background to red, Label to black.