Fire rule on ANY thing state change

Right now I have a rule that monitors my things for their ONLINE/OFFLINE state. The entire body of my rule works via groups thanks to several posts on here. The only thing that does not work on a group is the syntax under “when”. I still have to list every thing as Thing “a:b:c:d” changed. Is there a way to just say “Thing * changed” or something along those lines so that it fires when any thing registered with the system changes state?

I think if you use Member Of triggers, then you should be able to use the TriggeringItem implicit variable in your rules.

OpenHAB does not manage Things.

OpenHAB manages Items which, many times, are linked to a Thing Channel.

Please learn about openHAB concepts and try to ask your question again.


@Bruce_Osborne not sure on your reply. I fully understand how OH is managing things versus items. I’m looking on a way to optimize my rules. For example, my rule right now looks like:

rule "Thing State"
when
        Time cron "5 * * * * ?" or
        Thing "globalcache:itachIR:REDACTED1" changed or
        Thing "globalcache:itachIR:REDACTED2" changed or
        Thing "globalcache:itachIR:REDACTED3" changed or
        Thing "globalcache:itachIR:REDACTED4" changed or
	    ...
	    Thing "globalcache:itachIR:REDACTED420" changed
then
	do stuff
end

This is cumbersome and requires direct maintenance as I add new things to the system. The body of my rules use for loops with groups and tags to do their work based on a carefully crafted items file. My goal is to just be able to adjust the items file as I add new things but not touch the rules. What I’m looking for is to make it more like

rule "Thing State"
when
        Time cron "5 * * * * ?" or
	    Thing * changed
then
	do stuff
end

So that the rule will fire if any thing changes state. What I can’t figure out is the “Thing * changed” wildcard part.

Using scripted automation, you can generate triggers to include all Things. Let me know if this is of interest and if you need an example. You could also have a rule watching for added/removed Things and reloading the first rule when there is a change.

I do something like that now with a simple bash script that goes through all the .things file to generate the list. It still feels clunky. Is there really no way to do a wildcard in the when section of a rule to do this cleanly?

Yes, see Scott’s post about alternate rule system, but not in DSL Rules, no.