-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Maintain curated list of units for a given dimension #4082
Comments
This is not possible. How do you select which combinations are shown? Take for instance velocity:
Any combination of these units is a valid velocity unit, at least 48 different units if we only take the most common ones (although probably If at all a curated list of units should be available in Main UI, but core should not present a subset of available units. |
Fair enough. And I was aware of the problem of selecting what to show. The reason to consider putting a curated list in core is that it would allow to maintain everything about units in one place, together with the unit types. I am happy to move this to the ui and maintain it there though. Can this issue be reformulated (not REST API) and moved to the webui repository? |
I changed the title, but I am not authorized to move it.. |
Closes openhab/openhab-core#4082. This PR adds: 1. A curated list of units to show as a drop-down list when creating a Number item with dimension. 2. The possibility to use a different default unit on item creation than the system default unit. 3. The ability to change unit and state description for items. 4. The ability to use the `unitHint` provided by channel types for "Link channel to Item" -> "Create a new Item". 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. 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 will provide a unit hint if defined in the binding channel types. If such information is available, this PR adds support for this to be the the suggested unit. If that information is unavailable, the UI will fall back to behavious described above. --------- Also-by: Florian Hotze <[email protected]> Signed-off-by: Mark Herwege <[email protected]>
Can someone please close this issue? I have merged the UI PR, but since I have no issue managment rights on the core repo, this issue was not closed automatically. |
This makes sense for Dimensionless. But if you check the list of 'standard' units, you will notice it actually only lists exceptions not covered out of the box by the libraries. For instance, it creates mm/h, but km/h comes from the libraries. So the code you link is by no way exhaustive. Also, it would have to be created manually in the UI code.
I think what is need is a way to query a set of units for a given dimension through the REST API from core, and then show that list. That would make sure things are in sync with core and there are no two places to maintain it. Again, I think this goes beyond the scope of this (and the linked UI) PR. It is probably worth creating a specific enhancement request issue for it.
Originally posted by @mherwege in #4079 (comment)
The text was updated successfully, but these errors were encountered: