-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Provide meaningful list of units in item form #2312
Conversation
Job #1750: Bundle Size — 11.13MiB (+0.11%).Warning Bundle contains 19 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
View job #1750 report View mherwege:unit-hint branch activity View project dashboard |
@mherwege I can’t really comment on the code; but I will make a build and test how it looks on screen. |
Ok. I did a full build and found three problems..
|
^
|
@andrewfg Thanks for testing. Issues are noted and I will look into them. I am currently working on integrating a currated list of units in this PR as well. Let's come back on this and test again when I have done that. |
@andrewfg If you want to have another go at testing this, that would be very much appreciated. |
@florian-h05 While this PR now will benefit of openhab/openhab-core#4079 and provide extra functionality, it is not strictly required for this PR and will work without. |
For Temperature, can someone in SI still pick |
I don't know if |
It won't be in the suggestion list, but it is always possible to put it in manually. |
Possible, but from a perspective of a European, I don't want to see the Imperial units. I don't deal with them at all. That perspective could be different for users in the US though. |
I agree with this.
They might need to use metric sometimes, and at that time, having the hints would probably be quite helpful. I'm happy either way. From usability perspective, when it's not there, some people might think it's not possible. |
Agree, but I don't see a good way to overcome it. The issue is there are too many combinations possible for units and their multipliers. Showing them all does not make sense. And if you don't show all possible combinations, the proposed list should be relevant with the possiblity to put something else if needed. That's what I try to achieve. @rkoshak Your opinion on this would be valued as well. |
Ok. I just started building it now.. |
Please just remember the poor old UK .. .. unlike the US which uses 'Imperial' (I always find it odd that the US refers to its units by reference its one-time imperial over-lords) .. the UK has mostly adopted SI and dropped 'Imperial' (Brexit notwithstanding) .. EXCEPT in a couple of peculiar special cases -- namely as follows..
=> Ergo for UK users, presenting both units, would probably make sense.. |
Does that mean standard conversion to a metric unit does not work, as different for US and UK? |
So, what does a UK user set as measurement system, metric or imperial? |
Metric .. except when in a car or a pub. ;) |
OK, so it sounds like it may make sense to show both, but sequence switched depending on measurement system. |
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
I merged your PR in my branch on github, but couldn't get it to my local anymore afterwards. So I reapplied your changes and force pushed. All should be in there. I went through your other comments, and I believe I have tackled all of them. |
I have checked the commits, looks good 👍
I am currently re-reviewing, I already found a few minor issue, I think I will fix them myself (just push a new commit to your branch). |
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!!
I have applied a few fixes and JSDoc improvements, you can have a look at my recent commits (they are all divided into separate commits).
As this PR is a major improvement to the configuration of UoM Items even without the unit hint being not yet available , I will merge this PR.
Regarding the units.js asset, I am fine with having this file in the UI. In the past, we also had the semantic tags hard-coded and translated inside the UI, which are now loaded from REST.
And with regards to the error message of the unit autocompletion: As the autocompletion works anyway, I would propose to merge this PR and then try to fix that error message later. No need to make this PR even bigger ;-) |
Thank you for the review and merge. |
Regression from openhab#2312. Fixes openhab#2669. Signed-off-by: Florian Hotze <[email protected]>
Regression from #2312. Fixes #2669. Signed-off-by: Florian Hotze <[email protected]>
Regression from #2312. Fixes #2669. Signed-off-by: Florian Hotze <[email protected]> (cherry picked from commit fa85c07)
Closes openhab/openhab-core#4082
This PR adds:
By default, the system default unit (for the configured measurement system) will be shown when editing or creating an item.
units.js
contains a number of frequently used units by dimension and measurement system. These will be available in a autosuggest dropdown list. It is still possible to not select from the list and use any other string as a unit.units.js
now only contains a relatively small list, but can easily be extended with other frequently used units.All units for the dimension in
units.js
will be in the dropdown list, but they will be sorted by measurement system. If the measurement system is set to US, imperial units will appear higher in the list. Units that have not explicitely been listed as SI or US will always appear higher.When typing a unit that is not in the curated list, a longer list will be used for autocompletion that considers allowed prefixes to base units and constructs all combinations.
units.js
also contains a field to set a different default unit on item creation than the system default unit.With openhab/openhab-core#4079, the REST API of channel types would provide a unit hint if defined in the binding channel types.
If such information is available, this PR adds support for this in the UI. When creating an item from a thing channel, it will suggest to use the unit from the unit hint if available. If not available, it will suggest the webui defined default from
units.js
, if not available, the system default unit for the dimension.For dimensions with different units in SI or US measurement systems, it is possible to provide 2 units separated by comma in binding channel types. The first one will be SI, the second US. The suggested one will depend on the measurement system setting.
See also: