SensorDataDB

Description

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 PayloadDescription
cv.PayloadOutputs 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

NameRequiredDescription
Filter KeyTrueThe property to filter for
Filter ValueTrueThe value to filter for
From PreviousTrueThe number of records to retrieve (e.g., if From Previous is 10 and the timescale is a record, the latest 10 will be retrieved).
TimescaleTrueUnit 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 RecordsTrueGet all records by overriding the From Previous and Timescale conditions.
Time RoundingTrueGet data from the last second, minute, hour, day, week, month, and year rounded up to the last time the component was executed. When set to true, rounds down the time to the specified unit (e.g., if executed at 14:23:45, rounds down to 14:00:00 for hourly rounding).
Filter ExpressionsFalseAllow you to choose whether to output the payload in an expression, like the Filter component Filter Expressions. Filter Formula Example: Value.Data > 123 or 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.