Re: [node-red] Inject epoch into forecast.io

254 views
Skip to first unread message
Message has been deleted

Dave C-J

unread,
Aug 28, 2016, 5:51:31 PM8/28/16
to node...@googlegroups.com
Answered on Slack
Your change is the wrong way round... you need to set msg.time not msg.payload, and epoch is in mS
This works - Jan 1st Year 2000
[{"id":"d4b535d2.c19a08","type":"inject","z":"896b28a8.437658","name":"","topic":"","payload":"946684800000","payloadType":"num","repeat":"","crontab":"","once":false,"x":148,"y":1272,"wires":[["ee0063ea.fe855"]]},{"id":"ee0063ea.fe855","type":"change","z":"896b28a8.437658","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":225,"y":1358,"wires":[["4032a22a.6f663c"]]}]

Toshi Bass

unread,
Aug 29, 2016, 7:48:02 AM8/29/16
to Node-RED


Hi am banging my head a little with this one I have a dropdown node to a  function node with following code ...
 
msg1={};
msg2={};

var now = new Date();
var epoch = now.valueOf();

if(msg.payload==1){
    var e1 = epoch-(60*60*48*1000);
    msg1.payload = new Date(e1);
    msg2.payload = e1;
}

blabla

both msg1 and msg2 work fine but on msg2 I just want the date like Sat Aug 27 2016 not 2016-08-27T11:40:07.551Z any help would be appreciated thanks
Capture.JPG

Zenofmud

unread,
Aug 29, 2016, 7:55:18 AM8/29/16
to node...@googlegroups.com
Dave just did an update of node-red-node-forecastio - see the thread: Possible node-red-node-forecastio issue?!?

-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.
<Capture.JPG>

Toshi Bass

unread,
Aug 29, 2016, 8:18:43 AM8/29/16
to Node-RED
yeah saw that, didn't update yet but my post is about javascript to convert msg1.payload = new Date(e1); from full date/time to just date into a text node, I tried everything I can think off but just not getting anywhere

msg2.payload = e1; which goes to forecastio node via change node appears to work fine and perhaps even better when I update that node

 

Zenofmud

unread,
Aug 29, 2016, 9:35:13 AM8/29/16
to node...@googlegroups.com
Why not use the node-red-contrib-moment node to format the date? Using the format 
ddd, MMM Do YYYY
Gives me: Sat, Aug 27th 2016 

[{"id":"b9b77df8.46488","type":"function","z":"332bf788.ccd408","name":"","func":"msg1={};\nmsg2={};\n\nvar now = new Date();\nvar epoch = now.valueOf();\n\nif(msg.payload==1){\n    var e1 = epoch-(60*60*48*1000);\n    msg1.payload = new Date(e1);\n    msg2.payload = e1;\n}\nreturn [msg1, msg2];","outputs":"2","noerr":0,"x":398,"y":274,"wires":[["3785cbef.c87a34"],["f0067017.0ff99"]]},{"id":"be72b602.418d48","type":"inject","z":"332bf788.ccd408","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":198,"y":279,"wires":[["b9b77df8.46488"]]},{"id":"f0067017.0ff99","type":"debug","z":"332bf788.ccd408","name":"msg2","active":true,"console":"false","complete":"payload","x":602,"y":333,"wires":[]},{"id":"3785cbef.c87a34","type":"moment","z":"332bf788.ccd408","name":"","topic":"","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd, MMM Do YYYY","locale":"\"C\"","output":"","outputType":"msg","outTz":"America/New_York","x":609,"y":286,"wires":[["3b64f735.c49b08"]]},{"id":"3b64f735.c49b08","type":"debug","z":"332bf788.ccd408","name":"msg1","active":true,"console":"false","complete":"payload","x":809,"y":227,"wires":[]}]
On Aug 29, 2016, at 8:18 AM, Toshi Bass <toshib...@gmail.com> wrote:

yeah saw that, didn't update yet but my post is about javascript to convert msg1.payload = new Date(e1); from full date/time to just date into a text node, I tried everything I can think off but just not getting anywhere

msg2.payload = e1; which goes to forecastio node via change node appears to work fine and perhaps even better when I update that node

 

Dave C-J

unread,
Aug 29, 2016, 9:46:28 AM8/29/16
to node...@googlegroups.com
Hi Toshi

if you just need to inject the date into the forecast.io node then leave it as epoch time in mSec. No need to re-format it.

Dave C-J

unread,
Aug 29, 2016, 9:47:29 AM8/29/16
to node...@googlegroups.com
As per my example above...

Toshi Bass

unread,
Aug 29, 2016, 10:35:37 AM8/29/16
to Node-RED
Sorry I wasn't very clear . trying to make like a menu see attached, if I choose today + 2 then forcast io shows correct weather for 31st Aug 2016 problem I am having is with text node I want just the relative date in there preferably in the format 31 Aug 2018, not date/time  the date its self calculates correct as does the output to forecastio node.

 

Capture1.JPG
Capture.JPG

Toshi Bass

unread,
Aug 29, 2016, 10:40:17 AM8/29/16
to Node-RED
Oh sorry paul I didn't see your post I will dowenload node-moment and check your solution


Toshi Bass

unread,
Aug 29, 2016, 10:50:44 AM8/29/16
to Node-RED

OK that solution works fine thanks Paul

Toshi Bass

unread,
Aug 29, 2016, 11:32:38 AM8/29/16
to Node-RED
oh now I updated forcast_io to "version": "0.1.9", and now the below format doesn't appear to work anymore ... it just returns "time": "2016-08-29T23:00:00.000Z",  for any input


inject Timestamp node

Function node

msg.time = msg.payload + (60*60*72*1000);
return msg;

Paul Reed

unread,
Aug 29, 2016, 12:09:01 PM8/29/16
to Node-RED
Stopped working for me too since the update to v0.1.9.
Also, if the forecast is set to 'Specify time & date' the 'Time' input box is too small & cannot be expanded.


Dave C-J

unread,
Aug 29, 2016, 6:46:53 PM8/29/16
to node...@googlegroups.com

Oops.. I'll take another look.

Dave C-J

unread,
Aug 30, 2016, 11:16:30 AM8/30/16
to Node-RED
Paul, Toshi,

