Man/Auto mode switch

For completeness, I experimented

My custom icon set in /classic/icons
beam.png
beam-open.png
beam.closed.png
Each is a visibly different image.

Stealing a URL from my UI and using it directly in OH2.5 e.g.

http://localhost:8080/icon/beam?format=svg&anyFormat=true
(valid name, no state)
displays beam image, as we’d hope.

http://localhost:8080/icon/beam?format=svg&anyFormat=true&state=closed
(valid name, valid state)
displays beam-closed image, as we’d hope.

http://localhost:8080/icon/beam?format=svg&anyFormat=true&state=apple
(valid name, unknown state) displays beam image, again as we’d hope.

Now to “break the rules” …
http://localhost:8080/icon/beam-closed?format=svg&anyFormat=true
(naughty hyphen name but exists, no state)
shows beam-closed image. Naughty, but works.

http://localhost:8080/icon/beam-closed?format=svg&anyFormat=true&state=open
(naughty hyphen name but exists, valid state)
shows beam-open image. Oh, surprise.

http://localhost:8080/icon/beam-closed?format=svg&anyFormat=true&state=apple
(naughty hyphen name but exists, invalid state)
shows beam image, default.

http://localhost:8080/icon/beam-apple?format=svg&anyFormat=true
(invalid hyphenated name, no state)
shows beam image, default

http://localhost:8080/icon/beam-apple?format=svg&anyFormat=true&state=closed
(invalid hyphenated name, valid state)
shows beam-closed image

Conclusions:

If the UI supplies an icon request with no state (I have no idea whether any of the UIs may do that), you can get away with directly addressing a hyphenated icon.
It could happen with sitemap like - (because there is no Item to get the state of)

Text label="for pagination only" icon="myicon-off" {

But if there is a hyphenated icon name AND a state, then the picker discards the hyphenated part of the name (beam-closed) to extract a base name (beam), then builds a state-related name (beam-open). If that exists, serve it. If not, serve base/default version.
I expect the presence of state= in the URL invokes this process.

I was wrong about picker looking for say beam-open-closed.png, tried that and it doesn’t happen.

I’ll stick to my initial pronouncement - specifying hyphenated icon names in sitemap (or Item definitions) breaks the rules with unexpected results.

Does this logic explain your visible experience, Hans ? @hmerk

2 Likes

It surely explains it. I was just using visibility tag for text widgets, so never thought it could be an issue.

1 Like

Well @rossko57 that is a well thought out whitebox test and pretty agreeable conclusive results. I did have hyphens in my custom icon names - at first - and I concur , in that the results were neither predictable nor consistent.But when I replaced the hyphen with underscore, the UI/OH does no further processing and serves up the requested custom icon (provided it exists of course) without applying a suffix for the state when used in a sitemap - yet I think it does (add a state suffix) when using this in the .items definition.

Different functionality when using icon=“abc” (sitemap def, no state added to name), and < abc > (in items def , state is added to name) - at least that is my experience.

I am nowhere near the level of expertise as you, but I have read the dynamic icon text over and over and I am not sure whether your analysis and summary (which I agree with) is accurately documented?
https://www.openhab.org/docs/configuration/items.html#icons ? The way I read, is that it is inferred (re “Hyphens ( - ) are reserved for [Dynamic Icons]” , but not explicitly mentioning unpredictable results, nor does the sitemap syntax validator throw an warning when encountering hyphens in sitemap custom icon names. I am being too anal ??

I do not agree. Note that the functional “getting away with it case” in the sitemap relies on that sitemap line having no primary Item specified to get the state of.
Example

Text label="blargh" icon="rule-bender"`

is the rare exception where rule-bender.svg is served

It is not possible to use the icon specified in an Item definition like <bend-more> without actually specifying that Item in the sitemap

Text label="blargh" item="myItem"

and that’s going to look for bend-myitemstate.svg, defaulting to bend.svg

I did not try out the case of overriding an Item definition with a sitemap definition

Text label="blargh" item="myItem" icon="other-bending"

but I’m fully confident the process applies, and that would look for
other-myItemstate.svg and default to other.svg

It isn’t. It’s irrelevant (if interesting).
This what the docs say

  • Icon filenames may include lowercase letters, numbers and underscores ( _ )
  • Hyphens ( - ) are reserved for Dynamic Icons

Them’s the rules.

2 Likes