Member of XXX_Group received update

Writing rules in Jython …

Is there an obvious reason why this rule continues to trigger every minute or so, even when none of the Members of the group are changing?

@rule("Group Item Testing", description="")
@when("Member of BatteryLow_Group received update")
def rMember_BatteryLow_Group_Group(event):

    log.info("Rule Triggered by: %s" % (event.itemName))

I have been using @when("Member of BatteryLow_Group changed") but wanted to insure the item was updated before executing the rule … but now I see that it is often being triggered ?

This occurs most frequently with the “Low Battery” Channel of my zigbee devices, but it is also happening on other channels.

Any ideas?

The members are updating to the same value perhaps? If you only care about the changes, change the trigger to changed

The event for update and changed does not occur until after the Item processes the state update and change. It’s only received command where you can’t count on the Item reaching the end state. Though even with changed and update, you can’t guarantee that the Item hasn’t changed state in the time between the event being issued and the rule being triggered. So be sure to rely on event.itemState instead of pulling the state from the Item itself.

1 Like

Yes, I assume that is what is happening … not sure why that is desired. Anyway, yes good point about relying on event.itemState that will solve the original issue I was seeing.

Let’s say I have a sensor reporting Watts every second and I want to collect those readings and calculate Wh. I need to know the Watts every second, even if it hasn’t changed.

Maybe I have a motion sensor that only reports ON when movement is detected. It never changes to OFF.

There are many more use cases. That’s why OH has three Item events:

  1. command: indicating a desire for something to happen, there is no guarantee that the Item will ever change state in response; some commands do not become states (e.g. INCREASE sent to a Dimmer Item)

  2. update: the state of the Item was touched; something said “set the state of the Item to X”; could be in response to a command, autoupdate, or a new value reported by the end device; an update does not necessarily mean a change

  3. changed: only for those cases where an Item was updated and the new state is different from the old state.

1 Like

Thanks Rich, good explanation … I’ve seen that before, hopefully it will stick this time :slight_smile: