Counting Group items ( Group:Number:COUNT(ON) ) does not work for dimmer ? (KNX)

  • Platform information:

    • Hardware: Virtual Image on Qnap wiht 4GB RAM_
    • OS: Ubuntu
    • Java Runtime Environment: Zulu as per installation recommendation
    • openHAB version: 3.4
  • Issue of the topic:
    I do have some problems with counting in groups and textual configuration. Basically I want to count all lights switched “on” in my house and indicate this in the UI card with a “Number” that tells me how many lights are switched on. As binding I do use KNX.

This works fine already fine for all lights that are setup as “Switches” . But I do also have some dimmer lights which are not counted… :frowning:

The KNX GA 0/4/17 is the ON/OFF return address of the dimmer. Actually if I do run the ETS monitor and read this 0/4/17 address it shows correctly on/off depending on if turned on, but it looks like this one is perhaps not passed on to the group counting as it is a “dimmer item” ?

Here my config

The things file config of the dimmer:

        Type dimmer        : EG_Esszimmer_Tisch_Dimmer          [ switch="0/1/17+<0/4/17", position="0/3/17+<0/5/17", increaseDecrease="0/2/17+<0/5/17" ]

Items File (containing my sematic Model)

Group:Number:COUNT(ON)   ZZ_Lichter "ZZ Lichter [An: (%.0f)]"       <light>         (ZZ)                        ["Location"]

Items File Dimmer

Dimmer  EG_Esszimmer_Tisch_Dimmer        	"Eszimmer Tischdimmer [%d %%]" <slider>     (EG_Esszimmer, ZZ_Lichter)          ["Lightbulb"]   {channel="knx:device:bridge:1_1_7_Dimmaktor:EG_Esszimmer_Tisch_Dimmer"}

I was thinking of creating a dummy switch item just with the on/off status that is not member of the corresponding room so that it does not show up but I would rather prefer to have this working as designed.

Appreciate if someone has got any ideas.
bkumio

That‘s correct.
You need to add a seperate switch item to your group

To be more precise: a dimmer item will never have the status ON (at least not in this context). Instead it will have the status 0 to 100 :slight_smile:

There are some options. As the counted value is a regular expression, you can try to use this:

Group:Number:COUNT(ON|[1-9][0-9]*) ZZ_Lichter "ZZ Lichter [An: (%.0f)]" <light> (ZZ) ["Location"]

So either the string ON or a string which is built with numbers and the first digit is not 0.

I haven’t tried myself.

Another option is to count in a rule (not as smart as the COUNT function :slight_smile: )

val myCount = ZZ_Lichter.members.filter[i|i.getStateAs(OnOffType) == ON].size

As you can see, there is an option to force the OnOffType.

1 Like

Hello,
I used a longer time to implement my dimmer.
You have to use three GA for one dimmer.
The channel for example looks like this:

    configuration:
      increaseDecrease: 3.007:1/1/9
      ga: 1/1/9
      position: 5.001:1/1/41+<1/1/45
      switch: 1.001:1/1/10

Than I built my own widget with a slider and a switch, because I want to dimm and switch the light.

But I also want to see the changes back in openHAB if I dimm or switch the light with the KNX-hardware knobs. Therefor is the “position” GA.

And you have to configure the dimming actuator accordingly

Neither increaseDecrease nor ga is needed (there is no parameter named ga for a dimmer channel anyway).
openHAB will always control the dimmer through absolut positioning (1/1/41 in your case) and will set the status to the absolute position (received at 1/1/45)

I quite like your elegant solution to use a regular expression :slight_smile: . Also I assume the “ON” and the [1-9] are then managed both as strings, so of same type.

But I am not a regex specialist. Have checked your suggestion on regex101. The suggested:(ON|[1-9][0-9]*) passed the test but Visual Studio Code is not happy and giving me some errors… :frowning:

OpenHab.log also confirms the missing 3rd EOF error but I guess this is just a follow-up error not able to manage the initial error with the “|” pipe/or char…?

Any idea how to cast this in a different way so that all “ON” and everthing between 01-100 is “counted” ?

[{
“resource”: “/V:/items/casakunzSemanticModel.items”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “org.eclipse.xtext.diagnostics.Diagnostic.Syntax”,
“severity”: 8,
“message”: “mismatched input ‘|’ expecting ‘)’”,
“startLineNumber”: 42,
“startColumn”: 22,
“endLineNumber”: 42,
“endColumn”: 23
},{
“resource”: “/V:/items/casakunzSemanticModel.items”,
“owner”: “generated_diagnostic_collection_name#0”,
“severity”: 8,
“message”: “Item name must not contain dashes.”,
“startLineNumber”: 42,
“startColumn”: 24,
“endLineNumber”: 42,
“endColumn”: 27
},{
“resource”: “/V:/items/casakunzSemanticModel.items”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “org.eclipse.xtext.diagnostics.Diagnostic.Syntax”,
“severity”: 8,
“message”: “missing EOF at ‘]’”,
“startLineNumber”: 42,
“startColumn”: 27,
“endLineNumber”: 42,
“endColumn”: 28

I need to do some further testing but I think this one works.

The trick was the quoation marks " " . Where I am still unsure is if I do need the zero 0 …

Group:Number:COUNT("ON|0[1-9]|[1-9].*")    ZZ_Lichter "ZZ Lichter [An: (%.0f)]"   <light>  (ZZ)   ["Location"]

The dimmer state (as string) should be “0” to “100”, no leading 0.