Available icons

Hi,

I’ve been playing around with putting my OH1 installation to OH2. I have all my bindings working (more or less), and even most of my rules worked without any hassle :-).

I now trying to customise my sitemap. Again, most is worked quite well, but I’m not very happy about the default switch icon. It is difficult to see what the state of the switch is based on the icon, and to my eyes it looks upside down. I would therefore like to try to change it back to the original lightbulb if that is possible. I’ve tried adding a simple take to the item definition, but then I get some errors about it not being found.

How can I see which icons are available in OH2 now that the icons folder is no longer used?

I guess a simple workaround would be to copy the icons from OH1 to the userdata folder, but I’m not convinced that is the best way :slight_smile:

1 Like

This is indeed not yet documented anywhere.
What you need to do is to add your custom icons in conf/icons/classic. Note that the Classic UI uses by now SVG icons, so you would need a file conf/icons/classic/switch.svg.
If you just want to replace some icons by others, you can find the full existing icon set at https://github.com/openhab/openhab2/tree/master/bundles/ui/org.openhab.ui.iconset.classic/icons.

2 Likes

Thanks for the link. I tried switching the icon for a light switch to the “light” icon, but I did not get a corresponding icon in the site map. There is a light-on and light-off icon, but it seems that these are not picked up by the site map when displaying the state of the item. The same goes for humidity. Should this be represented in some other way in the item file to have the icon in the site map updated based on state?

If your “light switch” items are simple Switch items, then the icon that is used is “switch-on.svg” and “switch-off.svg” - you should therefore rename your light-xx.svg accordingly.
Please also note that you need to restart the runtime after doing changes, since these things are cached.

I see. So is it not possible to change the icons for a switch item or number item using the icon tag in the items file? I thought that was possible in OH1, but maybe I was mistaken.

Sohail will this work for for instance humidity? There are several humidity icons with numbers behind them, and one without. Items representing humidity with the “humidity” icon tag have a correct humidity icon, but it does not reflect the actual value of the number. Is this not supported in the classic UI for OH2? An example item is like this:

Number	OutdoorHumidity	"Outdoor Humidity [%.1f %%]"	<humidity>	(Humidity,Outdoors,Weather)		{ rfxcom="<7425:Humidity" }

Nothing should have changed about the way you can choose an icon in the items file. What is wrong with the <humidity> setting?

The icon doesn’t change according to the value of the humidity. The same goes for the light switches in the openhab android app, they remain off regardless of the state of the switch.

I’ll need some time to verify and analyze this. May I ask you to enter an issue at https://github.com/openhab/openhab2/issues for further tracking? Thanks!

I am seeing strange icon behavior as well. Some of the icons are giving 404s on both the mobile app and Classic UI. When I go to the actual URL being requested, I see the path is /icon/xyz.png but the folder on the system is icons/xyz.png note the plural difference.

Let’s take battery.png as an example. battery.png exists in the icons folder, but when I specify in a items file the flag, it does not get served, and is instead a 404. This makes sense if the path were all that was going on. There seems to be more though. The application is finding things requested at /icon even though that folder does not exist in the installed system. This folder must then be part of the app/jar file tree, and contain a subset of the icons in the icons system folder.

I have not looked very deep in the source code, but did find this comment in the IconForwarder:

  • This servlet answers requests to /images (which was the openHAB 1 location for icons)
  • with HTTP 301 (permanently moved) with the new location /icon

ClassicIconProvider says:

  • This icon provider provides the classic icons (dating from openHAB 1). They are packaged
  • within this bundle and served from there.

with:

URL iconResource = context.getBundle().getEntry(“icons” + File.separator + resourceName);

@Kai can you shed a little light?

I may be barking up the wrong tree. I seem to be comparing classicUI using png to other UIs using .svg

/icon/humidity?state=79&format=svg

is how it is displayed in the new BasicUI

/icon/humidity.png

is how it is displayed in ClassicUI.

These two images are different though, even when displaying the same value. One picture has a water droplet on it. It seems strange to me that they would be different… I am not using any custom icon sets. Should these not be the same image? If they are different, could this be part of the problem @frankose is seeing?

(edited for clarity)

It is clear that they are different. If you want the same image, you should try

/icon/humidity?state=79&format=svg
/icon/humidity-79.png

and

/icon/humidity?format=svg
/icon/humidity.png

Then you will have identical results, because the requests are asking for the same (either with a given state 79 or for the fallback icon).

since that link is not valid anymore I tried to find again all avaiable icons
I can use for BASIC UI.

Anybody a hint?

Hint: https://github.com/openhab/openhab2-addons/issues/667

well sorry gotta ask one more question in this thread

there are many icons that differ from OH1 to OH2

e.g.
bedroom oh1

bedroom oh2

sind in both cases its icon=“bedroom” … how can I have the oh1 style?
many icons look better there

You could come up with a contribution for an alternative iconset, which can be made available as a bundle (see https://github.com/kaikreuzer/openhab-core/tree/master/bundles/org.openhab.ui.iconset.classic).

Is there a way to stop openhab from requesting a state as part of the Get of the icon?

For example:
I have an icon EcoBeeTemp - the state of it changes based on the value.
I don’t care for the icon to change each time. I just want it to request EcoBeeTemp.svg

http://192.168.1.241/icon/EcoBeeTemp?state=73.3&format=svg1

When i trace it in the browser i see:
The query string goes out with the following parameters:
state=73.3
format=svg

My item is defined as follows:
Number remoteSensors_EcoBee_capability_temperature (gRemoteSensors) { ecobee="<[xxxxxxxxx#remoteSensors(EcoBee).capability(temperature).value]" }
There is lessthan EcoBeeTemp greaterthan in there after temperature but it gets cut out when i post it here in brackets

Use the </> button to format your item, then it should work.
Or try the "“openHAB *items code fences”.

</> button: <code goes here>
item fences:

<code goes here>
indent preformatted text by 4 spaces     Number	remoteSensors_ecobee_capability_temperature <EcoBeeTemp>	(gRemoteSensors){ ecobee="<[xxxxxxxxxx#remoteSensors(ecobee).capability(temperature).value]" }

Hello Kai,
is there an updated link - this runs in 404-error (page not found).
Thanks Georg

http://docs.openhab.org/addons/iconsets/classic/readme.html