It was ecma 21 in text based script action.
Today I tried again in blockly and… it worked on the first try . I cannot tell what I did wrong.
Now it works with your template rule.
Here the code (for pasting in code-tab of new rule):
Click to see code
configuration: {}
triggers: []
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
blockSource: "<xml
xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable
id=\"]8Kt_8cXjoij*UWfL]}Z\">ignore</variable><variable
id=\"C,Wl8e|_BY7`@|WNRR)t\">things</variable><variable
id=\"Qzn]o6PxTzj]cn8bnT2k\">messageText</variable><variable
id=\"n0X6;%Q,_c=4$=`tHt^@\">ignoreList</variable><variable
id=\"%x2mOh`(Hd/#(A4O/k(]\">curThing</variable><variable
id=\"E%{F|_6VUVE]s;x=yceK\">thingId</variable><variable
id=\"oJm$Rz.ax{=5CWVHpP6o\">thingLabel</variable><variable
id=\"HrLFiEjH(SOud$zz{9iv\">thingStatus</variable></variables><block
type=\"oh_log\" id=\"{6Nhb|W/OGmd8@)Fp4@b\" disabled=\"true\" x=\"55\"
y=\"-618\"><field name=\"severity\">debug</field><value
name=\"message\"><shadow type=\"text\"
id=\"`*H5u4}v%f/UR]t5^Aqs\"><field name=\"TEXT\">Enter IDs to ignore in
next line (comma seperated)</field></shadow></value><next><block
type=\"variables_set\" id=\"A`J${j$nZ_dOHC]+d`GI\"><field name=\"VAR\"
id=\"]8Kt_8cXjoij*UWfL]}Z\">ignore</field><value name=\"VALUE\"><block
type=\"text\" id=\"i:tQdMWT($M2/|(JSPl9\"><field
name=\"TEXT\">example_ID1,exampleID2</field></block></value><next><block
type=\"variables_set\" id=\"{~WTIN2e_$f6q3SA6-Yv\"><field name=\"VAR\"
id=\"C,Wl8e|_BY7`@|WNRR)t\">things</field><value name=\"VALUE\"><block
type=\"oh_context_attribute\" id=\"|H7Nbd2VaPs{W;)0~AC?\"><value
name=\"key\"><shadow type=\"text\" id=\"K}t%;y/xn8{VP1ePVqF6\"><field
name=\"TEXT\">things</field></shadow></value></block></value><next><blo\
ck type=\"variables_set\" id=\"lI{JZ]zqeFw9P*HeI0t^\"><field
name=\"VAR\" id=\"Qzn]o6PxTzj]cn8bnT2k\">messageText</field><value
name=\"VALUE\"><block type=\"text\" id=\"/Let0^K`uHs}:3#7^N2p\"><field
name=\"TEXT\"></field></block></value><next><block
type=\"variables_set\" id=\"3Ld5v:`q))oi8DB;w=K?\"><field name=\"VAR\"
id=\"n0X6;%Q,_c=4$=`tHt^@\">ignoreList</field><value
name=\"VALUE\"><block type=\"lists_split\"
id=\"r3}xou^n;{KjY6dl0$RD\"><mutation mode=\"SPLIT\"></mutation><field
name=\"MODE\">SPLIT</field><value name=\"INPUT\"><block
type=\"variables_get\" id=\"(4kit^zIqe9-b/b7M4E*\"><field name=\"VAR\"
id=\"]8Kt_8cXjoij*UWfL]}Z\">ignore</field></block></value><value
name=\"DELIM\"><shadow type=\"text\" id=\"{CJs^j|p$=Y2x.Friu_p\"><field
name=\"TEXT\">,</field></shadow></value></block></value><next><block
type=\"oh_log\" id=\"V67tNp:rbdm+Y}L/x,4o\"><field
name=\"severity\">debug</field><value name=\"message\"><shadow
type=\"text\" id=\"i77BH#sZ2AL=2nNh=4Hb\"><field
name=\"TEXT\">abc</field></shadow><block type=\"oh_context_attribute\"
id=\"ItP}])9xOd?Z/v6/F)Py\"><value name=\"key\"><shadow type=\"text\"
id=\"8=q=T@jmhGwC1D2tk#uR\"><field
name=\"TEXT\">things</field></shadow></value></block></value><next><blo\
ck type=\"controls_forEach\" id=\"!*_/[dld@qMo~k.%wH8:\"><field
name=\"VAR\" id=\"%x2mOh`(Hd/#(A4O/k(]\">curThing</field><value
name=\"LIST\"><block type=\"variables_get\"
id=\"{;vLL.})j{+K}2-,fUf8\"><field name=\"VAR\"
id=\"C,Wl8e|_BY7`@|WNRR)t\">things</field></block></value><statement
name=\"DO\"><block type=\"oh_script_inline\"
id=\"dad|U8=9dRN@P@6#vrHj\"><field name=\"inlineScript\">thingLabel =
curThing.getLabel()&#10;thingId =
curThing.getUID().getId()&#10;thingStatus =
curThing.getStatus()</field><next><block type=\"controls_if\"
id=\"mxJbf8]-5BmqywT7W5sf\"><value name=\"IF0\"><block
type=\"logic_compare\" id=\"DAUiQW`ij2Yv[Dy$Fk.c\"
inline=\"false\"><field name=\"OP\">EQ</field><value name=\"A\"><block
type=\"lists_indexOf\" id=\"rv,~hIA.]{~wKDNOjtgR\"><field
name=\"END\">FIRST</field><value name=\"VALUE\"><block
type=\"variables_get\" id=\"6=$+}$AWvB)[v-ULY%0.\"><field name=\"VAR\"
id=\"n0X6;%Q,_c=4$=`tHt^@\">ignoreList</field></block></value><value
name=\"FIND\"><block type=\"variables_get\"
id=\"gPiC8%I:1C,ClMm@E+)h\"><field name=\"VAR\"
id=\"E%{F|_6VUVE]s;x=yceK\">thingId</field></block></value></block></va\
lue><value name=\"B\"><block type=\"math_number\"
id=\"/)KV?LC6;7ebjx|rMe#t\"><field
name=\"NUM\">0</field></block></value></block></value><statement
name=\"DO0\"><block type=\"text_append\"
id=\"J;;7GOyh~?h@QmS$GpfU\"><field name=\"VAR\"
id=\"Qzn]o6PxTzj]cn8bnT2k\">messageText</field><value
name=\"TEXT\"><shadow type=\"text\"><field
name=\"TEXT\"></field></shadow><block type=\"text_join\"
id=\"|4xA3YmbBj_/WySmg;b%\" inline=\"false\"><mutation
items=\"8\"></mutation><value name=\"ADD0\"><block type=\"oh_text_crlf\"
id=\"R=RwT3r2c!MldtMCh~7!\"></block></value><value name=\"ADD1\"><block
type=\"text\" id=\"qRfw,*rM9t]f]-k:QuO~\"><field
name=\"TEXT\">____________________________</field></block></value><value
name=\"ADD2\"><block type=\"oh_text_crlf\"
id=\".6xin}kznn2)oLg+PQHw\"></block></value><value name=\"ADD3\"><block
type=\"variables_get\" id=\"_~:^T3ya1r+kmE=;[!hA\"><field name=\"VAR\"
id=\"oJm$Rz.ax{=5CWVHpP6o\">thingLabel</field></block></value><value
name=\"ADD4\"><block type=\"text\" id=\",hu(4Y3uo%@~MBdyohQx\"><field
name=\"TEXT\"> (</field></block></value><value name=\"ADD5\"><block
type=\"variables_get\" id=\"G{1T=[t4mL,J]J|)WHU!\"><field name=\"VAR\"
id=\"E%{F|_6VUVE]s;x=yceK\">thingId</field></block></value><value
name=\"ADD6\"><block type=\"text\" id=\"lQ-81UfA^x01nOhBe8tV\"><field
name=\"TEXT\">): </field></block></value><value name=\"ADD7\"><block
type=\"variables_get\" id=\"-)va(!nQ2Pe@%?I3@M4V\"><field name=\"VAR\"
id=\"HrLFiEjH(SOud$zz{9iv\">thingStatus</field></block></value></block>\
</value></block></statement></block></next></block></statement><next><b\
lock type=\"controls_if\" id=\"4l=bGRXqL*m#4st3WbIV\"><value
name=\"IF0\"><block type=\"logic_negate\"
id=\";TGEaI7pk;r.Wd`XTB%m\"><value name=\"BOOL\"><block
type=\"text_isEmpty\" id=\"+|%Pzk,zFYtfTEN;/b6.\"><value
name=\"VALUE\"><shadow type=\"text\" id=\"eP+GnzQ;!+qFSR:f6Z@F\"><field
name=\"TEXT\"></field></shadow><block type=\"variables_get\"
id=\"}eT[MPm),_,qbA._-|nz\"><field name=\"VAR\"
id=\"Qzn]o6PxTzj]cn8bnT2k\">messageText</field></block></value></block>\
</value></block></value><statement name=\"DO0\"><block
type=\"telegram_with_chatID_message\" id=\"%?.)2$rZJ)1$`[CGZ9qP\"
inline=\"false\"><value name=\"MESSAGE\"><shadow type=\"text\"
id=\"%jIrNi@b+!)=WA-_P8,8\"><field name=\"TEXT\">What's
up?</field></shadow><block type=\"text_join\"
id=\"+:B^y;:|mtkaD2WvQ-/;\"><mutation items=\"2\"></mutation><value
name=\"ADD0\"><block type=\"text\" id=\"Vq%.RspM!Sb]4j|oA!Yq\"><field
name=\"TEXT\">*Things not online:*</field></block></value><value
name=\"ADD1\"><block type=\"variables_get\"
id=\";tdF%Ltj{[p+U`Yxi09~\"><field name=\"VAR\"
id=\"Qzn]o6PxTzj]cn8bnT2k\">messageText</field></block></value></block>\
</value><value name=\"BOT\"><shadow type=\"oh_thing\"
id=\"!e*,mpQ{}pF?C[R{m==`\"><field
name=\"thingUid\">telegram:telegramBot:Telegram-Bot</field></shadow></v\
alue><value name=\"CHAT_ID\"><shadow type=\"math_number\"
id=\"Atq3IW%ItA[[RXD}bR/0\"><field
name=\"NUM\">-123</field></shadow></value></block></statement></block><\
/next></block></next></block></next></block></next></block></next></blo\
ck></next></block></next></block></xml>"
type: application/javascript
script: >
var ignore, things, messageText, ignoreList, curThing, thingId,
thingLabel, thingStatus;
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var things2 = Java.type('org.openhab.core.model.script.actions.Things');
ignore = 'example_ID1,exampleID2';
things = ctx['things'];
messageText = '';
ignoreList = ignore.split(',');
logger.debug(ctx['things']);
for (var curThing_index in things) {
curThing = things[curThing_index];
thingLabel = curThing.getLabel()
thingId = curThing.getUID().getId()
thingStatus = curThing.getStatus()
if (ignoreList.indexOf(thingId) + 1 == 0) {
messageText += String(['\r\n','____________________________','\r\n',thingLabel,' (',thingId,'): ',thingStatus].join(''));
}
}
if (!!messageText.length) {
things2.getActions('telegram', 'telegram:telegramBot:Telegram-Bot').sendTelegram(-123, '*Things not online:*' + String(messageText));
}
type: script.ScriptAction
And the screenshot:
Thanks Rich for pointing me in the right direction.