Loop through all members in a group with OH2

Are you using ESHD? What shows up when you hit ctrl-space? There are javadocs over on the ESH project.

All Item types end in Item, all state types end in Type.

GroupItem is a subclass of GenericItem which defines a memberOf method so I can’t say what is going on here.

No, it’s an undocumented subset of Xtend with then some, but not all of the objects from the smarthome framework exposed. Running the v0.8.0 version of Designer is about the best you can get, but even it is far from reliable. The JavaDoc from the EHS project are for Java which is definitely not what the rules interpret.

I ran into the same question and it seems indeed, that memberOf(Group) is not support in Xtend. My log says:
'memberOf' is not a member of 'org.eclipse.smarthome.core.library.items.NumberItem'
:frowning:

However: It would be great to have a way to filter member of e.g. subgroups of a larger group of items.

I think you can do something like

MyItem.groups.contains("Group name")

I am not sure the method is called groups but there is a method on the Item to get a list of the groups the item is a member of.

2 Likes

As I just eagerly put this in practice, I can verify that it needs to read:
MyItem.groupNames.contains("Group name")

As always, thanks Rich

1 Like