This MAY be a problem:
function
node code:
switch (msg.next) {
case 1:
msg.delay = msg.runtime1;
msg.payload = 1;
msg.next = 2;
break;
case 2:
msg.delay = msg.runtime2;
msg.payload = 2;
msg.next = 3;
break;
case 3:
msg.delay = msg.runtime3;
msg.payload = 3;
msg.next = 4;
break;
case 4:
msg.delay = msg.runtime4;
msg.payload = "OFF";
msg.next = 5;
break;
case 5:
msg.delay = msg.runtime4;
msg.payload = 5;
msg.reset = true;
//msg.next = 1;
break;
}
return msg;
msg.next
increments with each pass and msg.reset
is set to true
if msg.next
is 5.
It used to work fine. Now it is just going nuts sending weird/random messages which is driving the display it goes to crazy with brightness.
This is part of the flow:
[{"id":"bfb00242.9bfce8","type":"switch","z":"83bf3de4.b9429","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Dawn","vt":"str"},{"t":"eq","v":"Dusk","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":1700,"wires":[["24ab3b76.2e1e64","f8d4dc92.4e2ab"],["cc25e9fa.095798","b717b6df.8bcec8"]]},{"id":"b717b6df.8bcec8","type":"trigger","z":"83bf3de4.b9429","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"30","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Start","x":350,"y":1710,"wires":[["14b6b1de.cd731e"]]},{"id":"14b6b1de.cd731e","type":"function","z":"83bf3de4.b9429","name":"Initialize","func":"var interval = flow.get('Time_delay') || 10;\n\ninterval = (interval * 60000);\ncontext.set(\"interval\",interval); // for debuging\n//var interval = 30*60000; // (30 minutes)\n// interval = 3000; // Test\n// Define runtime1\nmsg.runtime1 = interval;\n\n// Define runtime2\nmsg.runtime2 = interval;\n\n// Define runtime3\nmsg.runtime3 = interval;\n\n// Define runtime4\nmsg.runtime4 = interval;\n\n// Define runtime5\nmsg.runtime5 = interval;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":1750,"wires":[["9e68c7a9.1756d8","39513fbf.c38d1"]]},{"id":"9e68c7a9.1756d8","type":"function","z":"83bf3de4.b9429","name":"Cycle next value","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 4;\n break; \n \n case 4:\n msg.delay = msg.runtime4;\n msg.payload = \"OFF\";\n msg.next = 5;\n break; \n case 5:\n msg.delay = msg.runtime4;\n msg.payload = 5;\n msg.reset = true;\n //msg.next = 1;\n break; \n\n}\n\n return msg;","outputs":1,"noerr":0,"x":540,"y":1750,"wires":[["e7a56f9a.9fcfc"]]},{"id":"e7a56f9a.9fcfc","type":"delay","z":"83bf3de4.b9429","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":1790,"wires":[["9e68c7a9.1756d8","48d676f5.1cbf78","ea72f1d.b06ae9"]]}]
The flow
value is set to 15. (15 seconds)
Originally it was a fixed value of 30 minutes - as you may see in one of the function
nodes.