[ { "uid":"kaikreuzer:firealarm", "label":"Fire Alarm", "description":"Checks all temperature sensors for abnormal values and activates an alarm.", "configDescriptions":[ { "name":"temperature", "type":"TEXT", "context":"item", "label":"Temperature Group", "description":"The group of all temperature sensors", "required":true }, { "name":"threshold", "type":"INTEGER", "label":"Threshold", "description":"Alarm will be triggered if one sensor exceeds this value.", "required":true } ], "triggers": [ { "id": "1", "label": "a room temperature changes", "description": "", "configuration": { "itemName": "{{temperature}}" }, "type": "core.ItemStateChangeTrigger" } ], "conditions": [], "actions": [ { "inputs": {}, "id": "2", "label": "activate alarm if any sensor has a critical value", "description": "Sends ON to all switch items tagged with 'Alarm'", "configuration": { "type": "application/javascript", "script": "var temperatures = items.get('{{temperature}}').getAllMembers()\nvar alarm = false\ntemperatures.forEach(function(element) {\n if(element.state > ${threshold}) alarm = true\n});\nif(alarm==true) {\n items.getItemsByTagAndType('Switch', 'Alarm').forEach(function(element) {\n element.send(ON)\n });\n}" }, "type": "script.ScriptAction" } ] } ]