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
Set Defaut State Presentation for items not linked to channel #4071
Comments
The unit should always be guessable. Calling My understanding is that "of type Number, |
I meant for items of type just |
Right, if it's a You can always know the unit or if there is no unit. |
For unmanaged items, I believe we can simply set the default pattern to items at this place, that is when no pattern is defined inside the label: I will prepare a PR and test it. For items managed by Main UI, maybe the solution would be to have a pattern proposed by default in the page used to create a new item ? |
See here: openhab/openhab-webui#2485 |
Do you mean with “managed item” an item, created over the web interface, because the web interface enforces saving state presentation? Or it does not enforce saving state presentation and the rationale is different? |
…ed items Related to openhab#4071 and openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This leads to a very long value, look at my screenshot in the proposed PR. Maybe we should reduce the default to show year, month, day, hour, minute and second ? Precision after the seconds is generally not useful while it takes a lot of place. |
Yes, we call "managed" what is managed by UI, so created/modified/removed from Main UI. |
For items of type number with a dimension, I propose |
Not today but my suggestion would be to add this field in the creation page for String/Number/DateTime items and to set it to the default value we are now defining. This field will remain optional and a user could decide to remove the default pattern or to enter a different pattern if he prefers for any reason. |
Done, it works. |
I see what is |
Regarding NULL/UNDEF, this is a totally separate request for change, "-" is currently displayed if I am not wrong. I believe it was a deliberate choice to not show to user a too much technical value. I do not remember if this is done globally in OH or only at sitemap UI level. I will search. |
I think if |
Writing transforms one has to handle currently three different states: |
What I mean is that a group has generally no state (it is just a container) except if you apply an aggregation function on it. There is a default function, EQUALITY., so that is probably the reason why you mentioned the two cases, with and without a function. https://www.openhab.org/docs/configuration/items.html#derive-group-state-from-member-items |
Closes openhab#4071 Closes openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
My proposal in the PR is now for all items, managed and unmanaged. |
Default pattern for string item: %s Default pattern for datetime item: %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS Default pattern for number item: %.àf Default pattern for number with dimension item: %.àf %unit% Closes openhab#4071 Closes openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Default pattern for string item: %s Default pattern for datetime item: %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS Default pattern for number item: %.0f Default pattern for number with dimension item: %.0f %unit% Closes openhab#4071 Closes openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
A default state pattern was previously provided by ChannelStateDescriptionProvider only for String and Number items linked to a channel. It is now the class DefaultStateDescriptionFragmentProvider which is responsible for providing the default state pattern for items, whether the item is linked to a channel or not. This new class is the lowest ranked StateDescriptionFragmentProvider so that all other providers have priority in setting the state pattern. Default pattern for string item: %s Default pattern for datetime item or group with datetime state: %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS Default pattern for number item or group with number state: %.0f Default pattern for number+dimension item or group with number+dimension state: %.0f %unit% Closes openhab#4071 Closes openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
My PR is now finished and ready for review for the default state pattern. |
Regarding this second request for change, I believe this conversion of NULL and UNDEF states into "-" is done here and also applies to the value passed to the transformation (if one is provided). |
Honestly, I do not remember what I had in mind when I opened the ticket and I have now no OH environment for tests. As EQUITY is explicit, apparently there is no way to create a |
A default state pattern was previously provided by ChannelStateDescriptionProvider only for String and Number items linked to a channel. It is now the class DefaultStateDescriptionFragmentProvider which is responsible for providing the default state pattern for items, whether the item is linked to a channel or not. This new class is the lowest ranked StateDescriptionFragmentProvider so that all other providers have priority in setting the state pattern. Default pattern for string item: %s Default pattern for datetime item or group with datetime state: %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS Default pattern for number item or group with number state: %.0f Default pattern for number+dimension item or group with number+dimension state: %.0f %unit% Closes openhab#4071 Closes openhab#3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Finally, it could make sense to change that, for consistency with what is doing Main UI. |
I am lost in the discussion. Can you please describe what makes sense to change, what is the current state, and the possible final, changed state. |
I was talking about your proposal to not convert NULL/UNDEF into -. |
…4175) * Set a default presentation pattern for String/Number/Datetime items A default state pattern was previously provided by ChannelStateDescriptionProvider only for String and Number items linked to a channel. It is now the class DefaultStateDescriptionFragmentProvider which is responsible for providing the default state pattern for items, whether the item is linked to a channel or not. This new class is the lowest ranked StateDescriptionFragmentProvider so that all other providers have priority in setting the state pattern. Default pattern for string item: %s Default pattern for datetime item or group with datetime state: %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS Default pattern for number item or group with number state: %.0f Default pattern for number+dimension item or group with number+dimension state: %.0f %unit% Closes #4071 Closes #3835 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Will this happen? |
First, I hope you are happy that your main proposal was implemented and accepted ?
Please create another dedicated request for change to discuss of it. You could explain why you think it is better to display a raw value "UNDEF" / "NULL" rather than "-" for UNDEF and NULL states. I will then add pros and cons. I hope we can engage a discussion with others. The change itself is very easy to implement and I could do it. |
Yes, I am happy that this is implemented. About |
This is not exactly the same request. In your other issue, you are requesting a consistent behaviour regarding transformations in Main UI and sitemap UIs. Your other request makes sense, read my analysis in the other issue. |
The current logic for implicit state presentation is explained at openhab/openhab-webui#2251 (comment):
I suggest extending the above logic, for items not linked to channels:
[%s]
, spellingNULL
when the value is NULLNumber:<dimension>
use%.0f the unit
. If unit cannot be guessed, use%.0f
.The latter logic should be applied also to
Group:Number:<dimension>
,Group:Number:<dimension>:<function>
,Group:Number
andGroup:Number:<function>
.So if a user does not want to see the current value, the user can explicitly add
[]
.See also #3835 and openhab/openhab-webui#2251.
The text was updated successfully, but these errors were encountered: