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

[Sitemap] Add optional conditional rules for icon #3820

Merged
merged 2 commits into from
Oct 15, 2023

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Oct 2, 2023

This allows dynamic icons based on items states even with non OH icon sources.
This also allows overwritting the default handling with state done by the icon servlet.

Example: icon=[item1>0=temperature,==0=material:settings,f7:house]

Related to openhab/openhab-webui#1938

Closes #1046

Signed-off-by: Laurent Garnier [email protected]

@lolodomo lolodomo requested a review from a team as a code owner October 2, 2023 18:16
@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 2, 2023

Please note that this enhancement of the sitemap syntax remains fully backward compatible.

@openhab/android-maintainers
@openhab/ios-maintainers

The boolean staticIcon returned by the sitemap REST API will tell you if you have to use or not the item state when requesting the icon.
The SSE event will contain 2 new fields: icon and reloadIcon. icon will contain the icon reference, this field was already existing but was never set by the server until this change. reloadIcon (boolean) will tell if you have to reload or not the icon.

@maniac103
Copy link
Contributor

And when receiving SSE updates, either the icon field is filled and you must reload the icon, or it is null and you must not reload the icon.

I'd rather want to see 'null means no icon' in SSE events as well. Otherwise there's ambiguity between 'null means no icon' and 'null means no change'.

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 2, 2023

And when receiving SSE updates, either the icon field is filled and you must reload the icon, or it is null and you must not reload the icon.

I'd rather want to see 'null means no icon' in SSE events as well. Otherwise there's ambiguity between 'null means no icon' and 'null means no change'.

In that case, an additional boolean field would be required to indicate if the icon must be reloaded or not. I can call it reloadIcon. Is it ok for you ?

@maniac103
Copy link
Contributor

It's fine as far as I am concerned. The Android app doesn't need it either way since the OkHttp layer uses the URL (built from icon, state etc.) as caching key, so if there's no change in the parameters used for building the URL, no reload will happen.

@lolodomo lolodomo force-pushed the sitemap_dynamic_icon branch from 70e3b19 to 6b3e5e9 Compare October 2, 2023 20:15
@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 2, 2023

Changes done, I have updated my second message.

This allows dynamic icons based on items states even with non OH icon sources.
This also allows overwritting the default handling with state done by the icon servlet.

Example: icon=[item1>0=temperature,==0=material:settings,f7:house]

Related to openhab/openhab-webui#1938

Signed-off-by: Laurent Garnier <[email protected]>
@lolodomo lolodomo force-pushed the sitemap_dynamic_icon branch from 6b3e5e9 to df0a21c Compare October 2, 2023 20:58
lolodomo added a commit to lolodomo/openhab-webui that referenced this pull request Oct 4, 2023
lolodomo added a commit to lolodomo/openhab-webui that referenced this pull request Oct 7, 2023
lolodomo added a commit to lolodomo/openhab-webui that referenced this pull request Oct 7, 2023
lolodomo added a commit to lolodomo/openhab-webui that referenced this pull request Oct 7, 2023
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks.

@kaikreuzer kaikreuzer merged commit 7281dca into openhab:main Oct 15, 2023
2 checks passed
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Oct 15, 2023
@kaikreuzer kaikreuzer added this to the 4.1 milestone Oct 15, 2023
@lolodomo lolodomo deleted the sitemap_dynamic_icon branch October 15, 2023 23:40
kaikreuzer pushed a commit to openhab/openhab-webui that referenced this pull request Oct 26, 2023
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Dec 16, 2023
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Dec 16, 2023
stefan-hoehn pushed a commit to openhab/openhab-docs that referenced this pull request Dec 16, 2023
* Sitemap: extended syntax for icon to define conditional rules

Related to openhab/openhab-core#3820

Signed-off-by: Laurent Garnier <[email protected]>

* Considers review comments

Signed-off-by: Laurent Garnier <[email protected]>

---------

Signed-off-by: Laurent Garnier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add iconvalue attribute at sitemap
3 participants