Our devices are IOT fragrance machines. Each device has the ability to read an RFID tag from a fragrance cartridge, send that RFID tag info to Losant where losant checks to see if the cartridge is valid to run in that particular machine. Losant sends the device an approval or denial to run the cartridge. Losant also captures this RFID to the time series data against that device.
After a cartridge is authenticated to run in a machine the machine checks in with Losant every 15 minutes. with this checkin payload is information on how much time the cartridge has run.
Sometime cartridges will be pulled from one machine and run in another.
I need to run a report or query that will allow me to search for a cartridge RFID number across multiple devices time series data.
What is the easiest way to do this?
Thank you,
Dave
See the attached workflow. This should do the trick.
- Import this workflow into your application.
- In the Virtual Button, set the
attributeName
property to the name of the attribute where you are reporting the RFID. Also set the valueToCheck
property to an RFID you want to look for across your devices.
- The output on the payload will be an array of matching device IDs under the
matchingDeviceIds
property.
What we’re doing here is …
- In the Data: Time Series Node …
- Running a query for all devices that have an attribute matching your
attributeName
property.
- Querying a duration of 180 days (the maximum) and a resolution also of 180 days, resulting in a single data point per matching device.
- Using the Time at Value aggregation method in conjunction with the value provided in the
valueToCheck
property.
- In the Function Node …
- Iterating over all the devices returned by the Time Series Node
- For each device, check to see if it has a
value
property greater than 0
, which indicates that the device at some point - even for a millisecond - reported an RFID matching the value of valueToCheck
.
Now, this approach does have its limits; depending on your application’s data TTL and the number of devices, this could very well time out. It will certainly take several seconds to execute.
If it does time out, you’d have to take a different approach using a Jupyter Notebook.
losant-support-testing-develop.flow|attachment (3.3 KB)
Thank you very much Dylan,
I’ll give this a try as soon as I can. I’ll let you know how it goes.
thanks,