[Solved] Querying historical data within a Workflow & Data storage

Hello,

I am unable to find any documentation on querying historical data from a device within a workflow. The only options I see for “Guage Query” are “Last received data point” and an “Aggregation” over a period of time. Even the API for “Guage Query” has the same restrictions. How can I say, retrieve the last 8 data points for a given attribute within a workflow so that I can perform my own algorithms on this data? Should I be using a different workflow block?

This leads me to my next question, which if you prefer I create a separate post for let me know! Can a single attribute store more than one key-value pair? For example, if I had an attribute called “dashboard_configuration” that held the following:

customer_name: customer1
timezone: America/New_York
email_list: email1,email2,email3
smslist: phone#1,phone#2
etc…

Is this possible? Or must I create a separate attribute for each?

Thanks,

Derek

How can I say, retrieve the last 8 data points for a given attribute within a workflow so that I can perform my own algorithms on this data?

The Time Series Node would likely be the right option for you. You can’t query based on the number of data points, but you can query based on any custom time range. You will then receive your data in an array and can perform any processing you’d like.

Can a single attribute store more than one key-value pair

A string attribute can store any arbitrary data you’d like. I might recommend using a JSON string since the workflows do have the ability to encode and decode JSON information.

At a high-level, attributes are designed to store time-series data, which is usually telemetry data that changes often. Based on your example, that configuration might make more sense to be stored in Device Tags, which are key-value pairs of custom configuration data. If tags don’t make sense, then another option is the Data Table, where each key is a column.

Brandon,

Thanks for the information/clarification!

Derek