Description
Since OH 3.1
(#2123), it is possible to specify a system-wide sort order for items in groups (so that, for example, Basic UI always displays them in the exact same way).
Currently supported options (#2417) include:
- no sorting (
NONE
) - by label, lexicographically ascending (
LABEL
) - by item name, lexicographically ascending (
NAME
)
This is great 🏅 for deterministic display of the UI, but often times it is the most useful to have items sorted by value
(ASC or DESC).
For example, it makes sense to display device battery levels 🔋 as lowest first 📈 or energy consumption 🔌 from highest to lowest 📉 . Accomplishing it today (via rules) is cumbersome and may be brittle - ex. see this community thread.
Enhancement proposed
- Extend
Group:Number
definition to allow for specifying per-Group sort order.
ItemUIRegistry::getChildren()
would keep providing sorted outputs for groups, but:- If there's a per-group sort order defined (also including by-value sort) - use that as primary sorting criterion,
- system-wide setting (as-today) becomes a 2ndary sort criterion (ex. first by-value,descending, then by-name).
- Enhance Group definition to allow expressing the sort order. For example:
-
[option 1⃣ ] - as
metadata
- Example group definition syntax:
Group:Number:MIN GBatteryLevel "Battery levels [%.0f %unit%]" <battery> (gApartment) ["Battery"] { unit = "%", item_sort_order = "BY_VALUE_ASC" //<-- new }
- The sort order direction could be an UI-only parameter (no impact on
core
). Not sure about it though, given the default sort has been implemented by core already and this could lead to split responsibilities.
- The sort order direction could be an UI-only parameter (no impact on
- Example group definition syntax:
-
[option 2⃣] Extend definition syntax itself for the grouping functions, ex.
Group:Number:Energy:MAX(SORT_DESC)
orGroup:Number:Energy:MAX:SORT_DESC
.
Notice also that functions such asMAX
orMIN
may imply the sort order on their own, so perhaps this could be exploited...
-
- Add
BY_VALUE_ASC
andBY_VALUE_DESC
item sort criteria.- [non-option ⛔] Note that simply adding a system-wide value-based sort settings somewhere here:
would be the most straightforward... but unlikely to be useful at this high level (also, the compare would have to be bystring
repr.) 🙅.
- [non-option ⛔] Note that simply adding a system-wide value-based sort settings somewhere here: