Export device state to CSV > FTP

ftp
csv

#1

I have a requirement to query device state data and export a CSV file to an external FTP server on a periodic basis. It must be fully automated and setup to operate on a schedule.

Can anyone think of different approaches?


#2

Hi Paul,

Currently, there is not a direct way to do this with the FTP server from a workflow. Our next release will include a CSV node, so you will be able to use a timer to trigger export a CSV of state data. I would recommend using the HTTP node to send the CSV to a “middleman” that can communicate with the FTP server, since we do not have a way to do so directly.

Hopefully this helps!
Julia


#3

Thanks. Do you now when the next release is scheduled?


#4

Do you think an email attachment could be used as a middleman? There are online services available to automatically upload an email attachment to and FTP server. https://www.integromat.com/en/integration/329-automatically-upload-email-attachments-to-your-ftp-server


#5

Hi Paul!

An email attachment would be a great solution. Our built-in email node uses SendGrid under the hood, and with an account you have a lot of control on how emails are sent from the workflow.

This forum post has more information: Feature request - email attachments?

Hopefully this helps,
Julia


#6

@JuliaKempf would it be possible to generate the content of a Sendgrid attachment from within a workflow?


#7

Hi @paul_wareham,

It will be very easy to generate the SendGrid attachment content with the CSV node. The content will be stored on the payload, and you will then be able to include it as an attachment to SendGrid in an HTTP Node.

I built an example, but used a Virtual Button with a CSV formatted string.

Then I make it Base64 friendly:

Then I use an HTTP Post to SendGrid:


Then my payload will reflect this request, and an email comes through with my CSV attached.

Hopefully this helps!
Julia


#8

@JuliaKempf thanks!

Any idea the timeline if the csv node?


#9

Hi Paul,

That node is now released!

Thanks,
Julia


#10

that’s pretty wicked! Can you rework your above example based on the csv node?


#11

Hi Paul!

Below is the reworked workflow with the CSV node. The only other change (aside from the CSV node) is the addition of the Losant API node to get my device state data.


And I still receive my CSV attachment!

Thanks,
Julia


Array of Device states from API
#12

That works!

Is there an easy way to get the actual device state data from the API node into an array format so the CSV node can operate on the individual attributes instead of the top level API result array?


#13

Hi Paul,

I wrote a loop in a Function node to get to the attributes, but there are also other nodes that could have been used. Here is my Function node code:
56%20PM

And the CSV attachment that came to my inbox:

Hopefully this helps,
Julia