openhab/openhab-core

Maintain curated list of units for a given dimension

Closed this issue · 4 comments

That is why I was thinking of a drop down plus 'custom' input. Both one and % could be in the standard dropdown (with unit-hint preselected or % if unit-hint == null). The other standard options would be ppM, ppB, and dB. Any other unit, including those with milli, kilo, prefixes etc. could still be entered via the 'custom' input..

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)

This is not possible. How do you select which combinations are shown? Take for instance velocity:

  • length can be expressed as mm, cm, dm, m, km, in, ft, mi (which are common, every metric prefix like M, G, T is also valid for m)
  • time can be expressed as ms, s, min, h, d, m, y (which are common, every metric prefix is also valid for s)

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 in/y or km/ms don't make much sense).

If at all a curated list of units should be available in Main UI, but core should not present a subset of available units.

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?

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..

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.