Thing Status

Has anyone written a rule that monitors that status of all Things, and keeps a list of Things that are not online? I am thinking of a generic rule that any OH user could use, not monitoring specific things. I would use this list for the Main UI.

Check out Rich’s rule template. That sounds like what you’re after.


configuration: {}
triggers:
  - id: "1"
    label: When ThingStatusInfoChangedEvent is raised
    configuration:
      topic: openhab/things/**
      types: ThingStatusInfoChangedEvent
      source: ""
      payload: ""
    type: core.GenericEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    label: execute a given script
    configuration:
      type: application/javascript
      script: >
        console.log("Rule: ThingStatusOfflineEvent.
        Item:",event.thingUID.toString(),".
        Value:",event.statusInfo.toString());

        var offlineItem = event.thingUID.toString().replaceAll(":","_").replaceAll("-", "_") + "_offline";
        if (event.statusInfo.toString() == 'ONLINE') {
          items.getItem(offlineItem).sendCommand('OFF');
        } else {
          items.getItem(offlineItem).sendCommand('ON');
        }
    type: script.ScriptAction

It requires an item for each thing wih the following syntax:

ThingUID_offline

where the ThingUIDs’ colons „:“ need to be replace by underscore „_“

This requires OH4. If you are on v3, very few changes need to be done

1 Like

An of course the corresponding HABApp Rule

1 Like

System which has offline things reaches start level of 70. Once all things are online it will reach 100 (speaking here about default configuration).

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.