@rewenode sagte in Node-Red Programmabschnitte aktivieren/deaktivieren:
Beispiel flow
Was immer da schief lief, der Export läßt sich nicht importieren.
Nun sollte es gehen.
Spoiler
[
{
"id": "3fba4b65.667e1c",
"type": "ui_switch",
"z": "6a5f248f.c43fe4",
"name": "",
"label": "Alexa warnen lassen",
"tooltip": "",
"group": "e5a09358.c99e4",
"order": 4,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "AlexaWarnSwitch",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 280,
"y": 700,
"wires": [
[
"5161df40.dd73"
]
]
},
{
"id": "5161df40.dd73",
"type": "function",
"z": "6a5f248f.c43fe4",
"name": "Gate für Sensor",
"func": "// init/set context variable\nif (typeof context.get(\"AlexaWarnSwitch\") === \"undefined\") context.set(\"AlexaWarnSwitch\",\"0\");\n\n//if Switch, set context variable \nif (msg.topic == \"AlexaWarnSwitch\") {\n context.set(\"AlexaWarnSwitch\", msg.payload);\n node.status({fill: (msg.payload === true) ? \"green\" : \"red\",\n shape:\"dot\", \n text: (msg.payload === true) ? \"Warnung erlaubt\" : \"keine Warnung\"\n })\n} else { // msg comes from sensor\n if (context.get(\"AlexaWarnSwitch\")) node.send(msg); \n}\n",
"outputs": 1,
"noerr": 0,
"x": 540,
"y": 600,
"wires": [
[
"b425223f.3fa538"
]
]
},
{
"id": "48111ed4.b07f",
"type": "comment",
"z": "6a5f248f.c43fe4",
"name": "topic=\"AlexaWarnSwitch\"",
"info": "",
"x": 290,
"y": 660,
"wires": []
},
{
"id": "b425223f.3fa538",
"type": "debug",
"z": "6a5f248f.c43fe4",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 740,
"y": 600,
"wires": []
},
{
"id": "39119b95.d05fbc",
"type": "inject",
"z": "6a5f248f.c43fe4",
"name": "",
"topic": "",
"payload": "Sensorwert",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 580,
"wires": [
[
"5161df40.dd73"
]
]
},
{
"id": "25b5104b.2bddf",
"type": "comment",
"z": "6a5f248f.c43fe4",
"name": "Simuliert den Sensorwert",
"info": "",
"x": 290,
"y": 540,
"wires": []
},
{
"id": "e5a09358.c99e4",
"type": "ui_group",
"z": "6a5f248f.c43fe4",
"name": "Click",
"tab": "7341130f.164e84",
"order": 1,
"disp": true,
"width": "5"
},
{
"id": "7341130f.164e84",
"type": "ui_tab",
"z": "6a5f248f.c43fe4",
"name": "Home",
"icon": "link",
"order": 1
}
]