Real dynamic Icons

Deal all,

i am using openhab2 now for approximately one year to control MAX!-thermostat valves. Each valve has one temperature value that can be set and is delivering a lot of usefull additional information such as current temperature, battery-level, error-codes, etc.

In openhab2 all this informations are available as individual items like for example:

Number livingroom_temperature_SP "Solltemperatur [%.1f °C]" <radiator> {maxcul="RadiatorThermostat:OEQ0943872"}
Switch livingroom_temperature_BAT "Batterie [%s]" {maxcul="RadiatorThermostat:OEQ0943872:feature=battery"}
Number livingroom_temperature_MT "Isttemperatur [%.1f °C]" {maxcul="RadiatorThermostat:OEQ0943872:feature=temperature"}

I now want to combine all this informations to a single “real dynamic” icon that is dynamically created for example by external code. Each time one of the items is changed i want to execute a program that overwrites the icon.png file. I know that this can be done in a rule via executeCommandline-option.

But how can i trigger openhab to reload the specific icon file?

Is it possible to load the icon file from a induvidial location, for example in an RAM-Disk allocated place like /tmp/ ?

Best regards,


Hi flashbanger,

what about a bit different approach.

In your itemfile you create another item


in a rule file you set this item according to some rules

if() {
livingroom_temperature_ICON = hot
} else {
livingroom_temperature_ICON = batlow

and in your sitemap you refer to livingroom_temperature_ICON, but assign a dynamic icon to it - so everything is taken care of by normal dynamic icon handling.

  • icon1: livingroom_temperature-hot
  • icon2: livingroom_temperature-batlow

Thank you Michael for the quick answer.

How i understand your approach i will end up with multiple icons for one physical device on my sitemap.

Having in mind that each device got at least 4 independent objects (temperature, battery, valve-position and error-state) this would blow up my sitemap and especially in the android app this will be very ugly.

That was my intention to dynamically create the icons each time the properties of a thermostat changes.




no. You only have one icon per device. The icon will change automatically when the value of your icon-item changes.

see e.g. the classic items for light. You have one icon “light-ON” and one “light-OFF” (plus one default icon “light”).
And if you now assign the icon “light” to an item,

  • The icon “light-ON” is displayed when the item gets the value “ON”
  • The icon “light-OFF” is displayed when the item gets the value “OFF”

Cheers Michael

This might be where you use visibility to hide several versions of the line and show one.

The self made icons are only loaded from $OH_CONF/icons/classic.

I think what Michael is suggesting is you take advantage of rather than overwriting the one icon.png over an over.

Your display Item’s state will consist of the combination of all the information you want to base the icon upon. Your dynamic icon generation code will create an appropriately named .png for that combination of states. As the display Item changes state the UIs will load the newly created icon.

I did something similar in Comprehensive Wunderground using HTTP Binding Example with the main difference being I just copy the icon instead of creating it from scratch.