Created
January 21, 2020 08:33
-
-
Save arozhankov/d43077c82abab7d4e4f86c1068079bc3 to your computer and use it in GitHub Desktop.
Node-RED. Forecast code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "73c7f5a0.1d0ebc", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MaxTime0", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMaxTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MaxTime0", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 970, | |
"y": 680, | |
"wires": [ | |
[ | |
"b3c2083c.2c4358" | |
] | |
] | |
}, | |
{ | |
"id": "947e88cb.953b58", | |
"type": "http request", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": false, | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 630, | |
"y": 840, | |
"wires": [ | |
[ | |
"2bfb87d8.6e8178" | |
] | |
] | |
}, | |
{ | |
"id": "2bfb87d8.6e8178", | |
"type": "json", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"property": "payload", | |
"action": "", | |
"pretty": false, | |
"x": 770, | |
"y": 840, | |
"wires": [ | |
[ | |
"2a72cfba.e7112", | |
"20744a2c.6c0386", | |
"43320c88.d96ae4", | |
"9e636634.769d68" | |
] | |
] | |
}, | |
{ | |
"id": "40d2813f.b3804", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "url date+", | |
"func": "msg.url=\n\"https://api.darksky.net/forecast/\"+\n\"8c436809881364415cb1ba009316be79/\"+\n\"55.018803,82.933952,\"+\nmsg.payload+\n\"?units=si&exclude=hourly,flags\";\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 440, | |
"y": 840, | |
"wires": [ | |
[ | |
"947e88cb.953b58" | |
] | |
] | |
}, | |
{ | |
"id": "91733c96.08414", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "date+", | |
"func": "var date = new Date();\ndate.setHours( 10,0,0,0 );\nvar amount = msg.payload;\n\n\n//=====\n \nvar tzOff = date.getTimezoneOffset() * 60 * 1000,\n t = date.getTime(),\n d = new Date(),\n tzOff2;\n\n t += (1000 * 60 * 60 * 24) * amount;\n d.setTime(t);\n\n tzOff2 = date.getTimezoneOffset() * 60 * 1000;\n if (tzOff != tzOff2) {\n var diff = tzOff2 - tzOff;\n t += diff;\n d.setTime(t);\n }\n\n//=====\n\nmsg.payload = d.getTime() / 1000;\n \nreturn msg;\n\n\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 310, | |
"y": 840, | |
"wires": [ | |
[ | |
"40d2813f.b3804" | |
] | |
] | |
}, | |
{ | |
"id": "3d96d307.f45e7c", | |
"type": "inject", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "00 10 * * *", | |
"once": false, | |
"onceDelay": "60", | |
"x": 150, | |
"y": 440, | |
"wires": [ | |
[ | |
"33f5bd7c.35ba02", | |
"a2bf5b6c.2850b8", | |
"bba04109.95f2" | |
] | |
] | |
}, | |
{ | |
"id": "20744a2c.6c0386", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MinTime1", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMinTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MinTime1", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 960, | |
"y": 820, | |
"wires": [ | |
[ | |
"561ed6ba.d92618" | |
] | |
] | |
}, | |
{ | |
"id": "2a72cfba.e7112", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Min1", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMin", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Min1", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 780, | |
"wires": [ | |
[ | |
"8313edfc.cb98f" | |
] | |
] | |
}, | |
{ | |
"id": "9e636634.769d68", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MaxTime1", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMaxTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MaxTime1", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 970, | |
"y": 900, | |
"wires": [ | |
[ | |
"32941103.654c9e" | |
] | |
] | |
}, | |
{ | |
"id": "43320c88.d96ae4", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Max1", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMax", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Max1", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 860, | |
"wires": [ | |
[ | |
"858d8df1.810d8" | |
] | |
] | |
}, | |
{ | |
"id": "561ed6ba.d92618", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 820, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "32941103.654c9e", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 900, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "6c4ce702.b47368", | |
"type": "join", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"mode": "custom", | |
"build": "object", | |
"property": "payload", | |
"propertyType": "msg", | |
"key": "topic", | |
"joiner": "\\n", | |
"joinerType": "str", | |
"accumulate": false, | |
"timeout": "", | |
"count": "12", | |
"reduceRight": false, | |
"reduceExp": "", | |
"reduceInit": "", | |
"reduceInitType": "", | |
"reduceFixup": "", | |
"x": 1510, | |
"y": 860, | |
"wires": [ | |
[ | |
"9802e6b4.bdf818" | |
] | |
] | |
}, | |
{ | |
"id": "ae649d08.62a22", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"func": "\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1370, | |
"y": 860, | |
"wires": [ | |
[ | |
"6c4ce702.b47368" | |
] | |
] | |
}, | |
{ | |
"id": "9802e6b4.bdf818", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "message", | |
"func": "var forecast=msg.payload;\n\nmsg.payload=\n\"Сегодня в \"+forecast.MinTime0.date+\"\\n\"+\n\"Мин темп в \"+forecast.MinTime0.time+\" = \"+forecast.Min0+\"\\n\"+\n\"Макс темп в \"+forecast.MaxTime0.time+\" = \"+forecast.Max0+\"\\n\"+\n\n\"\\n================\\n\\n\"+\n\n\"Завтра в \"+forecast.MinTime1.date+\"\\n\"+\n\"Мин темп в \"+forecast.MinTime1.time+\" = \"+forecast.Min1+\"\\n\"+\n\"Макс темп в \"+forecast.MaxTime1.time+\" = \"+forecast.Max1+\"\\n\"+\n\n\"\\n================\\n\\n\"+\n\n\"Послезавтра в \"+forecast.MinTime2.date+\"\\n\"+\n\"Мин темп в \"+forecast.MinTime2.time+\" = \"+forecast.Min2+\"\\n\"+\n\"Макс темп в \"+forecast.MaxTime2.time+\" = \"+forecast.Max2+\"\\n\";\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1670, | |
"y": 860, | |
"wires": [ | |
[ | |
"5b65e400.adb81c" | |
] | |
] | |
}, | |
{ | |
"id": "56f7e8c1.cc18e8", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "pushover info", | |
"func": "msg.sound=\"none\";\nmsg.topic=\"Прогноз на 2 дня\";\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 2080, | |
"y": 860, | |
"wires": [ | |
[ | |
"74f8e774.a623e8" | |
] | |
] | |
}, | |
{ | |
"id": "74f8e774.a623e8", | |
"type": "pushover api", | |
"z": "91719b7c.87e078", | |
"keys": "84341e2b.91871", | |
"title": "", | |
"name": "", | |
"x": 2340, | |
"y": 860, | |
"wires": [] | |
}, | |
{ | |
"id": "33f5bd7c.35ba02", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "1", | |
"func": "msg.payload = 1;\n \nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 170, | |
"y": 840, | |
"wires": [ | |
[ | |
"91733c96.08414" | |
] | |
] | |
}, | |
{ | |
"id": "a2bf5b6c.2850b8", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "2", | |
"func": "msg.payload = 2;\n \nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 170, | |
"y": 1060, | |
"wires": [ | |
[ | |
"3b8cb309.15cf9c" | |
] | |
] | |
}, | |
{ | |
"id": "66004d6d.2856d4", | |
"type": "http request", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": false, | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 630, | |
"y": 1060, | |
"wires": [ | |
[ | |
"2b0b6d.613b0494" | |
] | |
] | |
}, | |
{ | |
"id": "2b0b6d.613b0494", | |
"type": "json", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"property": "payload", | |
"action": "", | |
"pretty": false, | |
"x": 770, | |
"y": 1060, | |
"wires": [ | |
[ | |
"63e792e9.880f4c", | |
"2c1ed151.0eb4ee", | |
"eaa1603d.0194f", | |
"973093b1.fcbf4" | |
] | |
] | |
}, | |
{ | |
"id": "bf8f49b3.88e9f8", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "url date+", | |
"func": "msg.url=\n\"https://api.darksky.net/forecast/\"+\n\"8c436809881364415cb1ba009316be79/\"+\n\"55.018803,82.933952,\"+\nmsg.payload+\n\"?units=si&exclude=hourly,flags\";\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 440, | |
"y": 1060, | |
"wires": [ | |
[ | |
"66004d6d.2856d4" | |
] | |
] | |
}, | |
{ | |
"id": "3b8cb309.15cf9c", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "date+", | |
"func": "var date = new Date();\ndate.setHours( 10,0,0,0 );\nvar amount = msg.payload;\n\n\n//=====\n \nvar tzOff = date.getTimezoneOffset() * 60 * 1000,\n t = date.getTime(),\n d = new Date(),\n tzOff2;\n\n t += (1000 * 60 * 60 * 24) * amount;\n d.setTime(t);\n\n tzOff2 = date.getTimezoneOffset() * 60 * 1000;\n if (tzOff != tzOff2) {\n var diff = tzOff2 - tzOff;\n t += diff;\n d.setTime(t);\n }\n\n//=====\n\nmsg.payload = d.getTime() / 1000;\n \nreturn msg;\n\n\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 310, | |
"y": 1060, | |
"wires": [ | |
[ | |
"bf8f49b3.88e9f8" | |
] | |
] | |
}, | |
{ | |
"id": "2c1ed151.0eb4ee", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MinTime2", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMinTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MinTime2", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 960, | |
"y": 1040, | |
"wires": [ | |
[ | |
"44961272.cb27fc" | |
] | |
] | |
}, | |
{ | |
"id": "63e792e9.880f4c", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Min2", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMin", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Min2", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 1000, | |
"wires": [ | |
[ | |
"f7a091e2.86447" | |
] | |
] | |
}, | |
{ | |
"id": "973093b1.fcbf4", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MaxTime2", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMaxTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MaxTime2", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 970, | |
"y": 1120, | |
"wires": [ | |
[ | |
"b2c5f23a.32e9" | |
] | |
] | |
}, | |
{ | |
"id": "eaa1603d.0194f", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Max2", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMax", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Max2", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 1080, | |
"wires": [ | |
[ | |
"76f4860a.3c51d8" | |
] | |
] | |
}, | |
{ | |
"id": "44961272.cb27fc", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 1040, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "b2c5f23a.32e9", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 1120, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "4feb7918.afaf78", | |
"type": "http request", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": false, | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 630, | |
"y": 620, | |
"wires": [ | |
[ | |
"ad5760fe.b2248" | |
] | |
] | |
}, | |
{ | |
"id": "ad5760fe.b2248", | |
"type": "json", | |
"z": "91719b7c.87e078", | |
"name": "", | |
"property": "payload", | |
"action": "", | |
"pretty": false, | |
"x": 770, | |
"y": 620, | |
"wires": [ | |
[ | |
"573ad77a.e0d248", | |
"88173062.24871", | |
"22f8c20c.e8ec4e", | |
"73c7f5a0.1d0ebc" | |
] | |
] | |
}, | |
{ | |
"id": "7ed55339.53a1ec", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "url date+", | |
"func": "msg.url=\n\"https://api.darksky.net/forecast/\"+\n\"8c436809881364415cb1ba009316be79/\"+\n\"55.018803,82.933952,\"+\nmsg.payload+\n\"?units=si&exclude=hourly,flags\";\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 440, | |
"y": 620, | |
"wires": [ | |
[ | |
"4feb7918.afaf78" | |
] | |
] | |
}, | |
{ | |
"id": "c614702b.663ff", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "date+", | |
"func": "var date = new Date();\ndate.setHours( 10,0,0,0 );\nvar amount = msg.payload;\n\n\n//=====\n \nvar tzOff = date.getTimezoneOffset() * 60 * 1000,\n t = date.getTime(),\n d = new Date(),\n tzOff2;\n\n t += (1000 * 60 * 60 * 24) * amount;\n d.setTime(t);\n\n tzOff2 = date.getTimezoneOffset() * 60 * 1000;\n if (tzOff != tzOff2) {\n var diff = tzOff2 - tzOff;\n t += diff;\n d.setTime(t);\n }\n\n//=====\n\nmsg.payload = d.getTime() / 1000;\n \nreturn msg;\n\n\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 310, | |
"y": 620, | |
"wires": [ | |
[ | |
"7ed55339.53a1ec" | |
] | |
] | |
}, | |
{ | |
"id": "88173062.24871", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "MinTime0", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMinTime*1000", | |
"tot": "jsonata" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "MinTime0", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 960, | |
"y": 600, | |
"wires": [ | |
[ | |
"8cca9fbc.5e36d" | |
] | |
] | |
}, | |
{ | |
"id": "573ad77a.e0d248", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Min0", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMin", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Min0", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 560, | |
"wires": [ | |
[ | |
"3102e046.56bd4" | |
] | |
] | |
}, | |
{ | |
"id": "22f8c20c.e8ec4e", | |
"type": "change", | |
"z": "91719b7c.87e078", | |
"name": "Max0", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payload.daily.data[0].temperatureMax", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "topic", | |
"pt": "msg", | |
"to": "Max0", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 950, | |
"y": 640, | |
"wires": [ | |
[ | |
"d97d40c0.10259" | |
] | |
] | |
}, | |
{ | |
"id": "8cca9fbc.5e36d", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 600, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "b3c2083c.2c4358", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "DateSec2DateString", | |
"func": "var date = new Date(msg.payload);\n\nvar weekday = new Array(7);\nweekday[0] = 'Пн';\nweekday[1] = 'Вт';\nweekday[2] = 'Ср';\nweekday[3] = 'Чт';\nweekday[4] = 'Пт';\nweekday[5] = 'Сб';\nweekday[6] = 'Вс';\n\nvar monthN = new Array(12);\nmonthN[0] = 'янв';\nmonthN[1] = 'фев';\nmonthN[2] = 'мар';\nmonthN[3] = 'апр';\nmonthN[4] = 'май';\nmonthN[5] = 'июн';\nmonthN[6] = 'июл';\nmonthN[7] = 'авг';\nmonthN[8] = 'сен';\nmonthN[9] = 'окт';\nmonthN[10] = 'ноя';\nmonthN[11] = 'дек';\n\n\nhour = date.getHours();\nminute = date.getMinutes();\nsecond = date.getSeconds();\n\nday = date.getDate();\nmonth = date.getMonth()+1;\nyear = date.getFullYear()-2000;\n\ndayName = weekday[date.getDay()-1];\nmonthName = monthN[date.getMonth()];\n\ndateString = dayName + ', ' +\n day.toString().padStart(2, '0') + ' ' + \n monthName;\n //month.toString().padStart(2, '0');\n //year.toString().padStart(2, '0');\n\ntimeString = hour.toString().padStart(2, '0') + ':' + \n minute.toString().padStart(2, '0');\n //second.toString().padStart(2, '0');\n \nmsg.payload = {};\n\nmsg.payload.general = dateString + \" \" + timeString;\nmsg.payload.date = dateString;\nmsg.payload.time = timeString;\nmsg.payload.monthday = day.toString().padStart(2, '0');\nmsg.payload.dayname = dayName;\nmsg.payload.month = month;\nmsg.payload.monthname = monthName;\nmsg.payload.year = year;\nmsg.payload.hour = hour.toString().padStart(2, '0');\nmsg.payload.minute = minute.toString().padStart(2, '0');\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1160, | |
"y": 680, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "bba04109.95f2", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "0", | |
"func": "msg.payload = 0;\n \nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 170, | |
"y": 620, | |
"wires": [ | |
[ | |
"c614702b.663ff" | |
] | |
] | |
}, | |
{ | |
"id": "3102e046.56bd4", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 560, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "d97d40c0.10259", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 640, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "8313edfc.cb98f", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 780, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "858d8df1.810d8", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 860, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "f7a091e2.86447", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 1000, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "76f4860a.3c51d8", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "Round", | |
"func": "msg.payload = Math.round(msg.payload);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1110, | |
"y": 1080, | |
"wires": [ | |
[ | |
"ae649d08.62a22" | |
] | |
] | |
}, | |
{ | |
"id": "5b65e400.adb81c", | |
"type": "function", | |
"z": "91719b7c.87e078", | |
"name": "clear msg", | |
"func": "msg.topic = \"\";\ndelete msg.url;\ndelete msg.statusCode;\ndelete msg.headers;\ndelete msg.responseUrl;\ndelete msg.redirectList;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1820, | |
"y": 860, | |
"wires": [ | |
[ | |
"56f7e8c1.cc18e8" | |
] | |
] | |
}, | |
{ | |
"id": "84341e2b.91871", | |
"type": "pushover-keys", | |
"z": "", | |
"name": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment