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

Item state representation are not overriden when sitemap labels leave them out. #5867

Closed
Josar opened this Issue Jul 6, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@Josar
Copy link
Contributor

commented Jul 6, 2018

The documentation states that sitemap labels override the item definitions but this is not working as expexted.

see

https://community.openhab.org/t/basic-ui-sitemap-printing-command-besided-buttos/47378/7?u=josar

String TV_QUARTO
Frame label="TV" {
    Switch item=TV_QUARTO  label="TV Volume [%s]" mappings=[TV_SAMSUNG_VOL_UP="+", TV_SAMSUNG_VOL_DOWN="-"]
    Switch item=TV_QUARTO label="TV Volume" mappings=[TV_SAMSUNG_VOL_UP="+", TV_SAMSUNG_VOL_DOWN="-"]
}

Works as promised.

But if you keep the label definition at the item it wont, this is diffferent then stated in the docs.
Now both labels show the state and the sitemap definition does not override the label definition from the item.

String TV_QUARTO "TV Volume [%s]"

https://docs.openhab.org/configuration/sitemaps.html#element-types

@htreu

This comment has been minimized.

Copy link
Contributor

commented Jul 6, 2018

This is due to the fact that the [%s] part of the label is in fact the state description which is parsed and separated from the label. So when defined at item level the state description is already set to be %s and it will be rendered regardless of the label/state description defined in the sitemap.

@htreu htreu added the wontfix label Jul 6, 2018

@htreu htreu closed this Jul 6, 2018

@Josar

This comment has been minimized.

Copy link
Contributor Author

commented Jul 6, 2018

This seems to be right in a technical point of view but is highly counterintuitive.
As the optional state presentation field in square brackets is allways set with the label.

Setting the state representation to be empty in the sitemap will overwrite the item definition. But this should be the same as not setting it.

label="TV Volume []"

As the state representation is always set with the label, overwritting the label in a sitemap should also consider to take care of a changed state representation, imho.

PS: it would be nice to get some time to react to statements before the case is closed and marked as wontfix. This would at least give me the feeling that reporting is apriciated and there is at least some room for discussion.

@Josar Josar changed the title Item labels are prefered to sitemap labels. Item state representation are not overiden when sitemap labels leave them out. Jul 6, 2018

@htreu

This comment has been minimized.

Copy link
Contributor

commented Jul 6, 2018

This was not meant to be rude, feel free to add comments (as you did) or even re-open the issue.

As for

Setting the state representation to be empty in the sitemap will overwrite the item definition. But this should be the same as not setting it.

there does not seem to be a right/wrong way of doing it. I assume the current behaviour not got broken and also offers a high level of flexibility.
I agree the openHAB documentation is not precise in this regard. My suggestion is to add a sentence which also describes the behaviour for the state description.

@Josar Josar changed the title Item state representation are not overiden when sitemap labels leave them out. Item state representation are not overriden when sitemap labels leave them out. Jul 6, 2018

@Josar

This comment has been minimized.

Copy link
Contributor Author

commented Jul 6, 2018

I also think that both solutions could be a proper handling of the case.

But the way it is right now is very counterintuitiv.
So when setting no state to the item i won't get a state. But setting no state to the sitemap element i will get a state if the item allready defined it.

As the pair label and state are presented as one entity in "Label [state]", i would expect them to be handelt/treated like one entity. In every case and behave equal every time.

@lolodomo

This comment has been minimized.

Copy link
Contributor

commented Jul 7, 2018

The state pattern is optional at any level.
When defined, the one set on the sitemap has priority over the one set on the item which has priority over the one defined on the channel.
If you set one on the item but none on the sitemap, the one on the item will be considered.
I introduced the [] to give the ability to break this inheritance mechanism at any level.

PS: so for me too, there is no bug in your examples.

@Josar

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2018

Then there is definitly a more sofisticated explanation of this behavior needed in the docs.

I think this solution is one wich offers high flexibility, but is a bit confusing. As the state representation is handled differently then the label. There is no way to NOT override the label and change the state representation.

//  keep state and overwrite label
label="TV Volume "
// set new state, but does not keep label
label="[%s]"

I am not aware where or if thsi is needed at all, is just to show that handling the two things differently adds at least a bit confusion.

@htreu

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2018

@Josar would be nice if you could clarify the current state just as @lolodomo described in the openHAB sitemap docs. wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.