One rule for many items

Hi all,

I have a number of items related to some digital signage I’ve developed.

I’d like to have a rule run when any one of them is changed, that takes into consideration the values of each of the items.

I thought I would create a group and detect the change to the group, but that seems somewhat difficult.

Can I create a wildcard rule that runs on something like item = SIGNAGE_*?

If anyone has a good example on how to achieve this, I would appreciate a link. Current skill level is newbie to beginner…

No, there is no wildcard for rule trigger, try out the group approach. You have to use Item MyGroup received update as trigger if the items are diverging, the downside is, the rule will be triggered two times for one update, maybe you have to care about this - depends on what the rule should do.

Thanks Udo - is there a way to have the rule trigger for all items, but then inspect the name conditionally? That might be a lot of processing overhead, however. I’m still sorting out the rule language options…

There is a hack you can use if you have persistence set up.

  • put all your sign items into a group
  • make sure all the items in the group are persisted at least every change, probably want every update
  • trigger your rule on the group as @Udo_Hartmann recommends (be aware the rule will trigger more than once per item event)
rule "Signage rule"
when
    Item gSignage received update
then
    Thread::sleep(100) // give persistence time to catch up
    val triggeringItem = gSignage.members.sortBy[lastUpdate].last

    ...
end
1 Like