[SOLVED] Issue with valuecolor on derived item using another item's values

Hello all,

I am having an issue with valuecolor when assigning to derived item - it does not work as described in the documentation and i wonder what i did wrong…

I have a NetAtmo unit that can measure both actual temperature (as a number) and also reports trend as a string. I also use a string item to combine those.

Number            Apt_LR_Temperature            "Temperature [%.1f °C]"               <temperature>          (Apt_Temperature,Apt_LivingRoom)                                        [""]   {channel="netatmo:NAMain:fe908471:70ee50369ad0:Temperature"}
String            Apt_LR_Temp_Trend             " [%s]"                               <temperature>          (Apt_LivingRoom)                                                        [""]   {channel="netatmo:NAMain:fe908471:70ee50369ad0:TempTrend"}
String            Apt_LR_Temp_with_Trend        "Temperature [%s]"                    <temperature>          (Apt_LivingRoom)

In the rules I have the following code to update the combined string item whenever there is an update like this:

rule "update Apt_LR_Temp_with_Trend"
    Item Apt_LR_Temperature received update
    Apt_LR_Temp_with_Trend.postUpdate(Apt_LR_Temperature.getState().format("%.1f °C") + " (" + Apt_LR_Temp_Trend.state + ")")

Overall this works fine except that I cannot format the color of the combined string item based on the original temperature item.

The basic temperature item coloring in the sitemap works fine like this:

Text item=Apt_LR_Temperature valuecolor=[Apt_LR_Temperature=="NULL"="lightgray",Apt_LR_Temperature>=30="red",>25="orange",>=20="green",>=15="orange",<15="blue"]

The same formatting for the combined string item does not - always uses default color…:

Text item=Apt_LR_Temp_with_Trend  valuecolor=[Apt_LR_Temperature=="NULL"="lightgray",Apt_LR_Temperature>=30="red",>25="orange",>=20="green",>=15="orange",<15="blue"]

The way i read the documentation the item_name in valuecolor does not need to be the item actually being displayed right?

I see no errors or warnings in the logs…

Can you please point me to my mistake :slight_smile:

Thanks in advance!

  • Platform information:
    • Hardware: synology NAS
    • OS: synology DSM
    • Java Runtime Environment: not sure… whatever the docker has
    • openHAB version: openhab 2.4.0 running in a docker container

Try that:

Text item=Apt_LR_Temp_with_Trend  valuecolor=[Apt_LR_Temperature=="NULL"="lightgray", Apt_LR_Temperature>=30="red", Apt_LR_Temperature>25="orange", Apt_LR_Temperature>=20="green", Apt_LR_Temperature>=15="orange", Apt_LR_Temperature<15="blue"]
1 Like

Thank you very much! This did it!

I guess this has to do with how java interprets this perhaps?

Nothing to do with java. It’s the sitemap parser. Because you are using another item you need to use the item in every condition.