is it possible to write a rule that says something like:
rule "Update"
when
Member of Member of MyGroup changed
then
...
end
So I need a rule, that looks at the Items of Sub-Groups from a big Group. Is this possible, without listing all Subgroups in such a way:
rule "Update"
when
Member of MySubGroup1 changed OR
Member of MySubGroup2 changed OR
...
then
...
end
And another Question:
I’m looking for a rule, that triggers when I change the Groups of an item in my .items file. Is it possible to write such a rule?
Because I need to recognize, wether the groups of an Item changed by adding or removing an Group to the Item to update this Item in my selfmade-program.
Okay in the case i want to check wether an item belongs to a group or not, where do I get the information from, to decide which item left the group or was a member in this group?
In my programm i want to filter my items by groups. But while runtime it could be possible, that some groups could be added to or removed at specific items. And in this case i want to update this specific items in my programm by sending update messages from OH.
So you plan to create groups dynamically in code and attaching items for those groups
If you can code this then you can code the testing of items in groups or not before and after.
I am sorry, I don’t mean to sound difficult, but I tried this approach and it was very cumbersome and difficult to implement in code. I went back to the drawing board and defined my groups and items for all the functionality I required.
There are no limits on the numbers of groups you can create
There are no limits on the numbers of groups an item can belong to
There are no limits on the nesting of groups
With proper planning and naming convention I have all the functionality I require.
I followed my own coding and the following design patterns:
If I understood it right I’m working on the same approach. I use group membership and group trigger to do some actions. If I do not need a special item in the group I just remove it from the group. And I have proxy items which controll group membership. If needed I can provide my solution.
Example:
I have a group for door/window contact. This group is checked for changes. If I do not want to monitor one item I just remove it from the group and thats all. Some work must be done to ensure that the group internal handling works well.
Please provide your solution.
I’ve tried to work with group-change trigger like:
when
Member of MyGroup changed
then
// give me the triggeringItem.name
The Member is also a Group. I’ve tried also to change the ‘changed’ to ‘received update’ but without success. The rule triggers not, if I remove a Subgroup (Member) of MyGroup from an item.
Could the fact, that I remove the groups via the .items file, is the reason that the rule is not triggering? Or how can i solve it, that the rule is triggering when the Subgroups are added or removed from the items?
I’ve read something about that Groups need an Item Type in order to get triggered. But how can I trigger a Group that contains Items with different Types like Dimmer, Switch and String?