Check every device data point for specific value

workflow
#1

Hi,

I would like to build a workflow which examines the state-history for a particular device, for occurrences of a specific value in the device’s state over a long period of time.

This is working somewhat using a timeseries query, but I’m unable to get every single datapoint for a long span. I’m restricted to either high-frequency, short-term or lower-frequency, longer-term aggregations.

Is there a way I can search every single device data-point for a particular value?

#2

Hi Alexander!

I would recommend checking out the Losant API Node as it may have more advanced capabilities that could be useful. Two actions that may be useful are Data: Time Series Query and Device: Get State, you will then be able to use a Loop to query through each data point on the payload and find the value you are looking for.

Let me know how else I can help!
Julia

1 Like
#3

Thank you. I will try the Losant API.

I do have a follow-up question: is querying the Losant API the best way to approach this, or should we use a different mechanism entirely?

Background:
We have a device uploading measurements. Our system requires the notion of ‘start test’ and ‘stop test’. Right now, the start/stop test values appear as a field in our device state, so my plan was to search through the complete device history to detect instances of test-start/test-stop.

However, I foresee that this might cause performance issues when our device history gets big enough (large database queries).

A couple of alternatives I thought of:

  1. Use a workflow to detect test-start/test-stop on incoming device-state, rather than querying history. But where do we store the result? A data-table? Something else?
  2. Use a webhook to inform our system of test-start/test-stop. Same question: where do we store the result?

Ultimately, we want a page where we can view a list of tests run by a particular device, where a ‘test’ is defined as the set of measurements taken in between a test-start and test-stop.

So we can identify the set of tests at the time of page-view, which requires a large database query, or we can count incoming tests as they occur, but then I’m not sure where to store the tests which are identified.

In terms of timing, each test may last anywhere from a few hours to a few weeks.

#4

Hey Alexander,

The concept of discrete “tests” or defined subsets of data within a device’s data stream is not something we’ve got great out-of-the-box support for. We’re seeing more and more use-cases and we do have a “data annotations” concept we’ve been brainstorming that would definitely help.

For now though, I might checkout our new Notebooks functionality. I like your idea of recording state for when a test starts and ends. You can then use a Notebook to carve out the data between those two state messages (much easier that trying to use a Workflow to do the same work). The notebook can then record a CSV file of the single test result which you can then put into a Data Table. I would probably recommend a single data table for all tests with a column for “test_id” so you can query individual tests from the larger table.

1 Like
#5

Hi Brandon,

It’s not quite clear to me how to do this. Is it possible to be a bit more specific with a description of the flow? What is being done in the workflow/data table/notebook? Ideally we’d like this report generation to happen when the ‘stop test’ is generated but it’s OK if it happens by way of a user pressing a button in our experience page. By the way, the user is creating the ‘stop test’ data by way of an Android app. Is it possible the Android app could use your API to do this to bypass some of this complexity?

#6

@Alexander_Farley,

I think I can add some background to what Brandon means.

The nice thing about Notebooks is that you can request all the data you have within Losant. So, you can perform the analysis against all the data you need. A notebook is a Jupyter Notebook that can use device state data, data tables and third-party sources to generate advanced insights for your application.

Essentially, you can write a Jupyter notebook that “examines the state-history for a particular device,” and execute in Losant whenever you’d like.

Additional resources to help:


When you register your “stop event,” you can trigger a Notebook to execute.

The beautiful thing about experiences is that you can set up your API ( or Experience Endpoint + Experience Workflow) to do so :slight_smile:

#7

Hi

I personally would approach this by having the workflow detect these occurrences (as you outlined) and write this information (date/time, device id etc) into a data table. Then you can perform additional queries etc as required using custom charts/notebooks export etc as required.

T

1 Like
#8

Thank you for the assistance, everyone. I have been able to use a Notebook to search for the start/end exactly as described.

1 Like