Created
April 26, 2022 12:17
-
-
Save padaVVan/9f0b3c41987a81820aa1fe0f4ac40d85 to your computer and use it in GitHub Desktop.
Up/Down Switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "03d1fe605e7ed494", | |
"type": "subflow", | |
"name": "UD Switch", | |
"info": "Up/Down Switcher", | |
"category": "", | |
"in": [ | |
{ | |
"x": 244, | |
"y": 272, | |
"wires": [ | |
{ | |
"id": "2b906dcad292535c" | |
} | |
] | |
} | |
], | |
"out": [ | |
{ | |
"x": 516, | |
"y": 240, | |
"wires": [ | |
{ | |
"id": "2b906dcad292535c", | |
"port": 0 | |
} | |
] | |
}, | |
{ | |
"x": 516, | |
"y": 304, | |
"wires": [ | |
{ | |
"id": "2b906dcad292535c", | |
"port": 1 | |
} | |
] | |
} | |
], | |
"env": [ | |
{ | |
"name": "initial", | |
"type": "str", | |
"value": "up", | |
"ui": { | |
"icon": "font-awesome/fa-arrows-v", | |
"label": { | |
"en-US": "Initial" | |
}, | |
"type": "select", | |
"opts": { | |
"opts": [ | |
{ | |
"l": { | |
"en-US": "Up" | |
}, | |
"v": "up" | |
}, | |
{ | |
"l": { | |
"en-US": "Down" | |
}, | |
"v": "down" | |
} | |
] | |
} | |
} | |
} | |
], | |
"meta": { | |
"author": "Oleg Koltsov", | |
"desc": "Up/Down Switcher", | |
"keywords": "switcher" | |
}, | |
"color": "#DDAA99", | |
"outputLabels": [ | |
"▲ Up", | |
"▼ Down" | |
], | |
"icon": "node-red/switch.svg", | |
"status": { | |
"x": 516, | |
"y": 368, | |
"wires": [ | |
{ | |
"id": "d7dc04e4535169a8", | |
"port": 0 | |
} | |
] | |
} | |
}, | |
{ | |
"id": "2b906dcad292535c", | |
"type": "function", | |
"z": "03d1fe605e7ed494", | |
"name": "", | |
"func": "let state = context.get('state')\n\nif (state === undefined) {\n state = env.get('initial') == 'up'\n}\n\nnode.status({fill:\"green\", shape:\"dot\", text:state ? \"▲\" : \"▼\"})\n\ncontext.set('state', !state)\n\nif (state) {\n return [msg, null]\n} else {\n return [null, msg]\n}", | |
"outputs": 2, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 380, | |
"y": 272, | |
"wires": [ | |
[], | |
[] | |
], | |
"outputLabels": [ | |
"▲ Up", | |
"▼ Down" | |
] | |
}, | |
{ | |
"id": "d7dc04e4535169a8", | |
"type": "status", | |
"z": "03d1fe605e7ed494", | |
"name": "", | |
"scope": [ | |
"2b906dcad292535c" | |
], | |
"x": 380, | |
"y": 368, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "8b596f84b0bf7b80", | |
"type": "subflow:03d1fe605e7ed494", | |
"z": "2ba8e4446e979585", | |
"name": "", | |
"x": 396, | |
"y": 720, | |
"wires": [ | |
[], | |
[] | |
] | |
} | |
] |
Author
padaVVan
commented
Apr 26, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment