We've improved recently introduced aggregate_by_field
method in message and calc counters to preserve the original data types of aggregated values. Previously, all aggregated field values were converted to strings, but now they retain their original data types (numbers, booleans, etc.).
Example:
When aggregating messages by voltage with this counter configuration:
{
"fields": [
{
"aggregate": "first",
"expression": "floor(external.powersource.voltage)",
"name": "voltage"
}
],
"method": "aggregate_by_field",
"name": "voltages",
"type": "message"
}
Before: Values were converted to strings
"voltages":[{"voltage":"15"},{"voltage":"13"},{"voltage":"14"},{"voltage":"12"}]
After: Values maintain their original type (numeric in this case)
"voltages":[{"voltage":15},{"voltage":13},{"voltage":14},{"voltage":12}]