bud spencer vs. chuck norris

x

[{"id":"716588a7.bde418","type":"mqtt-broker","z":"45e1a306.2668bc","broker":"192.168.1.2","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"ccc9a664.4cfd28","type":"ui_tab","z":"45e1a306.2668bc","name":"Thuis","icon":"dashboard","order":"1"},{"id":"7fb58be.1d9d174","type":"http request","z":"45e1a306.2668bc","name":"SunRise Time","method":"GET","ret":"obj","url":"http://api.sunrise-sunset.org/json?lat=52.0623605&lng=4.3766484&date=today","x":257.95729064941406,"y":448.7840881347656,"wires":[["2551529d.b17abe"]]},{"id":"2551529d.b17abe","type":"function","z":"45e1a306.2668bc","name":"Day light timer","func":"//Based on UTC time\n// Generate current time in seconds form noon\nvar d = new Date();\nvar h = d.getUTCHours();\nvar m = d.getUTCMinutes();\nvar s = d.getUTCSeconds();\nvar Tsec = h*3600 +m*60 +s; // Current time\n\n// sunrise time (UTC)\nvar sunrise = {\n    payload:msg.payload.results.sunrise,\n    };\nsunrise=JSON.stringify(sunrise);\nsunrise = sunrise.slice(12,-5); // Remove additional payload information\nvar a = sunrise.split(':'); // split it at the colons\nvar SRsec = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); \n\n// Day ligt time \nvar day_length = {\n    payload:msg.payload.results.day_length,\n    };\nday_length=JSON.stringify(day_length);\nday_length = day_length.slice(12,-2); // remove addition payload information\nvar b = day_length.split(':'); // split it at the colons\nvar DLsec = (+b[0]) * 60 * 60 + (+b[1]) * 60 + (+b[2]); \n\n// Calculate light status\nif (Tsec < SRsec -600){\n    var light = true;\n}else if (Tsec > SRsec+DLsec +1200){\n    light = true;    \n}else{\n    light = false;\n}\n\nmsg= {payload:light};\nreturn msg;","outputs":"1","noerr":0,"x":446.8492431640625,"y":450.48419189453125,"wires":[["7bcb6cd3.9ce6c4"]]},{"id":"7bcb6cd3.9ce6c4","type":"ui_switch","z":"45e1a306.2668bc","tab":"ccc9a664.4cfd28","name":"Tuin","topic":"Tuin verlichting","group":"Verlichting","order":"3","onvalue":"1","offvalue":"0","x":620.9601898193359,"y":451.13629150390625,"wires":[["87587313.b7542"]]},{"id":"87587313.b7542","type":"mqtt out","z":"45e1a306.2668bc","name":"Tuin Verlichting","topic":"TUINPWR_IN","qos":"","retain":"true","broker":"716588a7.bde418","x":791.0994110107422,"y":451.0909423828125,"wires":[]},{"id":"89fa0923.444588","type":"inject","z":"45e1a306.2668bc","name":"refresh","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"x":89.95170593261719,"y":448.9687194824219,"wires":[["7fb58be.1d9d174"]]}]

Flow Info

Created 8 years, 7 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x1)
  • http request (x1)
  • inject (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
Other
  • ui_switch (x1)
  • ui_tab (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option