global.set('rotation', 1);
function setrainfall() {
msg.payload = global.get('rainfall');
global.set('rotation', 2);
}
function sethumidity() {
msg.payload = global.get('humidity');
global.set('rotation', 3);
}
function setwindspeed() {
msg.payload = global.get('windspeed');
global.set('rotation', 1);
}
if (global.get('rotation') == 1) { setrainfall() }
if (global.get('rotation') == 2) { sethumidity() }
if (global.get('rotation') == 3) { setwindspeed() }
return msg;
still gives payload undefined
@colin the global.set for humidity, windspeed and rainfall are set and working.. currently im using timed injects to achieve the changing of the weather but its clunky and gets out of time.. thats why i thought a function was a more elegant way of doing it
[{"id":"eb3d7fa.90ab38","type":"tab","label":"test page","disabled":false,"info":""},{"id":"fe1746ff.1fbec8","type":"function","z":"eb3d7fa.90ab38","name":"","func":"global.set('rotation', 1);\nfunction setrainfall() {\n msg.payload = global.get('rainfall');\n global.set('rotation', 2);\n }\n\nfunction sethumidity() {\n msg.payload = global.get('humidity');\n global.set('rotation', 3);\n }\n \nfunction setwindspeed() {\n msg.payload = global.get('windspeed');\n global.set('rotation', 1);\n } \n \nif (global.get('rotation') == 1) { setrainfall() }\nif (global.get('rotation') == 2) { sethumidity() }\nif (global.get('rotation') == 3) { setwindspeed() }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":220,"wires":[["1b6d5bac.08e2a4"]]},{"id":"30e85221.555c3e","type":"inject","z":"eb3d7fa.90ab38","name":"","props":[{"p":"trigger1","v":"ok","vt":"str"}],"repeat":"20","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":220,"y":220,"wires":[["fe1746ff.1fbec8"]]},{"id":"1b6d5bac.08e2a4","type":"debug","z":"eb3d7fa.90ab38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":220,"wires":[]}]