Sensor data aggregation
Process raw IoT sensor readings into hourly time-bucketed records with decoded calibration, fuel volume calculations, and device-level aggregation
The Sensor data aggregation transformation resamples raw sensor readings into time-bucketed summary records. Each row in processed_common_data.sensors_data_by_hours represents one sensor on one device for one bucket: the average, minimum, and maximum decoded value, and, for fuel sensors, the calibrated volume at each of those points.
The built-in transformation runs every hour and aggregates the last hour of raw sensor data from raw_telematics_data.inputs into one-hour buckets. Each run appends a fresh set of hourly records to the table.
Output table: processed_common_data.sensors_data_by_hours
Each row represents one bucket of aggregated readings for one sensor on one device. In the built-in transformation, every bucket spans one hour. The natural key is hour_bucket, device_id, sensor_name, and event_id.
hour_bucket
timestamp
Start of the time bucket the row aggregates. In the built-in transformation, always aligned to the hour boundary in UTC. In custom transformations with a different bucket size, this is the start of the bucket at the chosen granularity (for example, the start of a 5-minute window).
device_id
integer
Device identifier. To get the object label without row multiplication, join to raw_business_data.objects on device_id where is_deleted = false.
sensor_name
text
Raw input identifier from raw_telematics_data.inputs. Matches sensor_description.input_label when a sensor is configured.
event_id
integer
Event type identifier for the sensor reading.
sensor_id
integer
Sensor entity identifier from raw_business_data.sensor_description. Null if the sensor is not configured.
input_label
text
Configured input label from sensor_description. Matches sensor_name when present.
sensor_label
text
Human-readable sensor name set by the user.
sensor_type
text
Sensor type, for example fuel_level, temperature, ignition.
sensor_units
text
User-entered unit string when units_type is set to custom. Empty otherwise.
units_type
integer
Numeric code for the unit category. Resolved to a human-readable string in sensor_description_units_type.
group_type
integer
Aggregation rule code for grouped sensors: 0 for sum, 1 for average. Resolved in sensor_description_group_type.
value_avg
float
Average of the decoded sensor value across all readings in the bucket.
value_min
float
Minimum decoded value in the bucket.
value_max
float
Maximum decoded value in the bucket.
val_low_avg, val_high_avg, vol_low_avg, vol_high_avg
numeric
Calibration breakpoints used when interpolating calibrated_volume_avg. Fuel sensors only; null otherwise.
calibrated_volume_avg
numeric
Calibrated volume corresponding to value_avg, computed by linear interpolation between the breakpoints. For non-fuel sensors, this equals value_avg.
val_low_min, val_high_min, vol_low_min, vol_high_min, calibrated_volume_min
numeric
Calibration breakpoints and interpolated volume for value_min.
val_low_max, val_high_max, vol_low_max, vol_high_max, calibrated_volume_max
numeric
Calibration breakpoints and interpolated volume for value_max.
object_label
text
Object label from raw_business_data.objects. May appear multiple times for the same bucket if a device was reassigned between objects historically.
sensor_description_units_type
text
Human-readable unit category resolved from units_type.
sensor_description_group_type
text
Human-readable grouping rule resolved from group_type.
sensor_units_final
text
The unit string to display. Equals sensor_units when set, otherwise falls back to sensor_description_units_type.
value_title
text
Human-readable label for discrete sensors, looked up from parameters.value_titles using value_max as the key. Null for measuring sensors.
The examples below show common query patterns. The first returns hourly aggregates for the last 7 days. The second joins to raw_business_data.objects to include the object label without row multiplication. The third focuses on fuel sensors and uses the calibrated volume columns.
How sensor aggregates are built
A row in this table is not a raw device reading, it is a derived entity assembled from many individual sensor readings. The transformation works through the raw data in stages: deciding which readings are usable, joining sensor configuration, decoding the value, bucketing into time windows, aggregating, applying fuel calibration, and finally enriching with human-readable labels. Understanding this process helps you interpret results correctly and recognize when the default behavior needs adjusting for your use case.
Here are the steps of the algorithm that forms a sensor aggregate row:
Reading and filtering raw inputs
The transformation reads the most recent slice of data from raw_telematics_data.inputs. The slice length matches the configured interval: the built-in run reads the last hour; a custom run with a 5-minute interval reads the last 5 minutes. Readings are filtered before any further processing:
Only values matching the regular expression
^[0-9]+\.?[0-9]*$pass through. This accepts non-negative integers and decimals.Text states, negative numbers, scientific notation, and null values are excluded.
Sensors that emit only non-numeric data do not appear in the output table.
The filter operates on the raw value column in inputs, before any decoding is applied.
Joining sensor configuration
Each remaining reading is matched against raw_business_data.sensor_description using a LEFT JOIN on device_id and input_label = sensor_name. The join brings in sensor_id, sensor_label, sensor_type, units_type, group_type, divider, multiplier, calibration_data, and parameters. Because the join is left-sided, readings from unconfigured sensors still pass through with sensor metadata as null.
Decoding the raw value
Each reading is converted from its stored representation to a usable numeric value. The decoding rule comes from sensor_description.parameters.calc_method:
bit_indexextracts a single bit from the integer value using bit-shift and mask:((raw_value::bigint >> bit_index) & 1). Used for status flags packed into integers.identityuses the raw numeric value unchanged.Otherwise, the function applies
(raw_value / divider) * multiplier, which is the standard formula for measuring sensors. A null divider triggers aCOALESCEfallback to the raw value.
Bucketing and aggregating
Decoded values are grouped into time buckets by truncating device_time to the bucket boundary. Within each bucket, the function computes AVG, MIN, and MAX of the decoded value. Grouping also includes sensor metadata columns, so aggregates are calculated per sensor per device per bucket.
In the built-in transformation, the bucket is one hour. Custom transformations can use any positive interval. See Customizing the transformation below.
Calibration for fuel sensors
Sensors with a populated calibration_data array (typically fuel level sensors) get linear interpolation applied to each aggregate. For value_avg, value_min, and value_max separately, the function finds the calibration breakpoints just below and just above the value, then interpolates linearly to produce calibrated_volume_avg, calibrated_volume_min, and calibrated_volume_max. For sensors without calibration data, the calibrated volumes equal the raw aggregates.
The breakpoint columns (val_low_*, val_high_*, vol_low_*, vol_high_*) are preserved in the output for transparency.
Enrichment with labels
The aggregated rows are joined with raw_business_data.objects on device_id to add object_label, and with raw_business_data.description_parameters twice to resolve units_type and group_type into human-readable description strings. The function also computes sensor_units_final, which prefers the user-entered sensor_units and falls back to the description string.
For discrete sensors with a parameters.value_titles mapping, the function looks up the human-readable title corresponding to value_max and returns it as value_title. Measuring sensors have value_title set to null.
The following two reference sections contain the configurable interval parameter and the decoding rules that the transformation applies internally.
Customizing the transformation
The default Sensor data aggregation reflects Navixy's general-purpose hourly aggregation. If your operational scenario requires different granularity, such as finer resolution for diagnostics dashboards or coarser intervals for long-term reporting, you can build a custom transformation that calls select_timeperiod_sensor_data with a different interval and writes the result to your own table in processed_custom_data.
Customization is a one-line change inside a Custom SQL node:
Change the interval literal to control both the bucket size and the lookback window. The function returns the same column shape regardless of the interval, so downstream Output node configuration stays simple.
Workflow shape
The minimal workflow is two nodes:

