OH2 idea for dynamic icons for items

At first, I’m afraid my English is a bit rusty.

I dont know if i post it in the rigth way. I have an idea.

I try to show the weather data in the UI and will post the correct weather icon(sun_clouds, sun…) for an String item with infomation like “Überwiegend Bewölkt -1.5 °C / 2.7 °C”, but i see no solution at the moment. My idea is that the “icon”-option can set by an additional Variable an other item for the dynamic part. So i can display the date “Überwiegend Bewölkt -1.5 °C / 2.7 °C” and the icon is related to a other item(“weather_cond_short”) with the dynamical data “sun”, “stormy” or “snow”…
The icon definition on the item can be fro example:


the reladed icon file for that ist for example:

“weather-sun.png” or “weather-snow.png”

Maybee other people haves the same problem like i and it would be an good solution if a function like that would implement in OH2.

BR Rene

It’s a good idea. It would be nice to have it implemented. Post an issue on GitHub as a request. Not sure if all providers return the same strings though. You could do this with your own icons though. I think you would just need some mapping.

Edit: That looks like what the CommonId and custom icons are used for here.

It is only an example with the weather icons, i would use this for some other items.
I hope this will se a developer and find it an good idea.

BR Rene

So I was able to accomplish my idea however it looks like you want to ‘cross’ data. Use the condition property for the icon and the temperature property for the text string. Is that correct?

No, i will use for the text an string with the information of the day, minimum temperatur and maximum temperatur, for example like this: " Monday -0.4 °C / 2.0 °C" and the icon for “snow”.

I read the post in your link, but it is for Openhab1.8 and not for Openhab 2.

That’s what I was asking. The text string is one item and the condition is another. I don’t think you can display a dynamic icon for one item with another item (specifically it’s string). By the way, how exactly are you getting a string with the Day, Min, and Max in it? (I run wunderground so maybe this is possible with another provider)

Uh huh. And where have you found one for 2?

I actuall have no string with the data, because i need at first the correct icon. But i have at the moment these string:
"Überwiegend Bewölkt -0.4 °C / 2.0 °C "

Here my creation of this string:

Temp_MinMax_heute.postUpdate(" " + String::format("%.1f", (Temp_Min_heute.state as DecimalType).floatValue()) + " °C / " + String::format("%.1f", (Temp_Max_heute.state as DecimalType).floatValue()) + " °C")
var mappedWeathercond_heute = transform(“MAP”, “weather_de.map”, Weathercond_heute.state.toString)
weather_heute.postUpdate(mappedWeathercond_heute + " " + Temp_MinMax_heute.state)

I have not found something for OH2 in the posted link, i found this:

“(This does not work for OpenHAB2 and this WIKI needs an update for how to use this on OH2)”

That is referring to a Webview (html layout of weather). That makes a little more sense now… You’re able to do some manipulation there, whereas in a sitemap or item file you cannot. That wasn’t clear in your post.

My solution to the condition icon in a sitemap was to download the icons, convert them to svg, throw them in the icons/classic folder, then rename them all to have condition- as a prefix (condition-cloudy.svg). Download the map file. I changed mine to condition.map.

String   	CommonId         	"[MAP(condition.map):%s]"	  	<condition>		(gWeather)	{ weather="locationId=home, type=condition, property=commonId" }

If you are wanting a Webview in your sitemap, it’s been submitted as an issue/feature request. https://github.com/openhab/openhab/issues/4532

But people have gotten it to work. Here

@awsnap: I will look for the solution for the weather binding. But i also will place a request for my idea in Github, but i don’t foind the rigth place. Can you post a link to the correct github-place i can post it?

That’s the tricky part… It’s not an OH2 specific addon yet, it’s still 1.9. I THINK it would go in openhab/openhab. If it doesn’t, I’m sure someone will move it.

Thanks for the link.I posted an request.


I’m facing the same problem.
Has anyone found a solution for a dynamic ICON?

What addon are you using? In oH2? or 1.x?