How to Update the State of a Group Member

How can I Update the State of a Group Member?
Based on some condition I want to update the member state. I’ve tried the following without success:
My code looks something like this

ggSummary?.members.forEach[ mysummary0|
if (…) {
mysummary0 = MyString
mysummary0.state = MyString
postUpdate.mysummary0(MyString)
postUpdate.mysummary0.state(MyString)
}
]

Your help is much appreciated.

It kind of looks like you are just trying random syntax to see what might works. When ever you have a question like this you should always refer to the docs first. In this case, https://www.openhab.org/docs/configuration/rules-dsl.html#manipulating-item-states.

None of those four lines are valid.

I can’t find anything in the documentation that tells me what does work. This is sort of indirect addressing.

A member of a Group is an Item. The docs say

MyItem.postUpdate(<new_state>) - Change the status of an Item without causing any implicit actions. Can be used to reflect changes that may be caused by other means.

So the code that will work is

mysummary0.postUpdate(MyString)
1 Like

I thought I tried that but i see had syntax issue with the cart before the horse!

Thank you again.