The Sensor Data DB Action Component is to read from the Sensor Data DB. Each recorded piece of data gets stored in the Sensor Data DB. With this component, you can query that database.
The SensorDataDB component queries data from the SensorDataDB stored in HubKit and passes each record, one row at a time, to the next component.

With the content specified in the property, search the sensor DB and execute a filter expression for each matched record. The matched records can be referenced in the “Value” variable. If the result of the expression is true, the record will be passed through and the output Payload.

Output Payload Description
cv.Payload Outputs a JSON Object for each record that matches the conditions.

Output Example

{
   "AreaId":"c753b341-c856-42fc-9170-69edaa5d8246",
   "AreaName":"Entrance Area",
   "Data":460,
   "DataId":"f969129db906491e876cef43afb4fcb8",
   "DataType":"double",
   "KindId":"7e87a819-135e-40d3-9d5f-c0330f38ec4e",
   "KindName":"Gravio-CO2",
   "LayerId":"1efe01a1-41c7-4d21-bd98-d6bc87af74bd",
   "LayerName":"CO2",
   "PhysicalDeviceId":"DE-8D-06-FE-FF-57-B5-15",
   "PhysicalDeviceName":"CO2-Sensor-1",
   "Timestamp":"2021-09-13T00:26:42.594348934Z",
   "VirtualDeviceId":"2ce70be6-257b-4854-9680-af1f02d575b4"
} 

Timestamp is output as a date/time type in the JSON Object type.
For each record, the component variable ( cv.Id ) is given a record ID, the component variable ( cv.Count ) is given the first record that matches the record, and the ID is incremented by 1, and the number of the ID is incremented in order.

Component Properties

Name Required Description
Filter Key True The property to filter for
Filter Value True The value to filter for
From Previous True The number of records to retrieve (e.g., if From Previous is 10 and the timescale is a record, the latest 10 will be retrieved).
Timescale True Unit of the latest data to be acquired (choose from records, milliseconds, seconds, minutes, hours, days, weeks, months, and years). cp.Timescale can be one of the following values: “Records”, “Milliseconds”, “Seconds”, “Minutes”, “Hours”, “Days”, “Weeks”, “Months”, or “Years”.
All Records True Get all records by overriding the From Previous and Timescale conditions.
Time Rounding True Get data from the last second, minute, hour, day, day, week, month, and year rounded up to the last time the component was executed.
Filter Expressions false Allow you to choose whether to output the payload in an expression, like the Filter component Filter Expressions. Filter Formula Example
Value.Data > 123
Value.Data.key1 == "abc" && Value.Data.key2 > 123

Example

If you like to use the data from the sensor DB in the next step, for example a Matrix Display that rotates various latest database values, you will have to access the data using cv.Payload.Data:

In this example, each SensorDataDB step reads a particular last data set of a layer, the Gravio Led Matrix shows it on the display and the Sleep step pauses the display for 15 seconds.

Need more help with this?
Join our slack community for help

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.