Define icon for a channel in ESH-INF/thing/ xml file?

In the ESH-INF/thing/*.xml file, one can define labels, units and other parameters, for a channel-type; and these parameters get inherited by default by any item that links to channel of that type. So I wonder if it is possible to include an icon element in the xml description for a channel-type that can also be inherited by linked items?

I think the magic word here is “category”

Ah-Ha, I did wonder about that myself.

I am developing a binding for a thermostat, so the temperature channels would be category “temperature”, the home/away switch channel of category “presence”, and the heating on/off status channel of category “fire” :slight_smile:

I will test it and report back if it works…

Nope, it doesn’t work :frowning:

The documentation ( https://www.openhab.org/docs/developer/bindings/thing-xml.html#channel-categories ) says it is allowed – although the detail page “Categories Overview” link ( https://www.openhab.org/docs/concepts/categories.html ) is broken.

And the Eclipse XML Editor won’t allow category elements in its XML – apparently because the XSD schema does not mention it…

the cvc-complex-type.2.4.a: Invalid content was found starting with element 'category'

Over my pay grade, but you could rummage around the zwave binding which does provide device dependent icons. I’m sure that is done by “category” option of some kind/name, you cannot directly specify an icon with no idea if it might be present or what the UI wants etc. You’ll need to choose from predefined categories.

You might move your post to development category for the right attention.

I’ve no help but I moved this to the Development category where I think it is more appropriate.

Thanks @rossko57 and @rlkoshak both for your help.

I looked at the ZWave xml file ( https://github.com/openhab/org.openhab.binding.zwave/blob/master/src/main/resources/ESH-INF/thing/channels.xml ) and can see that they do indeed use category tags. So in theory I could try that too.

However as mentioned in my earlier post, in my case the Eclipse IDE chokes on such tags, because presumably they are not defined in the xsd schema (??). So I would still have to figure out a way to persuade Eclipse (and MVN etc.) to ignore the error and complete the build. => Anyone have suggestions on this?

EDIT: the Eclipse schema test failed in my case because I tried to put the “category” element before the “state” element. If the elements are in the correct order, then it builds Ok. :slight_smile:

Yesss! It works!!

In the channel-type definition enter a category tag/value that matches the name of one of the classic icons ( https://www.openhab.org/docs/configuration/iconsets/classic/#icons ) and the framework will take over that icon into any items that are linked to a channel of that channel-type.

EDIT: you may need to delete and re-create any old items in order to force the change…

Ah, so there’s no pre-defined list of categories, just the pre-packaged library of icons to choose from.

Yes that seems to be the case.