Dynamic Icons for temperature

hello, today i’m trying to show different icons based on temperature.

i’ve tried to use this config for items file:

Number Temperature "Temperatura [%.2f °C]" {weather="locationId=home, type=temperature, property=current"}
Number TemperatureIcon "Icon Temperature"

for sitemap:

sitemap astro label="Meteo" {
                Frame label="Meteo Attuale" {
                Text item=Temperature icon="temp-27" visibility=[TemperatureIcon==27] 

and for rules:

rule "Temperature Icon"
              Item Temperature received update

              if (Temperature.state >= 27) {postUpdate(TemperatureIcon, 27) } 
              logInfo("TemperatureIcon", "TemperatureIcon: " + TemperatureIcon.state)
              postUpdate(TemperatureIcon, TemperatureIcon.state)


i have placed icons named temp-0.svg, temp-1.svg, temp-2.svg, temp-3.svg, temp-4.svg into folder /icons/classic but i cannot show the icon when temp exceed 27 °C.
i just want to make
when temp is < 0°C -->show icon temp-0.svg
when temp is between 0°C and 15°C -->show icon temp-1.svg
when temp is between 16°C and 20°C -->show icon temp-2.svg
when temp is between 21°C and 25°C -->show icon temp-3.svg
when temp is between >26°C -->show icon temp-4.svg

can anyone please help me?


if      (Temperature.state > 25) {TemperatureIcon.postUpdate(4)} 
else if (Temperature.state > 20) {TemperatureIcon.postUpdate(3)}
else if (Temperature.state > 15) {TemperatureIcon.postUpdate(2)}
else if (Temperature.state > 0)  {TemperatureIcon.postUpdate(1)}
else                             {TemperatureIcon.postUpdate(0)}
Text item=Temperature icon="temp-0" visibility=[TemperatureIcon==0] 
Text item=Temperature icon="temp-1" visibility=[TemperatureIcon==1] 
Text item=Temperature icon="temp-2" visibility=[TemperatureIcon==2] 
Text item=Temperature icon="temp-3" visibility=[TemperatureIcon==3] 
Text item=Temperature icon="temp-4" visibility=[TemperatureIcon==4]

thanks for reply, but doesn’t work.
in Chrome i get this link error:

GET 404 (Not Found)

in sitemap i cannot see the temperature entry (nothing displayed)

I seems to be a general problem with you icons.
Start testing with

Text item=Temperature icon="temperature"
Text item=Temperature icon="temp-0"
Text item=TemperatureIcon label="ti[%s]" 

Text item=Temperature icon=“temperature”
Text item=Temperature icon=“1”
Text item=TemperatureIcon label=“ti[%s]”

attached you can find the screenshot.
the problems seems to be to have iconname-1.svg
renamed in 1.svg the icon is shown.

so how can i update my rules and my sitemap to match it?

Take my example and modify it. You will find the solution yourselve.

Try a other way. Save your icons as youriconname.svg youriconname-16.svg, …-21.svg, …-26.svg and use icon=“youriconname” in the sitemap without rule and visibility.

i’ve tried copying the “1.svg” (that works in sitemap) to “test-1.svg” and it doesn’t work. simply the icon in sitemap wont’ be shown.
i can suppose the problem comes when i use “iconname-” prefix…

EDIT: ok so, the rule works and also sitemap update. the only thing to be remembered, is that icons must NOT have prefix. in this case i’ve used “0.svg”, “1.svg”, "2.svg, “3.svg”, “4.svg”.

thanks for help!

Number Temp "Temp[%.1f °C]" <thermometer>
sitemap tmp label="TMP" {
    Setpoint item=Temp






A late update to the above post.
I was scratching my head while testing dynamic icons e.g. temperature-20.png and so on. (OH 2.4 M4)
Discovered that it doesn’t work properly with a combination of Setpoint in the sitemap and ClassicUI. Only the default icon temperature.png is fetched and displayed.

The same setup works fine in BasicUI.
The same setup works fine in ClassicUI for a Text sitemap line.

In my case the setpoint is only a development aid for proving rules action so I don’t care really, but it is a puzzling trap if you’re using setpoint for real.

i’m lost because maybe something is missing:

rule "Icona Temperatura Termostato Sala"

     Item iSala_Actual_Temp changed
     if (iSala_Actual_Temp.state >= 25) {TemperaturaIIcon.postUpdate(4)}
     else if (iSala_Actual_Temp.state >= 20) {TemperaturaIIcon.postUpdate(3)}
     else if (iSala_Actual_Temp.state >= 15) {TemperaturaIIcon.postUpdate(2)}
     else if (iSala_Actual_Temp.state >= 0)  {TemperaturaIIcon.postUpdate(1)}
     else {TemperaturaIIcon.postUpdate(0)}

items (i’m not sure the TemperaturaIIcon must be as Number):

Number TemperaturaIIcon "Icona Temperatura interna"

Number:Temperature iSala_Actual_Temp "Sala [%.1f °C]" <temperature> (gTermostatoSala, gSala, gTemperature) [ "CurrentTemperature" ] { channel="openwebnet:bus_thermostat:LCD:TermostatoSala:temperature" }


sitemap test label="Termostati" 
Text item=iSala_Actual_Temp visibility=[TemperaturaIIcon==0]
Text item=iSala_Actual_Temp visibility=[TemperaturaIIcon==1]
Text item=iSala_Actual_Temp visibility=[TemperaturaIIcon==2]
Text item=iSala_Actual_Temp visibility=[TemperaturaIIcon==3]
Text item=iSala_Actual_Temp visibility=[TemperaturaIIcon==4]

obviously my icons are called “0”,“1”,“2”,“3”,“4”.


The dynamic icons for setpoint items have been fixed in the last OH release M7.
You may want to give that a go.

This will not work.
Your icons are named icon-0., icon-1.… but the icon displayed will depend on the value of iSala_Actual_Temp
So your icons will only be displayed when the temp is quite low, If above 4c you will see icon-4.
Did you define an icon: icon.* for the default

Because the value depends on iSala_Actual_Temp rename your icons:
temperature.* , temperature-0.* , temperature-15.* , temperature-20.* , temperature-25.*

And your sitemap

sitemap test label="Termostati" 
Text item=iSala_Actual_Temp

No rule needed and No Icon item

so, temperature.png/svg is used when no value is retrieved for device, otherwise if i have 21.5 °C, it will use temperature-21.png/svg.


thanks a lot!!!

1 Like

You don’t need to create an icon for each temperature
Between 20 and 24.99 it will use the temperature-20 icon

many thanks! easier than expected and working!

thanks a lot again!

And bear in mind you must have the default iconame.png/svg even if you never expect to see it.

The possible number icons are a bit limited to the 0-99 range (because they were invented for dimmer percentages).
If you expect subzero temperatures, for most of us it works well enough to have your snowflake icon or whatever as the unnumbered default.

That falls down if you have numbers 100+ or want to distinguish between different negative zones. Then you would have to resort to a virtlual linked icon that scaled the real values to the 0-99 range, as you attempted.

1 Like

ok perfectly clear! these are for internal thermostats, so i hope i will never go below 0 degrees :wink: but i will keep in mind for external temperature :wink:


I’m busy trying the same thing and have “issues”.

I’m playing with the dynamic icon “heating”.

  1. If I remove the icon(s) completely from the icon directory while only leaving the “heating.png” -> it still reacts dynamically.
  2. As I would like to trigger the icon’s 5 steps at different t° like: 5, 11, 18, 19, 21 I tried renaming the 5 icons as “heating-5.png”, “heating-11.png”, etc…
    But it doesn’t match reality. It even sometimes goes the opposite way ?
    This is my sitemap command: Setpoint item=Thermostat_2 step=0.5 minValue=4.5 maxValue=25 label=“Target Temperature [%.1f °C]” icon=“heating”

Any idea ?
Tx :slight_smile:

Don’t try to use the same name as any of the default system icons library. You cannot remove the built-in icons, just use another filename.
Hover for filenames. “heating” is one of the system icon sets.

Usual notes apply -
You must have a root/default icon, even if you never expect to see it. This is not a nice-to-have, it just will not work without.