From 7f4bf7ca7ebf3d97e48ac754abaae7aafe92ec16 Mon Sep 17 00:00:00 2001 From: unixweb Date: Sat, 20 Jun 2020 09:46:18 +0200 Subject: [PATCH] Added new Function --- toogle.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 toogle.js diff --git a/toogle.js b/toogle.js new file mode 100644 index 0000000..6af681e --- /dev/null +++ b/toogle.js @@ -0,0 +1,17 @@ +/* +if we receive a true we toogle output +and store the new state in a local context +with a unique name +*/ +var fname = "toggle1"; + +if(msg.payload === true){ + +if(context.get(fname) === false){ + msg.payload = true; +}else{ + msg.payload = false; +} +context.set(fname, msg.payload); +} +return msg;