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

For counting switches, contacts and dimmers as part of the same group this should work:

Group:Number:SUM testCountALL
Group:Number:COUNT("^[1-9]|ON|OPEN|0.0*[1-9]") testCountON "Number of active test items [%d]" (testCountALL)
Group:Number:COUNT("^(0(.0+)*)|OFF|CLOSED|NULL|UNDEF") testCountOFF "Number of INactive test items [%d]" (testCountALL)

Contact contact1        "Contact 1 [%s]" <window>  (testCountON, testCountOFF)
Switch switch1          "Switch 1 [%s]"  <light>   (testCountON, testCountOFF)
Dimmer dimmer1          "Dimmer 1 [%s]"  <heating> (testCountON, testCountOFF)

I tested with all three kinds of items and got correct results for dimmers with both integer and decimal values (0, 0.0, 1, 1.0, …) as well as “UNDEF” and “NULL” values.

“correct” means I consider “CLOSED” contacts and UNDEF or NULL items to be part of the OFF/inactive group.

2 Likes

That’s brilliant :smiley:
Should work as-is with Rollershutter (same state type as Dimmer)

Can you add Color types - state format a,b,c and find non-zero c - without messing up dimmer? Regex is beyond me.

Can you add Color types

Oh, here’s a challenge … :smile:
I’ll give it a shot, might take some days, though

Okay, here you go: This should work for switches, contacts, dimmers and color items:

Group:Number:SUM testCountALL
Group:Number:COUNT("^(([1-9][0-9.-]*$)|ON|OPEN|0[.]0*[1-9]|([0-9. ]+,[0-9. ]+,[0. ]*[1-9][0-9.]*))") testCountON "Number of active test items [%d]" (testCountALL)
Group:Number:COUNT("^((0$)|(0.0+$)|OFF|CLOSED|NULL|UNDEF|([0-9. ]+,[0-9. ]+, *0+(.0+)?$))") testCountOFF "Number of INactive test items [%d]" (testCountALL)

Compared to the first attempt (without color) it became slighty more complicated, but should also fix some issues with the first attempt :slight_smile:

I tested the expressions against these test cases:

ON-Values:
1
ON
OPEN
0.1
1.0
2
30
123
229,100,99
255,32,33
0,0, 0.00001
0,0,99
OFF-Values:
0
OFF
CLOSED
0.0
UNDEF
NULL
229, 100, 0.00000
229,100,0

Note, however, that I have some light things which have separate On/Off switches, where the third color value is >0 even though the switch and the light are OFF.

Unfortunately, RegExes are always Write-Only (i.e. one should never try to read and understand them…), so I hope these will never need to be changed :slight_smile:

Hope this works for you!

3 Likes

Hi Jens,
now the dimmers count as well with one line instead of having a separate rule.
You are the master :wink:
Thanks yo
Marco