uid: rules_tools:thing_status label: Thing Status Reporter description: Calls a user supplied script when a Thing changes it's status. configDescriptions: - name: script label: Rule to call description: Rule to call when one or more Things match the comparison. type: TEXT context: rule required: true triggers: - id: "3" label: A Thing Changes Status description: Triggers when any Thing changes status configuration: types: ThingStatusInfoChangedEvent payload: "" topic: openhab/things/** source: "" type: core.GenericEventTrigger conditions: [] actions: - inputs: {} id: "2" configuration: type: application/javascript script: | // Version 0.2 var {helpers} = require('openhab_rules_tools'); console.loggerName = 'org.openhab.automation.rules_tools.Thing Status'; // osgi.getService('org.apache.karaf.log.core.LogService').setLevel(console.loggerName, 'DEBUG'); helpers.validateLibraries('4.1.0', '2.0.1'); console.debug('ThingStatusInfoChangedEvent:' + event.toString()); var parsed = JSON.parse(event.payload); var data = {}; data['thingID'] = event.topic.split('/')[2]; data['thing'] = things.getThing(data['thingID']); data['oldStatus'] = parsed[1].status; data['oldDetail'] = parsed[1].statusDetail; data['newStatus'] = parsed[0].status; data['newDetail'] = parsed[0].statusDetail; rules.runRule("{{script}}", data, true); type: script.ScriptAction