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

Extend item syntax for category/icon #3539

Merged
merged 1 commit into from Apr 12, 2023

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Apr 11, 2023

The icon value can now contain until 3 segments separated by a semi-column.
First segment is the icon source. Example: oh, if, iconify, material, f7, ...
Second segment is the icon set. Example: classic
Third segment is the icon name (and can contain hyphen). Example: temperature

In case only two segments are provided, the first segment is the icon source and the second the icon name. "classic" icon set is assumed.
In case only one segment is provided, the icon source is assumed to be the openHAB server and its classic icon set and the value is then the icon name.

Ability to use a string containing anything has been removed.

Related to #3052

Signed-off-by: Laurent Garnier lg.hc@free.fr

@lolodomo lolodomo requested a review from a team as a code owner April 11, 2023 12:01
@lolodomo
Copy link
Contributor Author

lolodomo commented Apr 11, 2023

With the following items definition

Number:Temperature CurrentTemp2 "Current Temp [%.1f °C]" <temperature>
Number CurrentHumidity2 "Humidity [%.0f %%]" <classic:humidity>
Number CurrentPressure2 "Pressure [%.0f hPa]" <oh:classic:pressure>
String CurrentPressureTrend2 "Pressure Trend [%s]" <material::arrow_drop_down>
Number:Temperature SetpointTemp2 "Setpoint Temp [%.1f °C]" <iconify:wi:day-sunny-overcast> [ "Setpoint", "Temperature" ]
Number:Temperature SetpointTemp3 "Setpoint Temp [%.1f °C]" <if:wi:day-thunderstorm> [ "Setpoint", "Temperature" ]
String TestString2 "Test string [%s]" <material::favorite>

and this sitemap

sitemap test5 label="Tests"
{
        Frame label="Icon ref in items" {
                Default item=CurrentTemp2
                Default item=CurrentHumidity2
                Default item=CurrentPressure2
                Default item=CurrentPressureTrend2
                Default item=SetpointTemp2 iconcolor=["orange"]
                Default item=SetpointTemp3
                Default item=TestString2 iconcolor=["red"]
        }
}

here is the result in Basic UI:
image

@lolodomo lolodomo mentioned this pull request Apr 11, 2023
@lolodomo
Copy link
Contributor Author

It seems the build succeeded but with the now so famous final "Finished: UNSTABLE".

The icon value can now contain until 3 segments separated by a semi-column.
First segment is the icon source. Example: oh, if, iconify, material, f7, ...
Second segment is the icon set. Example: classic
Third segment is the icon name (and can contain hyphen). Example: temperature

In case only two segments are provided, the first segment is the icon source and the second the icon name. "classic" icon set is assumed if icon source is "oh".
In case only one segment is provided, the icon source is assumed to be the openHAB server and its classic icon set and the value is then the icon name.

Ability to use a string containing anything has been removed.

Related to openhab#3052

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

I finally changed the expectation when the icon value contains only 2 segments to be more compliant with Main UI syntax.
With the following items definition

Number:Temperature CurrentTemp2 "Current Temp [%.1f °C]" <temperature>
Number CurrentHumidity2 "Humidity [%.0f %%]" <oh:humidity>
Number CurrentPressure2 "Pressure [%.0f hPa]" <oh:classic:pressure>
String CurrentPressureTrend2 "Pressure Trend [%s]" <material:arrow_drop_down>
Number:Temperature SetpointTemp2 "Setpoint Temp [%.1f °C]" <iconify:wi:day-sunny-overcast> [ "Setpoint", "Temperature" ]
Number:Temperature SetpointTemp3 "Setpoint Temp [%.1f °C]" <if:wi:day-thunderstorm> [ "Setpoint", "Temperature" ]
String TestString2 "Test string [%s]" <material:favorite>

and this sitemap

sitemap test5 label="Tests"
{
        Frame label="Icon ref in items" {
                Default item=CurrentTemp2
                Default item=CurrentHumidity2
                Default item=CurrentPressure2
                Default item=CurrentPressureTrend2
                Default item=SetpointTemp2 iconcolor=["orange"]
                Default item=SetpointTemp3
                Default item=TestString2 iconcolor=["red"]
        }
}

here is the result in an updated version of Basic UI:
image

lolodomo added a commit to lolodomo/openhab-distro that referenced this pull request Apr 12, 2023
@lolodomo
Copy link
Contributor Author

Note that it is a breaking change as quotes are no more accepted inside the <>. I created an update warning for that.

lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 12, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 12, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 12, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Apr 12, 2023
@J-N-K J-N-K added this to the 4.0 milestone Apr 12, 2023
@J-N-K J-N-K merged commit 953c08c into openhab:main Apr 12, 2023
3 checks passed
J-N-K pushed a commit to openhab/openhab-distro that referenced this pull request Apr 12, 2023
@lolodomo lolodomo deleted the item_model_category branch April 12, 2023 15:46
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-docs that referenced this pull request Apr 13, 2023
Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@mherwege
Copy link
Contributor

mherwege commented Apr 14, 2023

@lolodomo I assume this will not impact the definition of icons in a sitemap file using the icon="iconname" syntax? Are segmented icon definitions in sitemaps supported as well?

@lolodomo
Copy link
Contributor Author

@lolodomo I assume this will not impact the definition of icons in a sitemap file using the icon="iconname" syntax? Are segmented icon definitions in sitemaps supported as well?

Yes, it was changed in #3378.

@mherwege
Copy link
Contributor

@lolodomo @J-N-K I created openhab/openhab-webui#1843 that includes fixes for this, tested with the examples provided.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/openhab4-m1-earlybird/145193/25

stefan-hoehn pushed a commit to openhab/openhab-docs that referenced this pull request May 4, 2023
* New icon sources for an item

Related to openhab/openhab-core#3052

Depends on the merge of PR openhab/openhab-core#3539

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* First set of review comments considered

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* Remove the constraint regarding hyphen in icon name

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* Consider one remaining opened comment

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* Hide &lt; and &gt;

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* Include HTTP link to icon sources directly in the table

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

---------

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
florian-h05 pushed a commit to openhab/openhab-webui that referenced this pull request May 5, 2023
- Adapt sitemap and item lexers to changes in icon name syntax
- Restrict the elements that can be added to a sitemap
- Added extra sitemap validations (in line with xtext validation in
core)
- Added test for sitemap parser and validation

This solves the issue in main UI created by openhab/openhab-core#3539 and openhab/openhab-core#3378.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
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.

None yet

4 participants