FTP on HTTP node?

172 views
Skip to first unread message

Glenn

unread,
May 12, 2017, 11:00:18 PM5/12/17
to Node-RED
 I am trying to access a xml file that is stored on a FTP.

I can browse it fine on the web. But don't know how to get it in Node-Red

Here is the info if anyone can help

http://reg.bom.gov.au/other/Ftp.shtml

Glenn

unread,
May 12, 2017, 11:06:47 PM5/12/17
to Node-RED
So it looks like I had a typo when i used the FTP node. So I can see the files but just can't do anything with them

I just want to load the XML into a payload, but I can't seem to find a way to do it.

That's why I thought a HTTP request would be good but doesn't seem to work.

Mark Setrem

unread,
May 13, 2017, 4:33:54 AM5/13/17
to Node-RED
Try using one of the ftp nodes?
See http://flows.nodered.org/

Glenn

unread,
May 13, 2017, 5:14:31 AM5/13/17
to Node-RED
I did. It only lets you save to file i just want the xml contents to payload.

Thanks anyway

Colin Law

unread,
May 13, 2017, 5:22:39 AM5/13/17
to node...@googlegroups.com
What about node-red-contrib-ftp? I haven't used it but it appears to
have a message output rather than specifying a filename to save in.

http://flows.nodered.org/node/node-red-contrib-ftp

Colin

On 13 May 2017 at 10:14, Glenn <glo...@gmail.com> wrote:
> I did. It only lets you save to file i just want the xml contents to payload.
>
> Thanks anyway
>
> --
> 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 an email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a73f5f53-2e80-4293-98af-d0e7ff3a02c4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Glenn

unread,
May 13, 2017, 5:33:25 AM5/13/17
to Node-RED
That's the one i tried had no output on debug node

Dave C-J

unread,
May 13, 2017, 5:35:30 AM5/13/17
to node...@googlegroups.com
Not glamorous I know but you could resort to the exec and curl node...

[{"id":"257a25bd.12d73a","type":"inject","z":"e2d795ce.135098","name":"","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDD10111.xml","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":600,"wires":[["f493fd69.66214","dcefe85b.f5ac68"]]},{"id":"dcefe85b.f5ac68","type":"exec","z":"e2d795ce.135098","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":800,"y":600,"wires":[["ff21dc74.72e4"],[],[]]},{"id":"ff21dc74.72e4","type":"debug","z":"e2d795ce.135098","name":"","active":true,"console":"false","complete":"false","x":970,"y":600,"wires":[]}]

Glenn

unread,
May 13, 2017, 6:09:47 AM5/13/17
to Node-RED
Thanks. I realized i dont know how to use the xml files either so maybe best to scrap the idea or just use a file node or exec node like you suggested.

Thanks

Dave C-J

unread,
May 13, 2017, 6:44:17 AM5/13/17
to node...@googlegroups.com
Well, once you get the xml you can feed it through an XML node to parse it into a json object. That will make it easier (at least in Node-RED) to extract the bits you want from it... but without knowing what you want it's hard to suggest anything more.

Glenn

unread,
May 13, 2017, 7:25:48 AM5/13/17
to Node-RED
Well what I want is to convert it to speech. So it can be read out to me.

Eg "Currently it is 10 degrees. You can expect Partly cloudy throughout the day. With a low of 8 and a high of 16"

Looks like might have to grab two xml files.

I tried weatherzone and it didn't give enough information.

Maybe will just stick with darksky would prefer an Australian source.

Dave C-J

unread,
May 13, 2017, 7:34:10 AM5/13/17
to node...@googlegroups.com
Well... using the "say" command on my Mac I can get this