ok have pushed version 0.1.10 - the function you had now works...
(for some reason it was only accepting that epoch number as a string... - now accepts number as it ought as well.  

Toshi Bass

unread,
Aug 30, 2016, 3:11:01 PM8/30/16
to Node-RED
Dave

I installed 0.1.10 rebooted pi but still have problems:

first issue node is not returning all the expected data .. (in 0.1.9 and previous it was returning all)

 { "weather": "clear-night", "detail": "Clear", "humidity": 0.75, "windspeed": 1.42, "winddirection": 13, "lat": 35.9375, "lon": 14.3754, "clouds": 0.07, "precipitation": 0, "units": "us" }

 So missing maxtemp, mintemp,sunrise,sunset

second issue data is the same for different days  see attached and here is test flow 


 [{"id":"c47842c2.9623","type":"forecastio","z":"e324760.b29cc88","forecastio":"","name":"","lon":"3.1883","lat":"55.9533","date":"","time":"","mode":"message","units":"auto","x":710,"y":3220,"wires":[["1d6457b2.450088","e15ec668.c30038"]]},{"id":"1d6457b2.450088","type":"function","z":"e324760.b29cc88","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.tempc+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":917,"y":3220,"wires":[[]]},{"id":"93dbac8d.4fa5f","type":"inject","z":"e324760.b29cc88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":102,"y":3073,"wires":[["f75d5d60.e124c","fd5d8677.947bd8","1baa1fc7.54d47","d5142a1b.b87538","803ff86b.fb7448"]]},{"id":"8c6a3616.d2acf8","type":"function","z":"e324760.b29cc88","name":"+ (60*60*72*1000);","func":"msg.time = msg.payload + (60*60*72*1000);\n    node.status({text:msg.payload+\" : \"+msg.time});\nreturn msg;\n","outputs":1,"noerr":0,"x":482,"y":3219,"wires":[["c47842c2.9623"]]},{"id":"533a672c.063978","type":"forecastio","z":"e324760.b29cc88","forecastio":"","name":"","lon":"3.1883","lat":"55.9533","date":"","time":"","mode":"message","units":"auto","x":702,"y":3119,"wires":[["8d12a579.328238","e15ec668.c30038"]]},{"id":"8d12a579.328238","type":"function","z":"e324760.b29cc88","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.tempc+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":911,"y":3119,"wires":[[]]},{"id":"14dc3ca9.b42e83","type":"function","z":"e324760.b29cc88","name":"- (60*60*72*1000);","func":"msg.time = msg.payload - (60*60*72*1000);\n    node.status({text:msg.payload+\" : \"+msg.time});\nreturn msg;\n","outputs":1,"noerr":0,"x":478,"y":3119,"wires":[["533a672c.063978"]]},{"id":"f75d5d60.e124c","type":"delay","z":"e324760.b29cc88","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":281,"y":3219,"wires":[["8c6a3616.d2acf8"]]},{"id":"3a9b447.92e7fbc","type":"forecastio","z":"e324760.b29cc88","forecastio":"","name":"","lon":"3.1883","lat":"55.9533","date":"","time":"","mode":"message","units":"auto","x":704,"y":3171,"wires":[["6492e2a.3dcc51c","e15ec668.c30038"]]},{"id":"6492e2a.3dcc51c","type":"function","z":"e324760.b29cc88","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.tempc+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":914,"y":3171,"wires":[[]]},{"id":"bdcb5c7b.c4d8c","type":"function","z":"e324760.b29cc88","name":"time stamp","func":"msg.time = msg.payload \n    node.status({text:msg.payload+\" : \"+msg.time});\nreturn msg;\n","outputs":1,"noerr":0,"x":459,"y":3170,"wires":[["3a9b447.92e7fbc"]]},{"id":"fd5d8677.947bd8","type":"delay","z":"e324760.b29cc88","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":278,"y":3170,"wires":[["bdcb5c7b.c4d8c"]]},{"id":"410933ff.1be31c","type":"forecastio","z":"e324760.b29cc88","forecastio":"","name":"","lon":"3.1883","lat":"55.9533","date":"","time":"","mode":"message","units":"auto","x":709,"y":3273,"wires":[["3485ae12.e270d2","e15ec668.c30038"]]},{"id":"3485ae12.e270d2","type":"function","z":"e324760.b29cc88","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.tempc+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":919,"y":3273,"wires":[[]]},{"id":"352ace73.7f0bb2","type":"function","z":"e324760.b29cc88","name":"+ (60*60*144*1000);","func":"msg.time = msg.payload + (60*60*144*1000);\n    node.status({text:msg.payload+\" : \"+msg.time});\nreturn msg;\n","outputs":1,"noerr":0,"x":494,"y":3272,"wires":[["410933ff.1be31c"]]},{"id":"1baa1fc7.54d47","type":"delay","z":"e324760.b29cc88","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":283,"y":3272,"wires":[["352ace73.7f0bb2"]]},{"id":"d5142a1b.b87538","type":"delay","z":"e324760.b29cc88","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":283,"y":3120,"wires":[["14dc3ca9.b42e83"]]},{"id":"244e4f0c.a4016","type":"forecastio","z":"e324760.b29cc88","forecastio":"","name":"","lon":"3.1883","lat":"55.9533","date":"","time":"","mode":"message","units":"auto","x":701,"y":3074,"wires":[["9d18daa0.e8d818","e15ec668.c30038"]]},{"id":"9d18daa0.e8d818","type":"function","z":"e324760.b29cc88","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.tempc+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":909,"y":3074,"wires":[[]]},{"id":"803ff86b.fb7448","type":"function","z":"e324760.b29cc88","name":"- (60*60*144*1000);","func":"msg.time = msg.payload - (60*60*144*1000);\n    node.status({text:msg.payload+\" : \"+msg.time});\nreturn msg;\n","outputs":1,"noerr":0,"x":485,"y":3074,"wires":[["244e4f0c.a4016"]]},{"id":"e15ec668.c30038","type":"debug","z":"e324760.b29cc88","name":"","active":true,"console":"false","complete":"false","x":908,"y":3327,"wires":[]}]
Capture.JPG
Capture1.JPG
Capture2.JPG

Paul Reed

unread,
Aug 30, 2016, 3:15:18 PM8/30/16
to Node-RED
I was just in the process of posting the same issues, but you beat me to it.
Just compared it with what is returned via a browser api call, which is complete, whilst a lot of the data is missing using the node.

Paul


Paul Reed

unread,
Aug 30, 2016, 4:06:26 PM8/30/16
to Node-RED
To highlight the issues, I've made a browser api request, and compared it with the node output, using the same epoch and location etc.

The forecastio git code shows what should be returned;
                        msg.data = jsun;
                        msg.payload.weather = jsun.daily.data[when].icon;
                        msg.payload.detail = jsun.daily.data[when].summary;
                        msg.payload.humidity = jsun.daily.data[when].humidity;
                        msg.payload.maxtemp = jsun.daily.data[when].temperatureMax;
                        msg.payload.mintemp = jsun.daily.data[when].temperatureMin;
                        msg.payload.windspeed = jsun.daily.data[when].windSpeed;
                        msg.payload.winddirection = jsun.daily.data[when].windBearing;
                        msg.payload.lat = jsun.latitude;
                        msg.payload.lon = jsun.longitude;
                        msg.payload.clouds = jsun.daily.data[when].cloudCover;
                        msg.payload.precipitation = jsun.daily.data[when].precipProbability;
                        msg.payload.sunrise = jsun.daily.data[when].sunriseTime;
                        msg.payload.sunset = jsun.daily.data[when].sunsetTime;
                        msg.payload.units = jsun.flags.units;
                        msg.location.lat = jsun.latitude;
                        msg.location.lon = jsun.longitude;
                        msg.time = new Date(jsun.daily.data[when].time*1000);
                        msg.title = RED._("forecastio.message.weather-forecast");
                        msg.description = RED._("forecastio.message.weather-info", {time: msg.time.toLocaleString(), lat: msg.location.lat, lon: msg.location.lon});
                        callback();

The browser api call returns;
"daily":{"data":[{"time":1472770800,"summary":"Light rain until afternoon.","icon":"rain","sunriseTime":1472793430,"sunsetTime":1472842408,"moonPhase":0.04,"precipIntensity":0.003,"precipIntensityMax":0.0114,"precipIntensityMaxTime":1472806800,"precipProbability":0.44,"precipType":"rain","temperatureMin":54.73,"temperatureMinTime":1472785200,"temperatureMax":68.9,"temperatureMaxTime":1472821200,"apparentTemperatureMin":54.73,"apparentTemperatureMinTime":1472785200,"apparentTemperatureMax":68.9,"apparentTemperatureMaxTime":1472821200,"dewPoint":55.75,"humidity":0.83,"windSpeed":9.94,"windBearing":221,"visibility":10,"cloudCover":0.67,"pressure":1016.39,"ozone":291.53}]},"flags":{"sources":["datapoint","gfs","cmc","fnmoc","isd","metwarn"],"datapoint-stations":["uk-310059","uk-350145","uk-350272","uk-350389","uk-350404","uk-350997","uk-351223","uk-351224","uk-351345","uk-351782","uk-352140","uk-352504","uk-352845","uk-353223","uk-353909","uk-354090"],"isd-stations":["033460-99999","033550-99999","033600-99999","033730-99999","749008-99999"],"units":"us"}}

