rule "Temperature Icon"
when
Item Temperature received update
then
if (Temperature.state >= 27) {postUpdate(TemperatureIcon, 27) }
logInfo("TemperatureIcon", "TemperatureIcon: " + TemperatureIcon.state)
postUpdate(TemperatureIcon, TemperatureIcon.state)
end
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
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]
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”.
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.
rule "Icona Temperatura Termostato Sala"
when
Item iSala_Actual_Temp changed
then
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)}
end
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:
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”.
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
}
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.
If I remove the icon(s) completely from the icon directory while only leaving the “heating.png” -> it still reacts dynamically.
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”
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. myheating.png