How to persist groups

I am moving some of my devices around the house and my problem is, that i like to dynamically assign these items. SO my idea ist to assign a specific item dynamically to a group and then use the group. We are taling about switches so the use of a group instead of the item directly should be no problem.

My problem is now that the dynamic assignment ist deleted if i restart openhab. So the question is: IS there a was to persist and restore a dynamic group with its members?

Any ideas on that?

Thomas

If you persist all the items with restoreonstartup, shouldn’t that set the group(s) back to the proper state(s) once all items have been restored?

With standard items the state of the item ist persisted and not the item itself or a reference to the item. but what is persisted if i persit the group? In this question the state of an item in a group is not relevant, because i need the information if an item was diynamically added to the group or not

Thomas