My example rule below:
var telegramAction = actions.get("telegram","telegram:telegramBot:telegram");
var Things = Java.type("org.openhab.core.model.script.actions.Things");
var status = Things.getThingStatusInfo("networkupstools:ups:ups");
//Actions
if (status == "ONLINE") {
telegramAction.sendTelegram("NUT " + status)
events.postUpdate("watchdog_binding_nut", "ONLINE")
}
if (status != "ONLINE") {
telegramAction.sendTelegram("NUT " + status)
events.postUpdate("watchdog_binding_nut", "OFFLINE")
}
This checks if the binding/thing is online/offline with the when trigger being networkupstools:ups:ups changed and/or the system reached start level 100.