Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Category not propagated reliably in sitemaps to BasicUI and OH-Android #3958

Closed
dilyanpalauzov opened this issue Dec 24, 2023 · 10 comments
Labels

Comments

@dilyanpalauzov
Copy link
Contributor

At openhab/openhab-android#3427 and openhab/openhab-webui#1938 I have asked to see updated icon, once I change the “category”. I have this

rule "E1, E2, E3 on/off change"
when
  Item e1 changed or
  Item e2 changed or
  Item e3 changed
then
  (ir.getItem(triggeringItemName + "_power") as NumberItem).category = switch ir.getItem(triggeringItemName).state {
  case ON: 'on'
  case OFF: 'off'
  default: null
  }
end

The resolution of the above items, including #3819 and #3820, was to extend the syntax for icon in sitemaps, to support AND, staticIcon and others. I have updated now to OpenHAB 4.1 . I open a sitemap in two browsers and in openhab-android 3.8.1-beta.

With the above rule I change the status of an item (e2) in one of the browsers. It appears in the sitemap as Text item=e2_power label="E2" labelcolor=[e2==ON="olive", e2==OFF="orange"]. So any time I toggle the state I expect that the label colour and the icon (category) change in the other browser and in openhab-android. I toggle the state many, many times. The label color does change reliably, every time I toggle the item.

The icon however does not change reliably. Often it does change, but sometimes it does not. Moreover the behaviour of the icon is consistent in the browser (Basic IU) and in openhab-android. The only difference is that in the browser sometimes, once the icon is out of sync, on a later state toggle, the icon changes its state several times very fast, while in openhab-android I cannot observe this.

An the symptoms appears in both Basic UI and in OH-Android, the problem must be in OH-core.

@dilyanpalauzov dilyanpalauzov added the bug An unexpected problem or unintended behavior of the Core label Dec 24, 2023
@lolodomo
Copy link
Contributor

Please read updated documentation
https://www.openhab.org/docs/ui/sitemaps.html#icons
You need to add conditional rules to icon parameter in your sitemap.

@lolodomo
Copy link
Contributor

For question, community forum is a better place.

@dilyanpalauzov
Copy link
Contributor Author

Rewriting the sitemap to change the icon will certainly work.

But I am writing here, that setting the category from a rule shall also work for icons in sitemaps. And indeed it does work sometimes. But sometimes it does not.

@lolodomo
Copy link
Contributor

Already discussed. Changing/hacking the category of an item inside a rule, even if made available by few rule engines, is not recommended and not officially supported, so you can't expect any UI to monitor this kind of hack for an immediate update in UI. Even Main UI will not support that. The official and supported way to update an item characteristics is to use the item REST API. I also implemented in 4.1 a clean solution for sitemaps to cover your use case, with a new dedicated syntax so that you can define conditional rules for your sitemap element icon.
@openhab/core-maintainers @openhab/webui-maintainers : please tell me if I am wrong or please close this issue.
By the way, it is a duplicata of openhab/openhab-webui#1938.

@florian-h05
Copy link
Contributor

florian-h05 commented Dec 26, 2023

Changing/hacking the category of an item inside a rule, even if made available by few rule engines, is not recommended and not officially supported, so you can't expect any UI to monitor this kind of hack for an immediate update in UI. Even Main UI will not support that.

This is the same as for other Item config, e.g. Item metadata. That configuration is meant to be static (at least was that the result from the discussion in openhab/openhab-webui#1725). Therefore, UIs won‘t ever monitor changes to Item config, and I also doubt that unauthorized users are even allowed to subscribe to these events over SSE or WebSocket.

I therefore agree to @lolodomo to close this issue, and I would also propose to rewrite the sitemap to dynamically change the icon.

Rewriting the sitemap to change the icon will certainly work.

Why? If it is a missing comparison operator, I am sure that someone is willing to work on that.

In case there is missing functionality inside the icon rules of sitemaps, please open a new issue to openhab-webui to request that functionality for icon rules.

@openhab/core-maintainers Please close this issue.

@J-N-K J-N-K added the invalid label Dec 26, 2023
@J-N-K
Copy link
Member

J-N-K commented Dec 26, 2023

@lolodomo and @florian-h05 have already explained why this is invalid. It is not expected to alter items this way.

@J-N-K J-N-K closed this as completed Dec 26, 2023
@J-N-K J-N-K removed the bug An unexpected problem or unintended behavior of the Core label Dec 26, 2023
@lolodomo
Copy link
Contributor

That being said and as we all agree, I am asking myself why some rule engines allow updating items in such a way ? IMHO, this is the root cause of all of this.

@florian-h05
Copy link
Contributor

Having this possibilities in the rule engines allows to programmatically create (or at least) modify Items. I mean that not in a way of dynamically changing configuration, but in a way of managing your Items.

E.g. if I want to change metadata or icon for a group of Items, in can just write a simple JS script instead of having to edit each Item manually. Of course better bulk editing in the UI would help here as well, but at least for me, writing a short JS script is the fastest way to bulk edit Items.

@dilyanpalauzov
Copy link
Contributor Author

By the way, it is a duplicata of openhab/openhab-webui#1938.

Yes it is. But back then manual reload was always necessary, while now sometimes manual reload is, and sometimes is not necessary - it is random. So something has improved in the meantime.

Rewriting the sitemap to change the icon will certainly work.

Why? If it is a missing comparison operator, I am sure that someone is willing to work on that.

I meant rewriting to use the syntax icon=[e3==ON=oh:classic:on, e3==OFF=oh:classic:off] does work.

@florian-h05
Copy link
Contributor

I am not sure what is your actual goal with the above example, but in case you want to perform some complex calculation to decide which icon to use, you can create a new icon where you store the result of that calculation to and decide based on the state of that Item which icon to use by using an icon rule.

dilyanpalauzov pushed a commit to dilyanpalauzov/openhab-docs that referenced this issue Jan 31, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Jan 31, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 24, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 24, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 24, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 24, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 24, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 25, 2024
dilyanpalauzov added a commit to dilyanpalauzov/openhab-docs that referenced this issue Feb 25, 2024
stefan-hoehn added a commit to openhab/openhab-docs that referenced this issue Feb 26, 2024
• insert the conclusion from openhab/openhab-core#3958

Co-authored-by: stefan-hoehn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants