OH2 - OH3 Sitemap to Main UI migration. Can't find the appropriate widgets

I like the Main UI as it has a way fresher look as the sitemap in OH2.
However, I am struggling to achieve this using Main UI:
Screenshot from 2021-07-13 07-50-15

So in the OH Sitemap definition I get a quick overview how many windows are opened and when I click on it i get the detailed list.

In OH3 I’d go for a label cell:
- component: oh-label-cell
item: gKontakte
title: Fenster

Then I think defining a pop up action where the status of all windows in gKontakte is shown would be the way.
However, I don’t know how to achieve that.


Create a widget to run through the groups.
Here is an example:

uid: Status-list
tags: []
    - context: item
      description: Group item to list
      label: Item
      name: item
      required: true
      type: TEXT
  parameterGroups: []
timestamp: Mar 19, 2021, 3:16:43 PM
component: oh-list
    min-width: 250px
    --f7-list-item-after-font-size: 12px
    --f7-list-item-after-font-weight: bold
    --f7-list-item-after-text-color: var(--f7-text-color)
    - component: oh-repeater
        sourceType: itemsInGroup
        groupItem: =props.item
        for: index
        fragment: true
          - component: oh-list-item
              title: =loop.index.label
              footer: =loop.index.name
              item: =loop.index.name
              after: =loop.index.state
              icon: =(loop.index.state === 'ON')?'f7:lightbulb_fill':'f7:lightbulb'

This is what it looks like:

Obviously modify it for your windows and doors.

Hi Greg,
thank you very much for your quick reply.
The lights is a another issue I have and your widget example helps a lot.
I have created a labeled cell with a popup action defined:

              - component: oh-cell
                  title: Test Lights Popup
                  action: popup
                  actionModal: widget:status-list-lights
                  icon: oh:light
                    item: gLicht

I have currently these issues:

  1. In the group gLicht are more than 20 Items defined and only 6 are shown.
  2. Not realtime, gLicht is changed but the popup is not reflecting the change.
  3. Directly switch on and off lights

Do you know what changes are required in your widget?


Ok you want live switches etc and real time.

For example you could do this:

Then if you go to the properties tb and then lights:

Then when you click on the gallights switch you will see this:

From there you can turn lights on and off individually or flip the big switch and control all of them.

Don’t know if this is what you want. Something to think about.

1 Like

Hi Greg,
this is quite close were I want to go:

However, in the actual cell label I want to have the number of lights which are actually on.

Currently I have:

          - component: oh-label-cell
              action: group
              actionGroupPopupItem: gLicht
              item: gLicht
              title: Lichter
              stateAsHeader: true
              expandable: false
              icon: oh:light

gLicht is defined:
Group:Switch:OR(ON, OFF) gLicht "Lichter an: [(%d)]"

Is there a more elegant way than defining a separate item and process the group gLicht within a rule?
What also would be nice to have a button in the popup “alloff”.
The case were I want to switch all lights on in one go are rare.

Further tests lead to:

              - component: oh-label-cell
                  action: group
                  actionGroupPopupItem: gLicht
                  title: Lichter
                  expandable: false
                  icon: =(items.gLicht.state == 'ON')?'oh:light-on':'oh:light-off'
                  label: =(items.gLicht.state)

label: =(items.gLicht.label)
does not work. I thought this could result in “Lichter an: 5”…

Are you using the UI or editing files?
I think if you use both then things don’t work properly.
I use the UI only. I don’t edit any files.
The widgets don’t show real time (or I can’t work out how to do it) but the properties tab is real time and that was the screen shot I posted.

I want to use text files only but it is hard to achieve (reason: Versioning with git). The MQTT things for example only work (at least I couldn’t achieve it) when using the UI.
I got a bit closer

Instead of the Text “OPEN” I’d like to see the number of the opened windows.

This is the code I have so far:

              - component: oh-label-cell
                  action: group
                  actionGroupPopupItem: gKontakte
                  label: =items.gKontakte.state
                  title: Fenster
                  icon: =(items.gKontakte.state == 'OPEN')?'oh:contact-open':'oh:contact-closed'
                  footer: footer
                  expandable: false

and the items in a text file:

Group:Contact:OR(OPEN, CLOSED) gKontakte “Offene Fenster/Türen [(%d)]”

//Group:Contact:COUNT(“OPEN”) gKontakte “Offene Fenster/Türen [%d]”

/* Fenster */
Contact Fenster_KG_Werkstatt “KG Werkstatt [MAP(de.map):%s]” (gKontakte, KG_Werkstatt) { channel=“knx:device:bridge:kontakte:Fenster_KG_Werkstatt” }
Contact Fenster_KG_Gast “KG Gast [MAP(de.map):%s]” (gKontakte, KG_Gast) { channel=“knx:device:bridge:kontakte:Fenster_KG_Gast” }

You need to introduce 3 new groups, one for open windows, one for closed windows :

Group:SUM gKontakte "Fenster/Türen"
Group:Contact:COUNT("OPEN") gKontakteOffen "Offene Fenster/Türen"
Group:Contact:COUNT("CLOSED") gKontakteGeschlossen "Geschlossene Fenster/Türen"

Having this, You can either show all contacts, or just open or closed contacts and will get the number as a state.

Hello Hans-Jörg,

the state gives always a “OPEN” or “CLOSED” regardless which group state I take as am item.

I have:

Group:Contact:SUM gKontakte "Offene Fenster/Türen"

Group:Contact:COUNT("OPEN") gKontakteOffen "Offene Fenster/Türen"
Contact Fenster_OG_Buero        "OG Büro [MAP(de.map):%s]"        <window> (gKontakte, gKontakteOffen, OG_Buero)     { channel="knx:device:bridge:kontakte:Fenster_OG_Buero" }
Contact Fenster_OG_Bad          "OG Bad [MAP(de.map):%s]"         <window> (gKontakte, gKontakteOffen, OG_Bad)       { channel="knx:device:bridge:kontakte:Fenster_OG_Bad" }

and this in the label field:

label: =items.gKontakteOffen.state

The log sais:

09:04:37.406 [INFO ] [nhab.event.GroupItemStateChangedEvent] - Item ‘gKontakte’ changed from CLOSED to OPEN through Fenster_OG_Buero
09:04:37.408 [INFO ] [nhab.event.GroupItemStateChangedEvent] - Item ‘gKontakteOffen’ changed from CLOSED to OPEN through Fenster_OG_Buero
09:04:40.678 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Fenster_OG_Buero’ changed from OPEN to CLOSED

Sorry, my fault,


This was it, thank you very much.
Now the number of opened windows is correctly displayed

1 Like

In ye olden days of OH2,

Group:Contact::OR(OPEN,CLOSED) someGroup "my label [%d]"

had magical properties. The basic state of the Group would be OPEN or CLOSED, as seen by rules or (usefully) by dynamic icons, but the [%d] state presentation gave a sitemap display of a count of ‘active’ members.

So far as I know this hidden count still exists in OH3, but is not accessible in MainUI. Has anyone fathomed it out?

Unfortunately not, I tried with several fields (.label, .text) but without success.
There is also another difference, dimmer items e.g.:

Dimmer Licht_EG_Essen_Tisch        "EG Esszimmertisch [%d %%]"   <light> (gLicht, gLichterAn)              { channel="knx:device:bridge:lichter:Licht_EG_Essen_Tisch" }

Don’t count when using this approach for lights. With the OH2 mechanism this was possible, just all light and dimmer items were through into the same group and also an active dimmer item was counted.

With the COUNT “ON” approach:

Group:Number:COUNT(“ON”) gLichterAn

Only switches are counted,

It still exists for BasicUI AFAIK, but not for MainUI. Had a chat about it with Yannick some time ago. It is not on the roadmap atm.

Well yes, these have state 0-100 so SUM obviously will give results like 456 while COUNT( >0) just doesn’t work.

You can put Dimmers into Switch flavoured Group, and the OR function will recognise >0 as ON, but that doesn’t help because of the regression losing %d functionality.

COUNT is documented as working with ‘regular expression’. I wonder if is possible to work out what not-“0” would look like. That would mess up with 0.0, but that’s not usually seen in Dimmers.
Not-0 isn’t quite the same as ON, remembering NULL etc. but it’s close.

So the only solution is to calculate the number of active dimmers in a rule?
the procedure would than be:

  1. Item for the active dimmer count
  2. group for all dimmers
  3. loop in a rule through all members of the dimmer group and count those having a state greater 0
  4. update the active dimmer count item
  5. use the active dimmer item in the Main UI

I had a look around for COUNT expression uses, found this

I could not get Group:Number:COUNT("^[1-9]*$") to work as used there.

I stole a “test for non-zero” expression from somewhere else, tried
and that seems to work pretty well. Non-zero dimmers are counted, decimal or integer.
0 NULL or UNDEF are not counted.
Quirk - decimals less than 1 e.g. 0.9 not counted, treated as OFF - do you care? Decimals are rare but allowed in Dimmers.

Don’t ask me how it works or how it could be improved to handle Switch members in the same group, that would be useful.

The question is: will it work in the next release? I am intending to replace proprietary KNX visualizations with OpenHAB.

Will what work? Why would you expect it to go away?