OH3: I "discovered" aggregation for groups, but they do (not) persist

  • openHABian 3.4 on rPi4 with 4GB

I never used the aggregation feature of a group, until most recently when I grouped my three inverters and tried the ‘sum’ function.
It showed me the total solar PV production; how good it that!

I thought I could save the effort of creating an item for the total_pv_power, which is updated by a rule, which adds up the power of all three inverters. These items are persisted.

Thinking further, I thought why not persist the group and do away with the total_pv_power item and the related rule. But… I can’t persist a group.

Is it correct to conclude, that
a) I can’t persist a group’s aggregate function result
b) if I want to add up similar things, I need a rule to do that
c) however, if I only want to show the aggregate value (e.g., in a sitemap), and do not need persistence, I can use the group’s state for this

I can’t answer your question about persisting groups, but would guess that they are excluded since groups will immediately update when member items are restored from persistence.

Rather than using a rule to calculate the group, you could use a rule to update an item whenever the group’s state changes, and persist that item.

1 Like

Awesome! I love this forum… :slight_smile: always learning something.

Nice! Will do… (much better)

a) Incorrect. You can save the state of a Group. But you have to explicitly add that Group to the persistence config.

b) No, Group aggregation is an excellent easy to do that.

c) Groups with aggregation functions are great for either.

If you have a managed persistence config, just add a configuration (Settings → Persistence → Database) and choose the Group or Groups under “select items to be persisted”.

If you use. persist files, add a new line in the “Items” section listing your Group(s) by name followered by the strategies.

        MyGroup1, MyGroup2 : strategy = everyChange

Notice that there is no “*” after the Group name. Omitting that causes persistence to treat that as a regular Item with a state instead of persisting all the members of the Group.

2 Likes

Thanks; Yep, this I remembered when I read it. :slight_smile:

I will go back and revisit all rules (grep is your friend); what I usually do under the umbrella of ‘continuous improvement’.