[SOLVED] How to order items to be displayed correctly?

  • Platform information:
    • Hardware: QNAP TS453Pro
    • Java Runtime Environment: 1.8.201
    • openHAB version: 2.5
  • Issue of the topic: Order not correct (not like in *.items file)

I’m a newbie and doing my first steps with OH2.
I have all my rooms sorted in my *.items file and they will be displayed correctly as entered (first room from *.items file on first position, second on second…)

I have configured the entries for my TV items to the room where they reside as well in a group named gSamsungTV (to be able to control the TV’s without browsing through florrs and rooms until I reach them), means I added the following at the end of the items lines: (GF_Living, gSamsungTV)

In my items file I have the entries for the TV’s in the SamsungTV area (at the bottom of the file) sorted first by room:

  1. guest room
  2. living room
  3. sleeping room

then by function

  1. Power-on (Switch, wol binding)
  2. Mute (Switch, samsungtv binding)
  3. Volume (Dimmer, samsungtv binding)
  4. Power off (Switch, samsungtv binding)

But in the Basic UI and in my Android app it shows different:

  1. Power off
  2. Mute
  3. Volume
    for every room ,but different room ordering than in the *.items file:
  4. living room
  5. sleeping room
  6. guest room

And at the end, the power-on entries are appended in the correct room order

  1. guest room
  2. living room
  3. sleeping room

The same (wrong) ordering is inside the rooms.

All works fine with the 3 TV’s, but I want a different ordering in the displays. Any hints ?

Thx !
Andi

  • Items configuration related to the issue:

//Samsung TV’s
// Samsung TV guestroom: samsungtv:tv:xxx
Switch PowerOn_TV_GR “TV GR Power-on” (EG_guestroom,gSamsungTV) { wol=“192.xxx.xxx.255#xx:xx:xx:xx:xx:xx” }
Switch Mute_TV_GR “TV GR Mute” (EG_guestroom,gSamsungTV)
Dimmer Volume_TV_GR “TV GR Volume” (EG_guestroom,gSamsungTV)
Switch PowerOff_TV_GR “TV GR Power-off” (EG_guestroom,gSamsungTV)
// Samsung TV livingroom: samsungtv:tv:xxx
Switch PowerOn_TV_LR “TV LR Power-on” (GF_livingroom,gSamsungTV) { wol=“192.xxx.xxx.255#yy:yy:yy:yy:yy:yy” }
Switch Mute_TV_LR “TV LR Mute” (GF_livingroom,gSamsungTV)
Dimmer Volume_TV_LR “TV LR Volume” (GF_livingroom,gSamsungTV)
Switch PowerOff_TV_LR “TV LR Power-off” (GF_livingroom,gSamsungTV)
// Samsung TV sleepingroom: samsungtv:tv:xxx
Switch PowerOn_TV_SR “TV SR Power-on” (GF_sleepingroom,gSamsungTV) { wol=“192.xxx.xxx.255#yy:zz:zz:zz:zz:zz” }
Switch Mute_TV_SR “TV SR Mute” (GF_sleepingroom,gSamsungTV)
Dimmer Volume_TV_SR “TV SR Volume” (GF_sleepingroom,gSamsungTV)
Switch PowerOff_TV_SR “TV SR Power-off” (GF_sleepingroom,gSamsungTV)

Item ID’s, IP addresses and MAC addresses modified :wink:

Hello, Groups are pretty much useless in sitemaps except for quickly trying stuff as there is no way to influence the order of items in a group when displaying them.
To display items on your sitemaps in a specific order you will have to add them manually to your sitemap file line by line and use things like text items and frames in the sitemap for structure.
The order the items have in your item file have no influence on the group order or the sitemap.
best regards Johannes

1 Like

Hi Johannes,
I found a solution thanks to your hint with the sitemap file.
My *.sitemap contains only 4 frames (floors, devices, windows and doors, weather) and in each frame only the group items which should be displayed after clicking.
Example: clicking to “groundfloor” in the “floors” frame shows all rooms in groundfloor as defined in the *.items file with alphabetical order (as in the *.items file). In each room I have further items like light switches and dimmers, window and/or door sensors and all in correct order again. And at the bottom of the sitemp file a group “weather” which contains a link to all weather data and the 3 most used text items from the weather binding (temperature, rain, clouds…) and I know I could have them displayed in the correct order by placing them more up or down.

Now I changed an entry of the sorted weather items by moving it one line up and checked in Paper UI, but nothing changed (as you told it’s useless). So I restarted my OpenHAB2 server and the ordering was like in my items file.
Means: if I change anything in my items file it will be displayed somewhere randomly until I restart OpenHAB server and then the sorting order is correct as in the *.items file.

No, this is just coincidence, of course, if using one single file to define your items, this may be true, but there may be circumstances when this might fail.

If using VSCode with openHAB plugin, you only need three clicks to insert complete groups to your sitemap Item by Item, it’s really simple and much more readable than a group item=something.

Your sitemap will grow, maybe you want some nice display features like different colors for Item values. Maybe you want different order for different sitemaps (the iOS and Android app don’t use 2 columns but only 1, so the appearance differs a lot from the browser on a desktop PC.