The forecastio node returned data;
{"weather":"clear-night","detail":"Clear","humidity":0.66,"windspeed":7.65,"winddirection":213,"lat":53.472931,"lon":-1.054628,"clouds":0.02,"precipitation":0,"units":"us"}

You can see what data is missing, but also that it is not the same. Take humidity for an example - the browser api request returns 0.83, whilst the node returns 0.66.

Paul

Paul Reed

unread,
Sep 1, 2016, 3:27:35 PM9/1/16
to Node-RED
For info, dceejay has kindly released v0.1.11 on npm with a number of bug fixes.
Just tried it, and it works great!

Paul

Toshi Bass

unread,
Sep 2, 2016, 2:40:45 PM9/2/16
to Node-RED
Tried it this afternoon works perfectly thanks Dave

For anyone who's interested here's my flow..... would be interested if anyone can make / propose improvements

[{"id":"614a4569.905a4c","type":"forecastio","z":"dfb58c30.3681e","forecastio":"","name":"","lon":"14.5146","lat":"35.8989","date":"","time":"","mode":"message","units":"uk2","x":493.00000381469727,"y":510.99975967407227,"wires":[["75b98975.b84198","54d2e644.9f3018","99d5fcfe.a5986","28450f0.280def2","394015dc.cb783a","db8515ac.da0cf8","db4380c7.28408","8e1e0063.ebf9d","8342904d.fc56","3fdb1f8b.99fb2","32cab2e1.cb812e","e476caaf.5465e8","30a3a887.03a2a8","61bbc4b5.75d91c"]]},{"id":"75b98975.b84198","type":"function","z":"dfb58c30.3681e","name":"Costruct data","func":"msg.payload = msg.payload.winddirection+\",\"+\nmsg.payload.windspeed+\",\"+\nmsg.payload.clouds+\",\"+\nmsg.payload.detail+\",\"+\nmsg.payload.mintemp+\",\"+\nmsg.payload.maxtemp+\",\"+\nmsg.payload.humidity+\",\"+\nmsg.payload.sunrise+\",\"+\nmsg.payload.sunset;\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":744.083324432373,"y":247.08334159851074,"wires":[[]]},{"id":"db8515ac.da0cf8","type":"function","z":"dfb58c30.3681e","name":"sunset","func":"var sec = msg.payload.sunset;\nvar date = new Date(sec * 1000);\nmsg.payload = date.toLocaleTimeString();\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":706.5158462524414,"y":809.5792589187622,"wires":[["1b9aede5.500672"]]},{"id":"28450f0.280def2","type":"function","z":"dfb58c30.3681e","name":"windspeed","func":"msg.payload = msg.payload.windspeed.toFixed(1);\nmsg.payload = (msg.payload+\" mph\")\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":730.4166374206543,"y":533.1110639572144,"wires":[["7340b33d.0b3dcc"]]},{"id":"394015dc.cb783a","type":"function","z":"dfb58c30.3681e","name":"sunrise","func":"\nvar s = msg.payload.sunrise;\nvar dates = new Date(s * 1000);\nmsg.payload = (dates.toLocaleTimeString());\n    node.status({text:msg.payload});\nreturn msg;\n","outputs":1,"noerr":0,"x":717.6269454956055,"y":765.0237798690796,"wires":[["6852ed13.b40c94"]]},{"id":"54d2e644.9f3018","type":"function","z":"dfb58c30.3681e","name":"maxtemp","func":"msg.topic = \"maxtemp\";\nmsg.payload = (msg.payload.maxtemp).toFixed(1);\nmsg.payload = (msg.payload+\"°C\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":721.3054351806641,"y":440.33326148986816,"wires":[["ce13096d.e56648"]]},{"id":"99d5fcfe.a5986","type":"function","z":"dfb58c30.3681e","name":"mintemp","func":"msg.payload = (msg.payload.mintemp).toFixed(1);\nmsg.payload = (msg.payload+\"°C\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":718.3054351806641,"y":488.33326148986816,"wires":[["72e4c4e1.2fad4c"]]},{"id":"db4380c7.28408","type":"function","z":"dfb58c30.3681e","name":"clouds","func":"msg.payload = (msg.payload.clouds);\nmsg.payload = (msg.payload+\" %\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":711.488151550293,"y":670.9125423431396,"wires":[["3d1bfb6b.a4dad4"]]},{"id":"8e1e0063.ebf9d","type":"function","z":"dfb58c30.3681e","name":"detail","func":"msg.payload = (msg.payload.detail);\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":713.4166412353516,"y":345.0277462005615,"wires":[["a8ec065c.461d88"]]},{"id":"8342904d.fc56","type":"function","z":"dfb58c30.3681e","name":"humidity","func":"msg.payload = (msg.payload.humidity*100).toFixed(0);\nmsg.payload = (msg.payload+\" %\");\n//msg.payload = (msg.payload+\" out\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":723.7777214050293,"y":393.0832004547119,"wires":[[]]},{"id":"3fdb1f8b.99fb2","type":"function","z":"dfb58c30.3681e","name":"winddirection","func":"msg.payload = msg.payload.winddirection;\nmsg.payload = (msg.payload+\"°\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":730.6388664245605,"y":579.9999399185181,"wires":[["562bdf97.ceead"]]},{"id":"e476caaf.5465e8","type":"function","z":"dfb58c30.3681e","name":"precipitation","func":"msg.payload = (msg.payload.precipitation);\nmsg.payload = (msg.payload+\" inch\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":726.9880332946777,"y":717.7460689544678,"wires":[["c8a27a04.82d6c8"]]},{"id":"32cab2e1.cb812e","type":"function","z":"dfb58c30.3681e","name":"weather icon","func":"msg.payload = (msg.payload.weather);\n    node.status({text:msg.payload});\nif(msg.payload==\"clear-day\"){\n    msg.payload=\"clear\";\n    return msg;\n}\nif(msg.payload==\"clear-night\"){\n    msg.payload=\"/nt clear\";\n    return msg;\n}\nif(msg.payload==\"partly-cloudy-day\"){\n   msg.payload=\"partlycloudy\";\n   return msg;\n}    \nif(msg.payload==\"partly-cloudy-night\"){\n   msg.payload=\"/nt partlycloudy\";\n   return msg;\n}\n\nreturn msg;\n//other possable icons from forcast_io \n//that do not need translation\n\n//rain\n//snow\n//sleet\n//wind\n//fog\n//cloudy ","outputs":1,"noerr":0,"x":732.8888854980469,"y":295.666579246521,"wires":[["5b29dd4d.89b664"]]},{"id":"562bdf97.ceead","type":"ui_gauge","z":"dfb58c30.3681e","name":"","group":"327fa404.8c4b0c","order":1,"width":"3","height":"3","gtype":"compass","title":"wind direction","label":"deg","format":"{{value}}","min":0,"max":"360","x":987.2897033691406,"y":579.4999551773071,"wires":[]},{"id":"ce13096d.e56648","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":12,"width":"2","height":"1","name":"","label":"max_temp","format":"{{msg.payload}}","layout":"col-center","x":1007.5037841796875,"y":440.5714502334595,"wires":[]},{"id":"72e4c4e1.2fad4c","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":11,"width":"2","height":"1","name":"","label":"min_temp","format":"{{msg.payload}}","layout":"col-center","x":998.0754241943359,"y":488.7144808769226,"wires":[]},{"id":"79df4867.af6668","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":10,"width":"2","height":"1","name":"","label":"temp_now","format":"{{msg.payload}}","layout":"col-center","x":1004.9564208984375,"y":1312.9165859222412,"wires":[]},{"id":"6852ed13.b40c94","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":8,"width":"2","height":"1","name":"","label":"sunrise","format":"{{msg.payload}}","layout":"col-center","x":991.1110877990723,"y":765.3572111129761,"wires":[]},{"id":"1b9aede5.500672","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":9,"width":"2","height":"1","name":"","label":"sunset","format":"{{msg.payload}}","layout":"col-center","x":982.1110725402832,"y":808.9286489486694,"wires":[]},{"id":"981573ca.92f95","type":"function","z":"dfb58c30.3681e","name":"time now","func":"msg.topic = \"time\";\nmsg.payload = context.global.times;\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":725.1587753295898,"y":189.71420574188232,"wires":[["851d4ab.50974b8"]]},{"id":"851d4ab.50974b8","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":7,"width":"2","height":"1","name":"","label":"time now","format":"{{msg.payload}}","layout":"col-center","x":998.230224609375,"y":189.85727882385254,"wires":[]},{"id":"e3552720.5a6ec8","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"x":136.58734566824774,"y":190.42860480717218,"wires":[["981573ca.92f95"]]},{"id":"a8ec065c.461d88","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":5,"width":"5","height":"1","name":" detail","label":"","format":"{{msg.payload}}","layout":"row-left","x":986.3253517150879,"y":344.54766845703125,"wires":[]},{"id":"c8a27a04.82d6c8","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":14,"width":"2","height":"1","name":"","label":"precipitation","format":"{{msg.payload}}","layout":"col-center","x":999.2182350158691,"y":717.4286756515503,"wires":[]},{"id":"7340b33d.0b3dcc","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":13,"width":"2","height":"1","name":"","label":"windspeed","format":"{{msg.payload}}","layout":"col-center","x":1005.8610687255859,"y":532.9999866485596,"wires":[]},{"id":"3d1bfb6b.a4dad4","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":15,"width":"2","height":"1","name":"","label":"clouds","format":"{{msg.payload}}","layout":"col-center","x":982.1825523376465,"y":672.3571577072144,"wires":[]},{"id":"85fffe67.377bf","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":3,"width":"3","height":"1","name":"Date","label":" ","format":"{{msg.payload}}","layout":"row-center","x":472.50000381469727,"y":471.7500190734863,"wires":[]},{"id":"2b6b3410.ed0dbc","type":"ui_dropdown","z":"dfb58c30.3681e","name":"","label":"","group":"327fa404.8c4b0c","order":2,"width":"3","height":"1","options":[{"label":"today - 2","value":"1"},{"label":"today - 1","value":"2"},{"label":"today","value":"3"},{"label":"today + 1","value":"4"},{"label":"today + 2","value":"5"},{"label":"today + 3","value":"6"},{"label":"today + 4","value":"7"},{"label":"today + 5","value":"8"}],"payload":"","topic":"","x":105.03572082519531,"y":408.392861366272,"wires":[["9962974f.da6ef8"]]},{"id":"39767602.f7991a","type":"change","z":"dfb58c30.3681e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":284.50000381469727,"y":511.00000381469727,"wires":[["614a4569.905a4c"]]},{"id":"9962974f.da6ef8","type":"function","z":"dfb58c30.3681e","name":"","func":"msg1={};\nmsg2={};\n\nvar now = new Date();\nvar epoch = now.valueOf();\n\nif(msg.payload==1){\n    var e1 = epoch-(60*60*48*1000);\n    msg1.payload = new Date(e1);\n    msg2.payload = e1;\n}\nif(msg.payload==2){\n    var e2 = epoch-(60*60*24*1000); \n    msg1.payload = new Date(e2);    \n    msg2.payload = e2;\n}\nif(msg.payload==3){\n    var e3 = epoch;\n    msg1.payload = new Date(e3);      \n    msg2.payload = e3;\n}\nif(msg.payload==4){\n    var e4 = epoch+(60*60*24*1000);    \n    msg1.payload = new Date(e4);    \n    msg2.payload = e4;\n}\nif(msg.payload==5){\n    var e5 = epoch+(60*60*48*1000);    \n    msg1.payload = new Date(e5);    \n    msg2.payload = e5;\n}\nif(msg.payload==6){\n    var e6 = epoch+(60*60*72*1000);    \n    msg1.payload = new Date(e6);    \n    msg2.payload = e6;\n}\nif(msg.payload==7){\n    var e7 = epoch+(60*60*96*1000);    \n    msg1.payload = new Date(e7);    \n    msg2.payload = e7;\n}\nif(msg.payload==8){\n    var e8 = epoch+(60*60*120*1000);    \n    msg1.payload = new Date(e8);    \n    msg2.payload = e8;\n}\n\n\n\n    node.status({text:msg1.payload+\" : \"+msg2.payload});\n    \nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":111.50000381469727,"y":516.7500038146973,"wires":[["f9b6d485.361998"],["39767602.f7991a"]]},{"id":"f9b6d485.361998","type":"moment","z":"dfb58c30.3681e","name":"","topic":"","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd, MMM Do","locale":"\"C\"","output":"","outputType":"msg","outTz":"America/New_York","x":295.00000381469727,"y":472.00000381469727,"wires":[["85fffe67.377bf"]]},{"id":"30a3a887.03a2a8","type":"debug","z":"dfb58c30.3681e","name":"","active":false,"console":"true","complete":"payload","x":488.2500114440918,"y":726.7500057220459,"wires":[]},{"id":"fc45ca63.a9bf18","type":"debug","z":"dfb58c30.3681e","name":"","active":false,"console":"false","complete":"payload","x":427.0000114440918,"y":1542.2500219345093,"wires":[]},{"id":"5d86f407.00f15c","type":"function","z":"dfb58c30.3681e","name":"Costruct now data","func":"\nmsg.payload=msg.payload.currently.time+\",\"+\nmsg.payload.currently.summary+\",\"+\nmsg.payload.currently.icon+\",\"+\nmsg.payload.currently.precipIntensity+\",\"+\nmsg.payload.currently.precipProbability+\",\"+\nmsg.payload.currently.temperature+\",\"+\nmsg.payload.currently.apparentTemperature+\",\"+\nmsg.payload.currently.dewPoint+\",\"+\nmsg.payload.currently.humidity+\",\"+\nmsg.payload.currently.windSpeed+\",\"+\nmsg.payload.currently.windBearing+\",\"+\nmsg.payload.currently.visibility+\",\"+\nmsg.payload.currently.pressure+\",\"+\nmsg.payload.currently.ozone+\",\"+\nmsg.payload.minutely.summary+\",\"+\nmsg.payload.hourly.summary;\n\nnode.status({text:msg.payload});\nreturn msg;\n\n//(msg.payload.mintemp-273.15).toFixed(2)+\",\"+\n//(msg.payload.maxtemp-273.15).toFixed(2)+\",\"+","outputs":1,"noerr":0,"x":741,"y":933.6666259765625,"wires":[[]]},{"id":"b5f95750.539298","type":"change","z":"dfb58c30.3681e","name":"","rules":[{"t":"move","p":"data","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":455.5000114440918,"y":1326.750020980835,"wires":[["fc45ca63.a9bf18","5d86f407.00f15c","8e488b3f.5c8048","c3dfde35.9e11e","59dbaebf.2be44","ddefcb0e.fcc988","f705ef9b.0fe24","6291318e.9675e","e951a88.797d158","a77db184.4b42d","a84de07b.89213","ea2e8d20.3735e","2becc3d0.3a9e9c","11bd4b27.e46c45","d87e77c.41e7888","f6cfe013.94417","52b69ba.c8ffa64","96873093.014d9","40b87f70.a0097"]]},{"id":"5a855f3e.41e7c","type":"forecastio","z":"dfb58c30.3681e","forecastio":"","name":"","lon":"14.5146","lat":"35.8989","date":"","time":"","mode":"message","units":"uk2","x":288.2500190734863,"y":1326.000020980835,"wires":[["b5f95750.539298"]]},{"id":"4316af6b.f6231","type":"inject","z":"dfb58c30.3681e","name":"each 30min","topic":"","payload":"","payloadType":"str","repeat":"1800","crontab":"","once":true,"x":126.5,"y":1326.5,"wires":[["5a855f3e.41e7c"]]},{"id":"9e43757d.1b4408","type":"function","z":"dfb58c30.3681e","name":"Global date / time","func":"var d = new Date();\n  date = d.toDateString();\n  h = d.getHours();\n  m = d.getMinutes();\n  s = d.getSeconds();\n  if (h<10){h=\"0\"+h}\n  if (m<10){m=\"0\"+m}\n  if (s<10){s=\"0\"+s}\ncontext.global.h=h;\ncontext.global.m=m;\ncontext.global.s=s;\ncontext.global.date = date; \ncontext.global.time  = (context.global.h+\":\"+context.global.m);\ncontext.global.times = (context.global.h+\":\"+context.global.m+\":\"+context.global.s);  \nif (s==\"00\"){\n    context.global.one_min_tick=1;\n}else{\n    context.global.one_min_tick=0;\n}\nnode.status({\n\ttext : context.global.date+\"...\"+context.global.times+\"...omt \"+context.global.one_min_tick\n});","outputs":"0","noerr":0,"x":373.7143249511719,"y":107.5000057220459,"wires":[]},{"id":"618511f7.c8c12","type":"inject","z":"dfb58c30.3681e","name":"inject each 1sec","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":true,"x":160.71432495117188,"y":107.5000057220459,"wires":[["9e43757d.1b4408"]]},{"id":"8e488b3f.5c8048","type":"function","z":"dfb58c30.3681e","name":"data time","func":"var sec = msg.payload.currently.time;\nvar date = new Date(sec * 1000);\nmsg.payload = date.toLocaleTimeString();\nmsg.payload = msg.payload+\" : \"+context.global.date\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":710.2500152587891,"y":983.5000171661377,"wires":[["908da1cf.9e752"]]},{"id":"c3dfde35.9e11e","type":"function","z":"dfb58c30.3681e","name":"current summary","func":"msg.payload = (msg.payload.currently.summary);\nmsg.payload = (msg.payload+\" \");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":738.75,"y":1030.75,"wires":[[]]},{"id":"59dbaebf.2be44","type":"function","z":"dfb58c30.3681e","name":"current precipIntensity","func":"msg.payload = (msg.payload.currently.precipIntensity);\nmsg.payload = (msg.payload+\" inch\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":747.0000152587891,"y":1227.7500171661377,"wires":[["e660fe0b.e041f"]]},{"id":"ddefcb0e.fcc988","type":"function","z":"dfb58c30.3681e","name":"current precipProbability","func":"msg.payload = (msg.payload.currently.precipProbability);\nmsg.payload = (msg.payload+\" inch\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":754.5000152587891,"y":1274.0000171661377,"wires":[["603f69fc.b2d618"]]},{"id":"f705ef9b.0fe24","type":"function","z":"dfb58c30.3681e","name":"minute summary","func":"msg.payload = (msg.payload.minutely.summary);\nmsg.payload = (msg.payload+\" \");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":734.9999923706055,"y":1081.9999866485596,"wires":[["5b4f4efb.949d1"]]},{"id":"6291318e.9675e","type":"function","z":"dfb58c30.3681e","name":"hour summary","func":"msg.payload = (msg.payload.hourly.summary);\nmsg.payload = (msg.payload+\" \");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":724.9999923706055,"y":1129.4999866485596,"wires":[[]]},{"id":"a77db184.4b42d","type":"function","z":"dfb58c30.3681e","name":"current temperature","func":"msg.payload = (msg.payload.currently.temperature).toFixed(2);\nmsg.payload = (msg.payload+\"°C\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":738.2500038146973,"y":1329.0000038146973,"wires":[["79df4867.af6668","625f79b3.e99148"]]},{"id":"e951a88.797d158","type":"function","z":"dfb58c30.3681e","name":"current apparentTemperature","func":"msg.payload = (msg.payload.currently.apparentTemperature);\nmsg.payload = (msg.payload+\"°C\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":769.5000038146973,"y":1381.5000038146973,"wires":[["ba0cc17b.7592f"]]},{"id":"a84de07b.89213","type":"function","z":"dfb58c30.3681e","name":"current dewPoint","func":"msg.payload = (msg.payload.currently.dewPoint);\nmsg.payload = (msg.payload+\" °\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":730.7500114440918,"y":1434.0000228881836,"wires":[["146ff57d.d6185b"]]},{"id":"ea2e8d20.3735e","type":"function","z":"dfb58c30.3681e","name":"current humidity","func":"msg.payload = (msg.payload.currently.humidity*100).toFixed(0);\nmsg.payload = (msg.payload+\" %\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":720.7500038146973,"y":1484.0000038146973,"wires":[["74142beb.91f8b4"]]},{"id":"2becc3d0.3a9e9c","type":"function","z":"dfb58c30.3681e","name":"current windSpeed","func":"msg.payload = (msg.payload.currently.windSpeed);\nmsg.payload = (msg.payload+\" mph\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":729.5000038146973,"y":1532.7500038146973,"wires":[[]]},{"id":"11bd4b27.e46c45","type":"function","z":"dfb58c30.3681e","name":"current windBearing","func":"msg.payload = (msg.payload.currently.windBearing);\nmsg.payload = (msg.payload+\"°\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":739.5000152587891,"y":1585.2499904632568,"wires":[[]]},{"id":"d87e77c.41e7888","type":"function","z":"dfb58c30.3681e","name":"current visibility","func":"msg.payload = (msg.payload.currently.visibility).toFixed(1);\nmsg.payload = (msg.payload+\" mile\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":716.4643135070801,"y":1678.4641771316528,"wires":[["bc729024.be6b4"]]},{"id":"f6cfe013.94417","type":"function","z":"dfb58c30.3681e","name":"current pressure","func":"msg.payload = (msg.payload.currently.pressure).toFixed(0);\nmsg.payload = (msg.payload+\" mb\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":730.2143135070801,"y":1727.2141771316528,"wires":[["b47d8657.1bb428"]]},{"id":"52b69ba.c8ffa64","type":"function","z":"dfb58c30.3681e","name":"current ozone","func":"msg.payload = (msg.payload.currently.ozone).toFixed(1);\nmsg.payload = (msg.payload+\" du\");\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":720.2143135070801,"y":1775.9641771316528,"wires":[["1754ce3f.5014f2"]]},{"id":"96873093.014d9","type":"function","z":"dfb58c30.3681e","name":"wd compass","func":"msg.payload = (msg.payload.currently.windBearing);\nif(msg.payload>=0 && msg.payload<11.25){\n    msg.payload=\"North\";\n}\nif(msg.payload>=11.25 && msg.payload<33.75){\n    msg.payload=\"NNE\";\n}\nif(msg.payload>=33.75 && msg.payload<56.25){\n    msg.payload=\"NE\";\n}\nif(msg.payload>=56.25 && msg.payload<78.75){\n    msg.payload=\"ENE\";\n}\nif(msg.payload>=78.75 && msg.payload<101.25){\n    msg.payload=\"East\";\n}\nif(msg.payload>=101.25 && msg.payload<123.75){\n    msg.payload=\"SES\";\n}\nif(msg.payload>=123.75 && msg.payload<146.25){\n    msg.payload=\"SE\";\n}\nif(msg.payload>=146.25 && msg.payload<168.75){\n    msg.payload=\"SSE\";\n}\nif(msg.payload>=168.75 && msg.payload<191.25){\n    msg.payload=\"South\";\n}\nif(msg.payload>=191.25 && msg.payload<213.75){\n    msg.payload=\"SSW\";\n}\nif(msg.payload>=213.75 && msg.payload<236.25){\n    msg.payload=\"SW\";\n}\nif(msg.payload>=236.25 && msg.payload<258.75){\n    msg.payload=\"WSW\";\n}\nif(msg.payload>=258.75 && msg.payload<281.25){\n    msg.payload=\"West\";\n}\nif(msg.payload>=281.25 && msg.payload<303.75){\n    msg.payload=\"WNW\";\n}\nif(msg.payload>=303.75 && msg.payload<326.25){\n    msg.payload=\"NW\";\n}\nif(msg.payload>=326.25 && msg.payload<348.75){\n    msg.payload=\"NNW\";\n}\nif(msg.payload>=348.75){\n    msg.payload=\"North\";\n}\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":706.2856712341309,"y":1630.4284801483154,"wires":[[]]},{"id":"61bbc4b5.75d91c","type":"function","z":"dfb58c30.3681e","name":"wd compass","func":"msg.payload = msg.payload.winddirection;\nif(msg.payload>=0 && msg.payload<11.25){\n    msg.payload=\"North\";\n}\nif(msg.payload>=11.25 && msg.payload<33.75){\n    msg.payload=\"NNE\";\n}\nif(msg.payload>=33.75 && msg.payload<56.25){\n    msg.payload=\"North East\";\n}\nif(msg.payload>=56.25 && msg.payload<78.75){\n    msg.payload=\"ENE\";\n}\nif(msg.payload>=78.75 && msg.payload<101.25){\n    msg.payload=\"East\";\n}\nif(msg.payload>=101.25 && msg.payload<123.75){\n    msg.payload=\"ESE\";\n}\nif(msg.payload>=123.75 && msg.payload<146.25){\n    msg.payload=\"South East\";\n}\nif(msg.payload>=146.25 && msg.payload<168.75){\n    msg.payload=\"SSE\";\n}\nif(msg.payload>=168.75 && msg.payload<191.25){\n    msg.payload=\"South\";\n}\nif(msg.payload>=191.25 && msg.payload<213.75){\n    msg.payload=\"SSW\";\n}\nif(msg.payload>=213.75 && msg.payload<236.25){\n    msg.payload=\"South West\";\n}\nif(msg.payload>=236.25 && msg.payload<258.75){\n    msg.payload=\"WSW\";\n}\nif(msg.payload>=258.75 && msg.payload<281.25){\n    msg.payload=\"West\";\n}\nif(msg.payload>=281.25 && msg.payload<303.75){\n    msg.payload=\"WNW\";\n}\nif(msg.payload>=303.75 && msg.payload<326.25){\n    msg.payload=\"North West\";\n}\nif(msg.payload>=326.25 && msg.payload<348.75){\n    msg.payload=\"NNW\";\n}\nif(msg.payload>=348.75){\n    msg.payload=\"North\";\n}\n    node.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":731.4285202026367,"y":624.8571739196777,"wires":[["150075e3.498ada"]]},{"id":"150075e3.498ada","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":4,"width":"3","height":"1","name":"","label":"wind direction","format":"{{msg.payload}}","layout":"col-center","x":1013,"y":625,"wires":[]},{"id":"40b87f70.a0097","type":"function","z":"dfb58c30.3681e","name":"current icon","func":"msg.payload = (msg.payload.currently.icon);\n    node.status({text:msg.payload});\n\nif(msg.payload==\"clear-day\"){\n    msg.payload=\"clear\";\n    return msg;\n}\n//wip\nif(msg.payload==\"clear-night\"){\n    msg.payload=\"/nt clear\";\n    return msg;\n}\nif(msg.payload==\"partly-cloudy-day\"){\n   msg.payload=\"partlycloudy\";\n   return msg;\n}\n//wip\nif(msg.payload==\"partly-cloudy-night\"){\n   msg.payload='/nt+\"partlycloudy\"';\n   return msg;\n}\n\nreturn msg;\n//other possable icons from forcast_io \n//that do not need translation\n\n//rain\n//snow\n//sleet\n//wind\n//fog\n//cloudy    \n","outputs":1,"noerr":0,"x":715,"y":1177,"wires":[["8ca17240.d8352"]]},{"id":"a04c8c79.71d3","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"rain","payloadType":"str","repeat":"","crontab":"","once":false,"x":1411.714241027832,"y":406.14283561706543,"wires":[["2d800f65.b5d93"]]},{"id":"5b29dd4d.89b664","type":"ui_template","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","name":"Display Image","order":6,"width":"1","height":"1","format":"\n<img alt=\"image\" src=\"http://icons.wxug.com/i/c/k/{{msg.payload}}.gif\"/>\n","storeOutMessages":false,"fwdInMessages":true,"x":1014.8571624755859,"y":296.57141876220703,"wires":[[]]},{"id":"5543bf4f.0a7e2","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"snow","payloadType":"str","repeat":"","crontab":"","once":false,"x":1411.714241027832,"y":438.14283561706543,"wires":[["2d800f65.b5d93"]]},{"id":"5fcf9c41.1bfd94","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"clear-day","payloadType":"str","repeat":"","crontab":"","once":false,"x":1421.1428146362305,"y":592.0000019073486,"wires":[["2d800f65.b5d93"]]},{"id":"8bd375c5.cce918","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"clear-night","payloadType":"str","repeat":"","crontab":"","once":false,"x":1420.1428146362305,"y":623.0000019073486,"wires":[["2d800f65.b5d93"]]},{"id":"c16d630b.a193e","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"partly-cloudy-day","payloadType":"str","repeat":"","crontab":"","once":false,"x":1440.1428146362305,"y":655.0000019073486,"wires":[["2d800f65.b5d93"]]},{"id":"b07c2ce7.75493","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"sleet","payloadType":"str","repeat":"","crontab":"","once":false,"x":1412.714241027832,"y":468.14283561706543,"wires":[["2d800f65.b5d93"]]},{"id":"e4136917.7afb38","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"wind","payloadType":"str","repeat":"","crontab":"","once":false,"x":1412.714241027832,"y":500.14283561706543,"wires":[["2d800f65.b5d93"]]},{"id":"b89ecb5f.a40cf8","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"fog","payloadType":"str","repeat":"","crontab":"","once":false,"x":1412.714241027832,"y":530.1428356170654,"wires":[["2d800f65.b5d93"]]},{"id":"dc9fc210.2846d","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"cloudy","payloadType":"str","repeat":"","crontab":"","once":false,"x":1411.714241027832,"y":561.1428356170654,"wires":[["2d800f65.b5d93"]]},{"id":"9f3f730.6a0599","type":"inject","z":"dfb58c30.3681e","name":"","topic":"","payload":"partly-cloudy-night","payloadType":"str","repeat":"","crontab":"","once":false,"x":1449.1428146362305,"y":685.0000019073486,"wires":[["2d800f65.b5d93"]]},{"id":"89e5508.04c90b","type":"link in","z":"dfb58c30.3681e","name":"","links":["2d800f65.b5d93"],"x":861,"y":320,"wires":[["5b29dd4d.89b664"]]},{"id":"2d800f65.b5d93","type":"link out","z":"dfb58c30.3681e","name":"","links":["89e5508.04c90b"],"x":1592.8570261001587,"y":545.999963760376,"wires":[]},{"id":"ba0cc17b.7592f","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":23,"width":"2","height":"1","name":"","label":"feels like","format":"{{msg.payload}}","layout":"col-center","x":994.2857246398926,"y":1381.9999446868896,"wires":[]},{"id":"5b4f4efb.949d1","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":18,"width":"5","height":"1","name":"for the hour","label":" ","format":"{{msg.payload}}","layout":"row-left","x":998.5714721679688,"y":1081.4285888671875,"wires":[]},{"id":"bc729024.be6b4","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":27,"width":"2","height":"1","name":"","label":"visability","format":"{{msg.payload}}","layout":"col-center","x":988.5714988708496,"y":1678.1429510116577,"wires":[]},{"id":"b47d8657.1bb428","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":21,"width":"2","height":"1","name":"","label":"pressure","format":"{{msg.payload}}","layout":"col-center","x":991.4285697937012,"y":1727.0000114440918,"wires":[]},{"id":"1754ce3f.5014f2","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":28,"width":"2","height":"1","name":"","label":"ozone","format":"{{msg.payload}}","layout":"col-center","x":982.857177734375,"y":1776.5714111328125,"wires":[]},{"id":"908da1cf.9e752","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":17,"width":"6","height":"1","name":"","label":"Download:","format":"{{msg.payload}}","layout":"row-spread","x":1002.8570556640625,"y":984.2856540679932,"wires":[]},{"id":"bb03fb7d.204b88","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":16,"width":"6","height":"1","name":"","label":"Additional data for today each 30min","format":"","layout":"row-spread","x":1037.1429138183594,"y":928.5714302062988,"wires":[]},{"id":"8ca17240.d8352","type":"ui_template","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","name":"Display Image","order":19,"width":"1","height":"1","format":"\n<img alt=\"image\" src=\"http://icons.wxug.com/i/c/k/{{msg.payload}}.gif\"/>\n","storeOutMessages":false,"fwdInMessages":true,"x":1007.1428909301758,"y":1177.142837524414,"wires":[[]]},{"id":"146ff57d.d6185b","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":26,"width":"2","height":"1","name":"dewpoint","label":"dewpoint","format":"{{msg.payload}}","layout":"col-center","x":985.7143058776855,"y":1433.714243888855,"wires":[]},{"id":"74142beb.91f8b4","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":22,"width":"2","height":"1","name":"","label":"humidity","format":"{{msg.payload}}","layout":"col-center","x":987.1428833007812,"y":1485.142822265625,"wires":[]},{"id":"603f69fc.b2d618","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":24,"width":"2","height":"1","name":"","label":"rain now","format":"{{msg.payload}}","layout":"col-center","x":995.7143135070801,"y":1274.2857055664062,"wires":[]},{"id":"e660fe0b.e041f","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":25,"width":"2","height":"1","name":"","label":"rain max","format":"{{msg.payload}}","layout":"col-center","x":997.1428833007812,"y":1227.9999904632568,"wires":[]},{"id":"625f79b3.e99148","type":"ui_text","z":"dfb58c30.3681e","group":"327fa404.8c4b0c","order":20,"width":"2","height":"1","name":"","label":"temperature","format":"{{msg.payload}}","layout":"col-center","x":1004,"y":1344.142822265625,"wires":[]},{"id":"327fa404.8c4b0c","type":"ui_group","z":"dfb58c30.3681e","name":"weather","tab":"b27b2f8d.12c49","order":1,"disp":true,"width":"6"},{"id":"b27b2f8d.12c49","type":"ui_tab","z":"dfb58c30.3681e","name":"weather","icon":"dashboard"}]

Paul Reed

unread,
Sep 2, 2016, 6:35:17 PM9/2/16
to Node-RED
Thanks Toshi, I've learnt a lot by looking through your flow.

A couple of minor observations;

Night weather icons
You have msg.payload='/nt+"partlycloudy"'; which doesn't produce an icon, but msg.payload="nt_partlycloudy"; works fine.

Time Format
The existing sunrise & sunset time format doesn't really fit the box very well, and would be better displayed in 24hr format, or hide the seconds, so that the 'AM' doesn't line break, and squash the box into 3 lines (I do realize why it's currently displayed 12hr format). 

Many thanks for sharing.


Toshi Bass

unread,
Sep 2, 2016, 6:58:42 PM9/2/16
to Node-RED
Oh sorry about Night weather icons forgot I didn't finish that ( you may see WIP work in progress)

Strange Time Format is in 24hr format for me so it fits nice on iPhone iPad and desktop could this problem be you location (units forcastiio is defaulting to perhaps) I am using uk units set in forcastiio node

Paul Reed

unread,
Sep 2, 2016, 7:05:53 PM9/2/16
to Node-RED
I'm using the uk units too. The other date/time formats are displayed ok, just sunrise/sunset has the problem.

Paul

Paul Reed

unread,
Sep 2, 2016, 7:16:35 PM9/2/16
to Node-RED
Could it be this line in the sunrise function node?
msg.payload = (dates.toLocaleTimeString());


Paul Reed

unread,
Sep 2, 2016, 7:29:20 PM9/2/16
to Node-RED
Yep, 
msg.payload = (dates.toLocaleTimeString('en-GB', { hour12: false }));

forces 24hrs format

Sorted!

Paul

Toshi Bass

unread,
Sep 2, 2016, 11:29:19 PM9/2/16
to Node-RED
Happy you resolved that .....found another small problem the moment node Date/Time Formatter needs to be set to Europe/London in both fields.

Julian Knight

unread,
Sep 3, 2016, 5:36:27 AM9/3/16
to Node-RED
That should be the default if the system you are running NR on has its time zone set correctly.

Paul Reed

unread,
Sep 3, 2016, 5:40:30 PM9/3/16
to Node-RED
Thanks Julian, as far as I know my timezone is set correctly;

pi@raspberrypi:~ $ sudo dpkg-reconfigure tzdata
Current default time zone: 'Europe/London'
Local time is now:      Sat Sep  3 22:22:06 BST 2016.
Universal Time is now:  Sat Sep  3 21:22:06 UTC 2016.

and locale;

pi@raspberrypi:~ $ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

Paul

Paul Reed

unread,
Sep 5, 2016, 12:31:13 PM9/5/16
to Node-RED
With a little help along the way, I've got the date to display correctly using a function node, instead of the 'moment' node, so you now have the option of using this instead, or adding the moment node and using that.

Paul

[{"id":"9590e167.4ce51","type":"function","z":"a444a9ff.e7a408","name":"","func":"msg1={};\nmsg2={};\n\nvar now = new Date();\nvar epoch = now.valueOf();\n\nif(msg.payload==1){\n    var e1 = epoch-(60*60*48*1000);\n    msg1.payload = -2;\n    msg2.payload = e1;\n}\nif(msg.payload==2){\n    var e2 = epoch-(60*60*24*1000); \n    msg1.payload = -1;    \n    msg2.payload = e2;\n}\nif(msg.payload==3){\n    var e3 = epoch;\n    msg1.payload = 0;\n    msg2.payload = e3;\n}\nif(msg.payload==4){\n    var e4 = epoch+(60*60*24*1000);    \n    msg1.payload = +1;    \n    msg2.payload = e4;\n}\nif(msg.payload==5){\n    var e5 = epoch+(60*60*48*1000);    \n//    msg1.payload = new Date(e5);  \n    msg1.payload = +2;\n    msg2.payload = e5;\n}\nif(msg.payload==6){\n    var e6 = epoch+(60*60*72*1000);    \n    msg1.payload = +3;    \n    msg2.payload = e6;\n}\nif(msg.payload==7){\n    var e7 = epoch+(60*60*96*1000);    \n    msg1.payload = +4;    \n    msg2.payload = e7;\n}\nif(msg.payload==8){\n    var e8 = epoch+(60*60*120*1000);    \n    msg1.payload = +5;    \n    msg2.payload = e8;\n}\n\n\n\n    node.status({text:msg1.payload+\" : \"+msg2.payload});\n    \nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":94.5,"y":474.24999809265137,"wires":[["aa531c9f.f9fd8"],["607ce2fb.98d5cc"]]},{"id":"aa531c9f.f9fd8","type":"function","z":"a444a9ff.e7a408","name":"Date format","func":"var qdate = parseInt(msg.payload);\n\nvar monthNames = [\n  \"Jan\", \"Feb\", \"Mar\",\n  \"Apr\", \"May\", \"June\", \"July\",\n  \"Aug\", \"Sept\", \"Oct\",\n  \"Nov\", \"Dec\"\n];\n\nvar dayNames = [\n  \"Sun\", \"Mon\", \"Tue\",\n  \"Wed\", \"Thur\", \"Fri\", \"Sat\"\n];\n\nvar datenow = new Date();\n\ndatenow.setDate(datenow.getDate()+qdate);\n\nvar day = datenow.getDay();\nvar date = datenow.getDate();\nvar monthIndex = datenow.getMonth();\nvar year = datenow.getFullYear();\n\nmsg.payload = (dayNames[day] + ', ' + date + ' ' + monthNames[monthIndex] + ' ' + year);\n\nreturn msg;","outputs":1,"noerr":0,"x":267,"y":430,"wires":[["afc47cc3.dab22"]]}]

Julian Knight

unread,
Sep 6, 2016, 3:42:17 AM9/6/16
to Node-RED
Not sure why you need a function to get the right date format?

[{"id":"d30ae8a2.ec506","type":"moment","z":"462586cc.55d938","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd D MMM YYYY","locale":"en_GB","output":"","outputType":"msg","outTz":"Europe/London","x":477.36668395996094,"y":2361.933334350586,"wires":[["c1c7a591.8cc1d"]]},{"id":"45aea17c.08f58","type":"inject","z":"462586cc.55d938","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":190.86668395996094,"y":2354.2833099365234,"wires":[["d30ae8a2.ec506"]]},{"id":"c1c7a591.8cc1d","type":"debug","z":"462586cc.55d938","name":"","active":true,"console":"false","complete":"false","x":689.8666839599609,"y":2366.6000213623047,"wires":[]}]

The only thing I can think of for the timezone issue would be if you had an older version of moment installed or a different tz that moment has misinterpreted. Might be worth adding a new moment node to see if that works as expected.

Also note that if you want an epoch value, moment is more than happy to oblige. Just use "X" as the output format if you want the epoch in seconds (the UNIX default) or "x" if you want milliseconds.

To get "Sat Aug 27 2016" from moment, the output format is "ddd MMM D YYYY"

Paul Reed

unread,
Sep 6, 2016, 4:05:09 AM9/6/16
to Node-RED
Not sure why you need a function to get the right date format?

As an alternative to using the 'moment' node. Users may not wish to install an additional node which is only being used on one occasion just to format one date, and maybe not used anywhere else. By using the function node instead of moment, means that Toshi's flow can be imported and used with just the forecastio node being added.

The only thing I can think of for the timezone issue would be if you had an older version of moment installed or a different tz that moment has misinterpreted. Might be worth adding a new moment node to see if that works as expected.

The format issue was nothing to do with 'moment', it was occurring in the timestamp produced from a function node (sunrise & sunset) which contained;
msg.payload = (dates.toLocaleTimeString); which did not include the option { hour12: false }
The default setting for toLocaleTimeString is locale dependent, however in my case it was wrongly formatted for some reason, despite my Timezone & Locale being correct (as above post shows).

Paul

Julian Knight

unread,
Sep 6, 2016, 4:49:49 AM9/6/16
to Node-RED
Ah, OK. For some reason I was feeling defensive! ;-)

I'll butt out then now that I know that moment is fine.

Toshi Bass

unread,
Sep 12, 2016, 6:27:33 AM9/12/16
to Node-RED
To get the Date, there is a alternative to using a function node or node-red-contrib-moment (which works great by the way :-) using Angular filters : 
In the text node, value format field   {{msg.payload | date:"EEE - dd'th' MMM"}}

Dave C-J

unread,
Sep 12, 2016, 6:33:43 AM9/12/16
to node...@googlegroups.com

Nice

Julian Knight

unread,
Sep 12, 2016, 8:31:57 AM9/12/16
to Node-RED

Paul Reed

unread,
Sep 12, 2016, 12:50:37 PM9/12/16
to Node-RED

Doh!

Mike Bell

unread,
Sep 12, 2016, 1:03:01 PM9/12/16
to Node-RED
Two, possibly obvious, points here. First, this works only if the msg.payload contains something that can be parsed as a valid date, e.g. a timestamp from an inject node. Second, this will work in the label field as well as the value format field of the text node. This last is hinted at somewhere in the documentation but not clearly enough to keep me from discovering it more or less by accident.


On Monday, September 12, 2016 at 12:50:37 PM UTC-4, Paul Reed wrote:

Doh!
Reply all
Reply to author
Forward
0 new messages