[OH3] User Interface equivalent of Group:Number:Count("String")

I am gradually transitioning from text based to UI in OpenHAB3 but I do not find a way to create from the UI the following group (which works in textual definitions)

Group:Number:COUNT("ControlledOff") gENEL_shred  "number of Shred equipments" 

The members of the group are string items. When I try to import from text definition it gives an error

Error: Syntax error at line 1 col 20:

  Group:Number:COUNT("ControlledOff"
                     ^
Unexpected string token: "ControlledOff". Instead, I was expecting to see one of the following:

A identifier token based on:
    AggArgs → "(" ● %identifier _ "," _ %identifier ")"
    Type → "Group" %membertype ":" %aggfunc ● AggArgs
    Item →  ● Type _ Name Label Icon Groups Tags Metadata
    Items →  ● Item
    Main → _ ● Items _
A identifier token based on:
    AggArgs → "(" ● %identifier ")"
    Type → "Group" %membertype ":" %aggfunc ● AggArgs
    Item →  ● Type _ Name Label Icon Groups Tags Metadata
    Items →  ● Item
    Main → _ ● Items _

If I try to create the group from the UI, I am not able to obtain the COUNT aggregation function.
What am I doing wrong?

Thank you for your attention

I don’t think you are doing anything wrong. This appears to be broken in MainUI.

There may be an issue already open for this so search first. If not please do file an issue. As far as I’m aware using COUNT like this is still allowed.

In the mean time you can insert it through the REST API or keep it in a text file. To insert it in the REST API, create the Item without the ("ControlledOff") part. Then go to the API Explorer and query for the Item using the “Get a single item” end point and copy the JSON that results. It’ll look something like this:

{
  "members": [],
  "groupType": "Number",
  "function": {
    "name": "EQUALITY"
  },
  "link": "http://10.10.1.112:8080/rest/items/TestGroup",
  "state": "NULL",
  "editable": true,
  "type": "Group",
  "name": "TestGroup",
  "label": "Test Group",
  "category": "",
  "tags": [],
  "groupNames": []
}

Go to the next end point down labeled “Adds a new item to the registry or updates an existing item”. Enter the Item name and paste the JSON into the “Request body”. Make the following edits:

  • remove the link field and editable field
  • add a common after “EQUALITY”
  • add the parameter:
    "params": [
      "ControlledOff"
    ]

It’ll look something like this

{
  "members": [],
  "groupType": "Number",
  "function": {
    "name": "EQUALITY",
    "params": [
      "ControlledOff"
    ]  },
  "state": "NULL",
  "type": "Group",
  "name": "TestGroup",
  "label": "Test Group",
  "category": "",
  "tags": [],
  "groupNames": []
}

Note, you can’t modify an Item defined in a text file this way.

Thank you Rich,
I found a recent similar issue in github and I added a comment there. I will try your solution through the rest-API and I will report the result.

Lionello

The use of the REST API works. The only change is to replace EQUALITY with COUNT.

1 Like