[ { "id": "9d4c4d1d.58c72", "type": "tab", "label": "Solar panel", "disabled": false, "info": "" }, { "id": "5fda76aa.462df8", "type": "http request", "z": "9d4c4d1d.58c72", "name": "", "method": "GET", "ret": "obj", "paytoqs": false, "url": "http://api.openweathermap.org/data/2.5/weather?id=2615003&units=metric&APPID=", "tls": "", "persist": false, "proxy": "", "authType": "", "x": 310, "y": 80, "wires": [ [ "2fece3db.c5857c", "67314ed.84fffb", "c73c7fdd.7ffbc", "ca980817.e36f58" ] ], "info": "http://openweathermap.org/\nSign in to get a free api" }, { "id": "2fece3db.c5857c", "type": "debug", "z": "9d4c4d1d.58c72", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 530, "y": 40, "wires": [] }, { "id": "67314ed.84fffb", "type": "function", "z": "9d4c4d1d.58c72", "name": "temp wind RH drg", "func": "msg.payload = (\"T1:\"+(msg.payload.main.temp)+\",RH:\"+(msg.payload.main.humidity)+\",deg:\"+(msg.payload.wind.deg)+\",speed:\"+(msg.payload.wind.speed));\nreturn msg;\n\n\n\n", "outputs": 1, "noerr": 0, "x": 550, "y": 80, "wires": [ [ "e7b7f761.1c2bd8", "204f4e00.fdb0c2" ] ] }, { "id": "c73c7fdd.7ffbc", "type": "function", "z": "9d4c4d1d.58c72", "d": true, "name": "Time of day", "func": "day = ((msg.payload.dt - msg.payload.sys.sunrise)/(msg.payload.sys.sunset - msg.payload.sys.sunrise))*(Math.floor (Math.random() *(50-30)+30)/100)*1500;\nmsg.payload = day;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 530, "y": 180, "wires": [ [] ] }, { "id": "ca980817.e36f58", "type": "function", "z": "9d4c4d1d.58c72", "name": "Solarpanel", "func": "var HP=1500;// installed power of the heatpump in watts\n \n// to calculate the suns position on the horizon on hte present day.\n\nday = ((msg.payload.dt - msg.payload.sys.sunrise)/(msg.payload.sys.sunset - msg.payload.sys.sunrise));\nday = day*Math.PI;\nday = Math.sin(day);\nif (day<0.01)\n{day = 0}\n\n\ncloud = msg.payload.clouds.all;// to calculate the amount of sunlight \nrnd=Math.floor (Math.random() * (10 - 1) + 1);\ncloud = ((100 - cloud+rnd)/100);//+10 to give a little load\nif (cloud>1)\n{cloud = 1}\n\n\n\n// to calculate the hight of the sun based on what time of year.\nvar now = new Date();\nvar start = new Date(now.getFullYear(), 0, 0);\nvar diff = (now - start) + ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);\nvar oneDay = 1000 * 60 * 60 * 24;\nvar day_of_year = (Math.floor(diff / oneDay))+10;//+10 to not have zero output on first and last day of year due to the sin() function\nday_of_year=(day_of_year/386)*Math.PI;//\nday_of_year= Math.sin(day_of_year);\n\n\nvar result=day*cloud*HP*day_of_year;\n//output to emonpi\nmsg.payload = (\"PV:\"+result+\",daytime:\"+day);\nreturn msg;", "outputs": 1, "noerr": 0, "x": 530, "y": 120, "wires": [ [ "e7b7f761.1c2bd8", "204f4e00.fdb0c2" ] ] }, { "id": "9dae2520.76f9e8", "type": "inject", "z": "9d4c4d1d.58c72", "name": "5Min Timer", "topic": "", "payload": "", "payloadType": "date", "repeat": "300", "crontab": "", "once": true, "onceDelay": 0.1, "x": 130, "y": 80, "wires": [ [ "5fda76aa.462df8", "c7f7a97c.149468" ] ], "info": "Note: on a free account I think it is vise not to \npull request to often. Every 5 minutes would be fine." }, { "id": "e7b7f761.1c2bd8", "type": "emoncms", "z": "9d4c4d1d.58c72", "name": "Emoncms Push", "emonServer": "4189409d.27ae3", "nodegroup": "emonpi", "datatype": "legacy", "x": 880, "y": 80, "wires": [] }, { "id": "c7f7a97c.149468", "type": "function", "z": "9d4c4d1d.58c72", "d": true, "name": "day of year", "func": "var now = new Date();\nvar start = new Date(now.getFullYear(), 0, 0);\nvar diff = (now - start) + ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);\nvar oneDay = 1000 * 60 * 60 * 24;\nvar day = Math.floor(diff / oneDay);\nmsg.payload=('Day of year: ' + day);\nreturn msg;", "outputs": 1, "noerr": 0, "x": 530, "y": 240, "wires": [ [] ] }, { "id": "204f4e00.fdb0c2", "type": "debug", "z": "9d4c4d1d.58c72", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 870, "y": 40, "wires": [] }, { "id": "4189409d.27ae3", "type": "emoncms-server", "z": "", "server": "http://localhost/emoncms", "name": "EmonBase" } ]