FTP out support? (or multiple Telnet connections?)

Hi, I need to get a file via FTP (it's a data feed from the local weather service, they don't supply it via HTTP or any other way).
I couldn't find any references on how to make an FTP connection.

I tried using the Telnet feature to write my own FTP connection, which works well to talk to the server (login and set mode) but it falls over at the part where I need to open a second Telnet connection to receive the actual file. It says 'connection refused' - I suspect the original Telnet connection is closed before attempting to open another, so the server stops listening on the newly opened port.
I wondered if I could use two separate drivers, but I'm not sure how to make them talk to each other (or if it would still close one telnet connection to open another).
Thought I'd better ask before I get too far off track!

So my questions are:
Is there an inbuilt way to download an FTP file?
If not, is there a way to open two Telnet connections at the same time?

1 Like

No FTP that I'm aware, natively supported.
My hub has several telnet connections going on concurrently, but not from the same device. If it's not supported in single device to have multiple telnet connections (though it maybe I do not know from experience), you could spawn several devices from a parent app. Each device having a separate telnet connection, and communicating with each other through the coordinator parent app.

Thanks for the reply :slight_smile: - now I know it's possible, I did get two telnet connections going by setting up a child device on the first device (didn't need an app).

Unfortunately it's not quite going to plan - I receive the file, but it comes through at about a rate of one line per couple of seconds. The file is 361kb, so it took over an hour to complete. (Running the same on my rpi gets the file instantly - so it's not an internet speed issue!)

I wonder if storing it in a state variable (and appending each line then resaving) is affecting performance - is there a better place to persist a larger amount of data?

Now that I have the file, running parseXml on it also seems to be taking an inordinately long time too (hasn't yet logged completion/error, ran it 20mins ago).
Also tried copying it to a temp variable before running parseXml, but that hasn't seemed to help either.

Update: I changed it to use a Field static StringBuilder variable, and the file now finishes downloading in a matter of seconds rather than hours. So there was definitely a performance issue with storing/resaving large string data in a state variable.

Not quite sure what was going on with parseXml, but changing it to parseXML seems to have resolved this issue.

I'll post a link to my code once I clean it up, in case anyone else wants to get an FTP file in the future.

Just in case anyone else is interested, there's a working FTP implementation in my custom weather driver (which gets Aussie weather forecast info direct from the Australian Bureau of Meteorology):


Note that it does require that Field static variable (see above, state variable was epically slow), so you can only have one device using it at a time.

1 Like

A Hubitat novice here. I have the BoM device running nicely, pulling data from the BoM. But I can't see how to add its tile to the dashboard. There is no template for the device listed in the dashboard template list.

Use the "Attribute" template, and then under the Options, select the "tile" attribute :slight_smile:

Perfect, thanks for the quick response.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.