[Android app] Iconcolor on sitemap is buggy?

I have been trying out iconcolor on a sitemap (is that new in OpenHab 4?), but it seems buggy on the door icon.

When I try the following in a sitemap, icons turn always RED regardless of OPEN or CLOSED.

Default item=ContactSensor23_Contact labelcolor=["OPEN"="red"] valuecolor=["OPEN"="red"] iconcolor=["OPEN"="red"]

When I try the following in a sitemap, icons turn always GREEN regardless of OPEN or CLOSED.

Default item=ContactSensor23_Contact labelcolor=["OPEN"="red"] valuecolor=["OPEN"="red"] iconcolor=["OPEN"="red", "CLOSED"="green"]

Or should I do it differently? labelcolor and valuecolor behave as I would expect.
I am using the latest openhab version 4.0.2.

Can you provide your item definition?

Sure, here it is.

Contact  ContactSensor23_Contact     "Contact Sensor 23" <door>    (Label, ContactSensor_InsideDoors) { channel="mqtt:topic:aqaraContactSensor23:contact" }

In that case, you are using an OH icon and generally they have hardcoded color palette, so you cannot control its color.
Let me check the content of the door icon.

Confirmed.

If you want to comtol icon color, either add custom SVG icons using “currentColor” as fill color or use icons from another source (iconify, material, …).

You can probably copy & paste the code of the original OH icon to create a custom icon.

Thanks for the confirmation and suggestions for workarounds!

Actually, I just tried a door icon from iconify using “currentColor” as below. And the same problem remains. The icon always uses the color specified in CLOSED when using iconcolor=["OPEN"="red", "CLOSED"="green"]

<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16"><path fill="currentColor" d="M12 1a1 1 0 0 1 1 1v13h1.5a.5.5 0 0 1 0 1h-13a.5.5 0 0 1 0-1H3V2a1 1 0 0 1 1-1h8zm-2 9a1 1 0 1 0 0-2a1 1 0 0 0 0 2z"/></svg>

You created a custom OH icon or you simply referenced an iconify icon?
You are using what UI? Basic UI or Android app?

  • I am using the Android App
  • And I added the iconify icon to the folder /conf/icons/classic (where also the other custom icons reside)
  • And I simply referenced it from an Item (as above). So <mydoor> instead of <door> in the item definition
Contact  ContactSensor23_Contact     "Contact Sensor 23" <mydoor>    (Label, ContactSensor_InsideDoors) { channel="mqtt:topic:aqaraContactSensor23:contact" }

Sitemap is the same

Default item=ContactSensor23_Contact labelcolor=["OPEN"="red"] valuecolor=["OPEN"="red"] iconcolor=["OPEN"="red", "CLOSED"="green"]

I will try to reproduce your use case in Basic UI and the Android app.

Tested, it works well in Basic UI (requires to enable “inline SVG” option) with the icon being either red or green, but does not work in the Android app (icon is always red).
So it looks like a bug in the Android app, not in OH core framework.
image
image

Contact TestContact "Test Contact [%s]" <mydoor>
Default item=TestContact labelcolor=["OPEN"="red"] valuecolor=["OPEN"="red"] iconcolor=["OPEN"="red", "CLOSED"="green"]

And with mydoor.svg:

<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16"><path fill="currentColor" d="M12 1a1 1 0 0 1 1 1v13h1.5a.5.5 0 0 1 0 1h-13a.5.5 0 0 1 0-1H3V2a1 1 0 0 1 1-1h8zm-2 9a1 1 0 1 0 0-2a1 1 0 0 0 0 2z"/></svg>

@maniac103 and @mueller-ma for information.

After reloading the Android app while the item state is CLOSED, the icon is now always green.
This is either a problem of icon cache (in the app) or a miss of refresh handling when new state is received.

@Piscator : ideally you should declare an issue in GitHub - openhab/openhab-android: openHAB client for Android

@Lolodomo. Thanks for figuring out what the problem is. I made an issue on openhab-android as you suggest: see "iconcolor" is not updated on a state change (if so defined in a sitemap) · Issue #3466 · openhab/openhab-android · GitHub

Where can this option be found?
Edit: found it (Bindings → UI → Basic UI → settings icon)

That’s probably the case. iconcolor is not parsed from SSE events.
While this can be fixed easily, I wonder whether iconcolor always was present in SSE events, or was there a time / some versions where this was not the case?
Edit: found out that

  • the Android app has supported it since ‘forever’
  • you added it to the SSE event in February

This gets me to an interesting problem: when receiving an SSE event without iconcolor, is it due to iconcolor not being defined for that particular state, or is it due to the server not supporting it? On the other hand, since it was defined only for images, not for sitemap widgets in general before, I guess there’s about nobody who used it before and the use case ‘initiial widget JSON contains iconcolor and later SSE event cancels it out’ isn’t really relevant? Thoughts?

Another edit: PR to fix this

Yes, I believe you can assume it was never used. More generally the icon for image widget was never used until very recently as not supported by any UI.

Thanks for the quick analysis and the quick fix. Looking forward to the next release of the App!