Dynamically altering value colors....... and color values?

I have a question on dynamically coloring numbers in the itemsfile.

Say I measure soil humidity with the following line in my itemsfile:

Number soil_moisture "Soil moisture [%.0f]" <icon> (group) {mqttchannel}

Then I can add colors to the outcome with a line like this in my sitemap file:

Text item=soil_moisture valuecolor=[soil_moisture>120="orange", soil_moisture>300="red"]

However, many items i never define in my sitemap: I simply define hem in my itemsfile in a group.

So, question 1:
Can i define a value dependend colorchange in the items file as well, or is it mandatory to do that in the sitemap.??
If not, too bad but so be it

Question 2:
In the example I define the value to turn red above 300, Suppose I want to be able to dynamically alter that colorflip value to any other value.
To clarify: say i use a different soil or sensor for which 250 or maybe 325 is a better value to flip the color, I want to b able to dynamically alter that say with a slider or a setpoint or simply an mqtt command. Is that anyway possible?

And ofcourse for both questions: if yes, how?

You have to do it in the sitemap.

I donā€™t think this is possible. You can try using an Item instead of a number in the comparison but Iā€™ve never seen anyone do it that way:

valuecolor=[soil_moisture>soil_mositure_orange="orange", soil_moisture>soil_moisture_red="red"]

Thanks Rich

  1. Clear. I was afraid of that already
    2 Thanks, I will experiment with that

Hello all,

I am working on the same thing. I have a ā€œsettingsā€ part on my sitemaps, where I can set min and max values for some items (i.e. a temperature sensor).
For these min-/max-settings, I created ā€˜virtualā€™ items which are (on every change) persisted to a mysql DB.
On the other hand, I use color formatting on the items which show the actual values (the actual temperature).

Now, I would like to combine the two, so that the color coding works with the items / entries from the settings part. Without this combination, it could happen that the color coding does not match the settings any more if someone made a change to the settings without adjusting the color coding in the sitemapā€¦

I tried this already:

Has anyone done this sucessfully yet?

Kind Regards,
Nadine

Well, like I said above, I donā€™t think that will work so if you tried it and it doesnā€™t work then you have your answer. You will have to use some other technique like a special item that combined the two items or using the visibility tag somehow.

I tried. Doesnā€™t work. Apologies for not giving that feedback earlier

Ok, I understand. Thanks for the info.

To get around this, I am now thinking about a rule which runs on every change of the original item (sensor information). The rule should check the two min / max ā€œsettingsā€ items and change the value of another (new) item which only carries the color information.
And then I could do the coloring of the sensor item based on the new color item.

Would that work? What do you think?

Kind Regards,
Nadine

Yes that could work

1 Like