ECMA 2021+ version of @Larsen blocky script.
configuration: {}
triggers: []
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript;version=ECMAScript-2021
script: >-
var ignore, things, messageText, ignoreList, curThing, thingId,
thingLabel, thingStatus;
var logger = log('Thing Status Processor');
ignore = 'ThingID1,ThingID2';
messageText = '';
ignoreList = ignore. Split(',');
logger.debug(things);
for (var curThing_index in things) {
curThing = things[curThing_index];
thingLabel = curThing.label;
thingId = curThing.UID.id;
thingStatus = curThing.status;
if (ignoreList.indexOf(thingId) + 1 == 0) {
messageText += String(['\r\n','_'.repeat("${thingLabel.length + thingId.lenght + thingStatus.length}".length),'\r\n',thingLabel,' (',thingId,'): ',thingStatus].join(''));
}
}
if (!!messageText.length) {
actions.NotificationAction.sendNotification('name@domain.com', 'Things not online: ' + String(messageText));
logger.warn('Things not online: ' + String(messageText));
}
type: script.ScriptAction