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
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
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?
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.
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.
No.
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 Group:Number:COUNT("^[1-9]\\d*(?:\\.\\d+)?$")
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.
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.
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
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