Trigger, when any Thing changed it status

Hey, is there a possibility to use a trigger which fires, when any Thing change its status (e.g. from ONLINE to OFFLINE or anything else)

Like the solution for items in groups ( when Member of Groupxy changed then …)

And maybe there is also something like triggeringThing (similary to triggeringItem)

I know that there is a solution for specific / defined Things, but i want to check all Things that are in Openhab.

Hope you got what i mean. Thanks.

The short answer is no, you cannot trigger a rule on any Thing changing status. You have to specify the Things one by one.

I’ve published Thing Status Reporting which gets around this by polling the Thing Registry for Things that match a configured state (e.g. OFFLINE) and then calling a separate rule with the list of this Things that are offline. From there you can process the list, send alerts or what ever you want.

It’s a rule template and can be installed from the Marketplace under Settings → Automation.

See Rules - Basic | openHAB for more on rule templates.

1 Like

There is a event.thing variable available, but not for DSL rules

https://openhab-scripters.github.io/openhab-helper-libraries/Guides/Event%20Object%20Attributes.html

I haven’t tested this but in theory (famous last words), this should work in jruby.

rule 'Execute rule when any thing is changed' do
   changed things
   run { |event| logger.info("Thing #{event.uid} changed to #{event.status}") }
end

I can’t speak to its efficiency (you are create a trigger for this rule for each thing in your system). Also, it wont catch when new things are added as it is just a static capture of the things known to openhab when the rule is parsed, you would have to rerun the rule to capture new things added.