Getting the item icons in a given PNG format


I’m running openHAB3 on an Arch Linux based distribution and all is well when using the web interface or even the android application.

But now I’m trying to render sitemaps on an embedded platform which uses a very specific chip to interface with the LCD screen.

This platform can retrieve the sitemap JSON just fine and I wrote the code to interpret it and render the appropriate elements for my use case.
The chip even has the ability to decode PNG content, so I decided to leverage this capability by fetching the icon data with URLs of the following kind:

http://server:8080/icon/temperature?state=25.8&format=png http://server:8080/icon/rollershutter?state=43&format=png

This gives me PNGs file with transparency which displays fine in a web browser. However, on the platform that I’m using, the second one is not accepted.

Reading the documentation for that chip, it is clearly indicated that only images with a bit depth of 8 are supported. The image for temperature is a paletted 8 bit ARGB PNG but the one for rollershutter is sent as a 4 bit ARGB PNG.

The choice to use the smallest possible file size makes perfect sense from a network point of view, and I agree that the chip that I’m using is not respecting the PNG standard that clearly states that any format should be accepted when decoding.

That being said, I’m writing this message to ask whether it is possible to indicate the kind of PNG that gets generated by the above kind of URLs.
Now, looking at the code inside, I could not see any query string parameter that would appear to have the effect that I’m looking for.

In my mind, the PNG returned by these URLs are generated on the fly from their SVG equivalent which explains my search for rendering options.
However, could it be that these are only files stored in the installation folder? In which case, I believe that creating a specific icon set for this platform with files in the expected format should work.

Does all this make sense? Any comments are most welcome.

Can’t you just use the ordinary ‘custom icon’ methods to serve images that you have prepared that are suitable? You can always base them on copies of standard icons, just give a unique filename.,

Yes, that’s the possibility that I’m wondering about in my last paragraph, but because the icon name is from the sitemap itself, I can’t simply add “custom” icons to the classic iconset.
I would have to create my own iconset based from the classic one, but having reworked the PNG files.
Right now, there is nothing in the $OPENHAB_CONF/icons/classic/ folder which leaves me wondering how to proceed from there.
I mean, I can send that kind of URL:


but where should I put the files, and from where can I get the “classic” ones?

I don’t think that’s the case. The pngs delivered are pre-rendered and not rendered on the fly when they are requested. You need to create your own custom set of icons per the custom icons docs.

The default set of icon files are inside the openHAB’s kar file. I’m not really certain where that file is these days on a typical installation.

That’s the right folder to put them in. See Items | openHAB

You can download the icons individually from Icons | openHAB or you can find the kar file and unzip it and explore the folder structure to find them.

The way the iconpicker server works is it fetches from a set of predefined standard icons. No idea where those come from, but who cares.
If the name is not on the list, it looks in icons/classic. You don’t have to do anything special except give your icon a unique filename that is different from any built-in icon.
i.e. sitemap
Text item=blah icon="fred"
will look in icons/classic/ for fred.png or fred.svg depending how your UI requests it.
You don’t have to tell it that’s a custom icon, it finds out.

There are a few rules about naming - lowercase, hyphens only when using dynamic icons - spelt out here

1 Like

Ok, after a bit of research, the source files are in the openhab-webui project, here

With the help of ImageMagick convert command line tool, I was able to create a png32 version of all the PNG files, and then I placed them in the following folder:


With this, I can get the desired content with the iconset argument added to the URL like this:

So clearly, even if I could not identify it, there is code in openHab that looks in subfolders of $OPENHAB_CONF/icons named as the given iconset name when it searches for a given image.

This is much cleaner than creating the converted files, adding a prefix/suffix and placing them all in the classic folder as this way, they live in a clearly identified folder.