No Raw data: Telematics source node is needed. The function reads from raw_telematics_data.inputs and raw_business_data tables internally. The Custom SQL node contains the entire pipeline, and the Output node materializes the result to your target table.
Customization examples
Expand the sections below to see case-based customization examples.
Output node configuration
Once the Custom SQL node is set up, connect it to an Output node and configure the target table.
Table name
A descriptive name, for example sensors_data_by_5min
Time column
hour_bucket (or your alias if you renamed it)
Primary key
device_id, hour_bucket, sensor_name, event_id
Partition by
DATE(hour_bucket)
Write mode
append
The primary key must include all four columns of the function's natural key. Using only device_id and hour_bucket will cause primary key violations, because each device has multiple sensors emitting in the same bucket. append is the correct write mode when the schedule matches the bucket size, because each run produces new buckets that have never been written before. Use upsert only if your runs overlap (for example, a 15-minute interval scheduled every 5 minutes).
Scheduling
The schedule cadence should equal the interval value. Each run then reads exactly one bucket's worth of data with no overlap and no gap.
1 minute
* * * * *
Every minute
5 minutes
*/5 * * * *
Every 5 minutes
15 minutes
*/15 * * * *
Every 15 minutes
1 hour
0 * * * *
Every hour at minute 00
1 day
5 0 * * *
Every day at 00:05 UTC
Times are UTC. Match the cron cadence to your interval; running less often than the interval will leave gaps in the output table, and running more often will cause duplicate primary-key conflicts in append mode.
Using the workflow template
Navixy provides a ready-made workflow template you can load into Transformation Builder as a starting point. The template ships with the Custom SQL node pre-configured for 5-minute buckets.
See the Templates page for the download, import instructions, and the Output node configuration for this transformation.
Next steps
Common transformations: Back to the transformation index.
Templates: Download the Sensor data aggregation workflow template and import it into Transformation Builder.
Transformation Builder: Learn how to work with the visual workflow editor, add nodes, and preview results.
Raw data layer: Explore the source tables that feed into the Sensor data aggregation:
raw_telematics_data.inputs,raw_business_data.sensor_description, andraw_business_data.objects.Trips: A sibling transformation that produces vehicle trip records from raw telematics data.
Last updated
Was this helpful?