[{"id":"257a25bd.12d73a","type":"inject","z":"e2d795ce.135098","name":"","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDD10111.xml","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":780,"wires":[["dcefe85b.f5ac68"]]},{"id":"dcefe85b.f5ac68","type":"exec","z":"e2d795ce.135098","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":800,"y":780,"wires":[["36654f62.3b5f3"],[],[]]},{"id":"36654f62.3b5f3","type":"xml","z":"e2d795ce.135098","name":"","attr":"","chr":"","x":930,"y":760,"wires":[["d16ddea3.6a53c"]]},{"id":"d16ddea3.6a53c","type":"change","z":"e2d795ce.135098","name":"get the text","rules":[{"t":"move","p":"payload.product.forecast[0].area[0][\"forecast-period\"][0].text[0]._","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":820,"wires":[["ff21dc74.72e4","81f4bb7a.dd3768"]]},{"id":"ff21dc74.72e4","type":"debug","z":"e2d795ce.135098","name":"","active":true,"console":"false","complete":"false","x":1090,"y":880,"wires":[]},{"id":"81f4bb7a.dd3768","type":"exec","z":"e2d795ce.135098","command":"say","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":1130,"y":760,"wires":[[],[],[]]}]



Glenn

unread,
May 13, 2017, 7:45:44 AM5/13/17
to Node-RED
Thanks will look at your flow tomorrow.

I'm using a Echo so just need the text and Alexa will say it

Glenn

unread,
May 13, 2017, 9:23:12 PM5/13/17
to Node-RED
You have done an amazing job. We are so close.

So the file is this ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml

I need to only get
<area aac="VIC_PT042" description="Melbourne" type="location" parent-aac="VIC_PW007">


and in this one I only need
<area aac="VIC_ME001" description="Melbourne" type="metropolitan" parent-aac="VIC_FA001">

After that I can ask Alexa will it rain today. Then she can lookup probability_of_precipitation


Glenn

unread,
May 13, 2017, 11:21:00 PM5/13/17
to Node-RED
So this is what I have so far let me know if it can be improved on.

I still need to do a loop to get chance of rain min and max

[{"id":"568ee809.7e02e8","type":"inject","z":"4bf927f2.d2b45","name":"Daily Outlook","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10751.xml","payloadType":"str","repeat":"","crontab":"","once":false,"x":90,"y":120,"wires":[["30f3e93.0eff096"]]},{"id":"30f3e93.0eff096","type":"exec","z":"4bf927f2.d2b45","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","name":"","x":220,"y":120,"wires":[["a9f61cce.b767"],[],[]]},{"id":"a9f61cce.b767","type":"xml","z":"4bf927f2.d2b45","name":"","attr":"","chr":"","x":350,"y":100,"wires":[["fa04d8a9.3d4ee8"]]},{"id":"e0d1de08.a89418","type":"debug","z":"4bf927f2.d2b45","name":"","active":true,"console":"false","complete":"false","x":710,"y":100,"wires":[]},{"id":"893678f3.8d879","type":"inject","z":"4bf927f2.d2b45","name":"Additional Info","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml","payloadType":"str","repeat":"","crontab":"","once":false,"x":90,"y":220,"wires":[["f32c613e.595c5"]]},{"id":"f32c613e.595c5","type":"exec","z":"4bf927f2.d2b45","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","name":"","x":220,"y":220,"wires":[["e20c76ac.94297"],[],[]]},{"id":"e20c76ac.94297","type":"xml","z":"4bf927f2.d2b45","name":"","attr":"","chr":"","x":350,"y":200,"wires":[["461ebbed.028124"]]},{"id":"747c2703.b3eb9","type":"debug","z":"4bf927f2.d2b45","name":"","active":true,"console":"false","complete":"payload","x":710,"y":200,"wires":[]},{"id":"461ebbed.028124","type":"change","z":"4bf927f2.d2b45","name":"Get Forcast","rules":[{"t":"move","p":"payload.product.forecast[0].area[52].forecast-period","pt":"msg","to":"weather","tot":"msg"},{"t":"set","p":"payload.today","pt":"msg","to":"weather[0]","tot":"msg"},{"t":"set","p":"payload.tomorrow","pt":"msg","to":"weather[1]","tot":"msg"},{"t":"set","p":"payload.two","pt":"msg","to":"weather[2]","tot":"msg"},{"t":"set","p":"payload.three","pt":"msg","to":"weather[3]","tot":"msg"},{"t":"set","p":"payload.four","pt":"msg","to":"weather[4]","tot":"msg"},{"t":"set","p":"payload.five","pt":"msg","to":"weather[5]","tot":"msg"},{"t":"set","p":"payload.six","pt":"msg","to":"weather[6]","tot":"msg"},{"t":"move","p":"payload.product","pt":"msg","to":"product","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":200,"wires":[["747c2703.b3eb9"]]},{"id":"fa04d8a9.3d4ee8","type":"change","z":"4bf927f2.d2b45","name":"Get Forcast","rules":[{"t":"move","p":"payload.product.forecast[0].area[1].forecast-period","pt":"msg","to":"weather","tot":"msg"},{"t":"set","p":"payload.today","pt":"msg","to":"weather[0].text[0]._","tot":"msg"},{"t":"set","p":"payload.tomorrow","pt":"msg","to":"weather[1].text[0]._","tot":"msg"},{"t":"set","p":"payload.two","pt":"msg","to":"weather[2].text[0]._","tot":"msg"},{"t":"set","p":"payload.three","pt":"msg","to":"weather[3].text[0]._","tot":"msg"},{"t":"set","p":"payload.four","pt":"msg","to":"weather[4].text[0]._","tot":"msg"},{"t":"set","p":"payload.five","pt":"msg","to":"weather[5].text[0]._","tot":"msg"},{"t":"set","p":"payload.six","pt":"msg","to":"weather[6].text[0]._","tot":"msg"},{"t":"move","p":"payload.product","pt":"msg","to":"product","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":100,"wires":[["e0d1de08.a89418"]]},{"id":"7ddb3bdf.01c6dc","type":"inject","z":"4bf927f2.d2b45","name":"Currently","topic":"","payload":"http://reg.bom.gov.au/fwo/IDV60901/IDV60901.95936.json","payloadType":"str","repeat":"","crontab":"","once":false,"x":80,"y":320,"wires":[["8dc80bad.e40f8"]]},{"id":"8dc80bad.e40f8","type":"http request","z":"4bf927f2.d2b45","name":"Get Current Weather","method":"GET","ret":"obj","url":"{{{payload}}}","tls":"","x":260,"y":320,"wires":[["fe6fab88.e42f5"]]},{"id":"fe6fab88.e42f5","type":"change","z":"4bf927f2.d2b45","name":"Last Weather Report","rules":[{"t":"set","p":"payload","pt":"msg","to":"$join(['Currently, its ', $string(msg.payload.observations.data[0].air_temp),' degrees'])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["9ab0dbb7.425e8"]]},{"id":"9ab0dbb7.425e8","type":"debug","z":"4bf927f2.d2b45","name":"","active":true,"console":"false","complete":"true","x":710,"y":320,"wires":[]}]


Glenn

unread,
May 14, 2017, 5:54:30 AM5/14/17
to Node-RED
JSONata for the win!!!

It is such an amazing tool I was able to merge elements from various levels.

It's much better than the flow above. As this one does keys and no longer needs another loop or any further processing

[{"id":"893678f3.8d879","type":"inject","z":"4bf927f2.d2b45","name":"Additional Info","topic":"","payload":"ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml","payloadType":"str","repeat":"","crontab":"","once":false,"x":90,"y":220,"wires":[["f32c613e.595c5"]]},{"id":"f32c613e.595c5","type":"exec","z":"4bf927f2.d2b45","command":"curl","addpay":true,"append":"","useSpawn":"false","timer":"","name":"","x":220,"y":220,"wires":[["e20c76ac.94297"],[],[]]},{"id":"e20c76ac.94297","type":"xml","z":"4bf927f2.d2b45","name":"","attr":"","chr":"","x":350,"y":200,"wires":[["9a708b1b.96b548"]]},{"id":"747c2703.b3eb9","type":"debug","z":"4bf927f2.d2b45","name":"","active":true,"console":"false","complete":"payload","x":690,"y":200,"wires":[]},{"id":"9a708b1b.96b548","type":"change","z":"4bf927f2.d2b45","name":"Get Forcast","rules":[{"t":"move","p":"payload.product.forecast[0].area[52].forecast-period","pt":"msg","to":"weather","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{   \t\"today\":{\t        \"date\":msg.weather[0].\"$\".\"start-time-local\" ,\t        msg.weather[0].text[1].\"$\".type:product.forecast[0].area[52].\"forecast-period\"[0].text[1].\"_\"\t    },\t\"tomorrow\": {\t        \"date\": msg.weather[1].\"$\".\"start-time-local\",\t        msg.weather[1].element[1].\"$\".type: msg.weather[1].element[1].\"_\",\t        msg.weather[1].element[2].\"$\".type: msg.weather[1].element[2].\"_\" & \" degrees\",\t        msg.weather[1].element[3].\"$\".type: msg.weather[1].element[3].\"_\" & \" degrees\",\t        msg.weather[1].text[1].\"$\".type: msg.weather[1].text[1].\"_\" & \" chance of rain\"\t    },\t\"two\": {\t        \"date\": msg.weather[2].\"$\".\"start-time-local\",\t        msg.weather[2].element[1].\"$\".type: msg.weather[2].element[1].\"_\",\t        msg.weather[2].element[2].\"$\".type: msg.weather[2].element[2].\"_\" & \" degrees\",\t        msg.weather[2].element[3].\"$\".type: msg.weather[2].element[3].\"_\" & \" degrees\",\t        msg.weather[2].text[1].\"$\".type: msg.weather[2].text[1].\"_\" & \" chance of rain\"\t        },\t\"three\": {\t        \"date\": msg.weather[3].\"$\".\"start-time-local\",\t        msg.weather[3].element[1].\"$\".type: msg.weather[3].element[1].\"_\",\t        msg.weather[3].element[2].\"$\".type: msg.weather[3].element[2].\"_\" & \" degrees\",\t        msg.weather[3].element[3].\"$\".type: msg.weather[3].element[3].\"_\" & \" degrees\",\t        msg.weather[3].text[1].\"$\".type: msg.weather[3].text[1].\"_\" & \" chance of rain\"\t        },\t\"four\": {\t        \"date\": msg.weather[4].\"$\".\"start-time-local\",\t        msg.weather[4].element[1].\"$\".type: msg.weather[4].element[1].\"_\",\t        msg.weather[4].element[2].\"$\".type: msg.weather[4].element[2].\"_\" & \" degrees\",\t        msg.weather[4].element[3].\"$\".type: msg.weather[4].element[3].\"_\" & \" degrees\",\t        msg.weather[4].text[1].\"$\".type: msg.weather[4].text[1].\"_\" & \" chance of rain\"\t},\t\"five\": {\t        \"date\": msg.weather[5].\"$\".\"start-time-local\",\t        msg.weather[5].element[1].\"$\".type: msg.weather[5].element[1].\"_\",\t        msg.weather[5].element[2].\"$\".type: msg.weather[5].element[2].\"_\" & \" degrees\",\t        msg.weather[5].element[3].\"$\".type: msg.weather[5].element[3].\"_\" & \" degrees\",\t        msg.weather[5].text[1].\"$\".type: msg.weather[5].text[1].\"_\" & \" chance of rain\"\t        },\t\"six\":  {\t        \"date\": msg.weather[6].\"$\".\"start-time-local\",\t        msg.weather[6].element[1].\"$\".type: msg.weather[6].element[1].\"_\",\t        msg.weather[6].element[2].\"$\".type: msg.weather[6].element[2].\"_\" & \" degrees\",\t        msg.weather[6].element[3].\"$\".type: msg.weather[6].element[3].\"_\" & \" degrees\",\t        msg.weather[6].text[1].\"$\".type: msg.weather[6].text[1].\"_\" & \" chance of rain\"\t}\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":200,"wires":[["747c2703.b3eb9"]]}]


Reply all
Reply to author
Forward
0 new messages