I need to access, when a data enter the Payload Parser, the data who was sent just before. It is for something akin to a derivation and I need 2 data for the calcul. Do you have an idea how to do that? Is there another solution?
Here is more detail on my situation:
I have rain gauge data who enter through one of my device. The rain gauge is a really basic model. It has a small container and each time the container is filled with water, the container is emptied and a pulse is send. I ultimatly receive the pulse in Tago. I am currently using the Payload Parser and my data take this form:
I want to change the way my data are presented and use another unit. My first version used the rain gauge pulse as the main value. (The value was a sequential) Now, I want to calcul the precipitation for my main value. For my calcul, I need to use the precedant data that was send. Is there a way to get that data in the Payload parser?
The Payload Parser in TagoIO is designed to process the raw payload from devices to extract measured variables or perform simple operations. However, it does not inherently store state or previous data entries, which means it cannot directly access the data that was sent just before the current payload.
To achieve the calculation you’re describing, where you need to access the previous data entry to calculate the precipitation, you would need to use an Analysis script instead of relying solely on the Payload Parser. An Analysis script can access the device’s bucket to retrieve previous data entries and perform more complex operations, such as the derivation you need.
Here’s a general approach to how you could implement this using an Analysis script:
Trigger the Analysis script each time new data arrives from your rain gauge device.
In the Analysis script, retrieve the last data entry for the pulse_precipitation variable from the device’s bucket.
Perform your calculation using the current and previous pulse_precipitation values to determine the precipitation.
Save the calculated precipitation value back to the device’s bucket with the appropriate unit and metadata.
Remember that using Analysis may incur additional costs, and you should refer to TagoIO’s pricing page for more information.
For more details on how to build an Analysis script, you can refer to the following resources:
I tried my hand with the analysis, but I seem to lack a documentation.
Most of the exemple use those function in the init the Analysis and it appear that the main function of the analysis contain 2 parameter who are list of dictionnary. I didn’t found the documentation who list the content of those 2 parameter.
I understand the importance of having adequate support for your analysis development. Indeed, we recommend using JavaScript for analyses on the TagoIO platform as the JavaScript SDK offers more comprehensive support compared to the Python SDK.
The documentation for the JavaScript SDK can be found at the following link: TagoIO JavaScript SDK.
Regarding your question, the analysis must be triggered by an action, and the context parameter should be structured as follows: