From 2a0ca0027dda9d9c8aa370e419ff97c4a2a992ec Mon Sep 17 00:00:00 2001 From: Tiyash Basu Date: Thu, 22 May 2025 15:38:37 +0200 Subject: [PATCH 1/2] Remove `SensorMetricSample` in favour of `MetricSample` This commit removes the `SensorMetricSample` message in favour of using `MetricSample` for sensors. The `SensorMetricSample` message was a subset of the `MetricSample` message. From a design perspective focused on consistency, flexibility, and minimizing API surface area while handling variations via optional fields (which is idiomatic in Protobuf3), there's a strong argument that `SensorMetricSample` is redundant and potentially confusing, and that having only `MetricSample` is a cleaner design. Signed-off-by: Tiyash Basu --- RELEASE_NOTES.md | 1 + .../frequenz/api/common/v1/microgrid/sensors/sensors.proto | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6521e7f7..39e26d6b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -35,6 +35,7 @@ - Renamed `SensorState` to `SensorStateSnapshot` to better reflect its purpose. - Renamed `sampled_at` timestamps for state snapshots to `origin_time`. - Renamed `sampled_at` timestamps for metric samples to `sample_time`. +- Remove `SensorMetricSample` in favour of using `MetricSample` for sensors. ## Bug Fixes diff --git a/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto b/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto index dac49cdd..1b781e98 100644 --- a/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto +++ b/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto @@ -233,11 +233,15 @@ message SensorMetricSample { // sample_time: "2023-10-01T00:00:00Z", // metric: "METRIC_SENSOR_TEMPERATURE", // value: metric_value_variant: {simple_metric: {value: 23.5}, +// bounds: {} +// source: {} // }, // { // sample_time: "2023-10-01T00:00:00Z", // metric: "METRIC_SENSOR_RELATIVE_HUMIDITY", // value: metric_value_variant: {simple_metric: {value: 23.5}, +// bounds: {} +// source: "humidity_sensor_1" // } // ], // states: [ @@ -254,7 +258,7 @@ message SensorData { uint64 sensor_id = 1; // List of measurements for a metric of the specific microgrid sensor. - repeated SensorMetricSample metric_samples = 2; + repeated frequenz.api.common.v1.metrics.MetricSample metric_samples = 2; // List of states of a specific microgrid sensor. repeated SensorStateSnapshot states = 3; From 3567a48b79859658b546c5e3f0964fe643b55fd2 Mon Sep 17 00:00:00 2001 From: Tiyash Basu Date: Thu, 22 May 2025 15:39:01 +0200 Subject: [PATCH 2/2] Remove unused enum `SensorMetric` Signed-off-by: Tiyash Basu --- RELEASE_NOTES.md | 1 + .../common/v1/microgrid/sensors/sensors.proto | 52 ------------------- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 39e26d6b..ed9c34d4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -36,6 +36,7 @@ - Renamed `sampled_at` timestamps for state snapshots to `origin_time`. - Renamed `sampled_at` timestamps for metric samples to `sample_time`. - Remove `SensorMetricSample` in favour of using `MetricSample` for sensors. +- Remove `SensorMetric` enum, since it was unused and redundant. ## Bug Fixes diff --git a/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto b/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto index 1b781e98..a73a2744 100644 --- a/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto +++ b/proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto @@ -42,46 +42,6 @@ enum SensorCategory { SENSOR_CATEGORY_GENERAL = 7; } -// Enumrated sensor metrics. -enum SensorMetric { - // Unspecified. - SENSOR_METRIC_UNSPECIFIED = 0; - - // Temperature. - // In Celsius (°C). - SENSOR_METRIC_TEMPERATURE = 1; - - // Humidity - // In percentage (%). - SENSOR_METRIC_HUMIDITY = 2; - - // Pressure - // In Pascal (Pa). - SENSOR_METRIC_PRESSURE = 3; - - // Irradiance / Radiation flux - // In watts per square meter (W / m^2). - SENSOR_METRIC_IRRADIANCE = 4; - - // Velocity - // In meters per second (m / s). - SENSOR_METRIC_VELOCITY = 5; - - // Acceleration. - // In meters per second per second (m / s^2) - SENSOR_METRIC_ACCELERATION = 6; - - // Metric to represent angles, for metrics like direction. - // In angles with respect to the (magnetic) North (°). - SENSOR_METRIC_ANGLE = 7; - - // Dew point. - // The temperature at which the air becomes saturated with water vapor. - // - // In Celsius (°C). - SENSOR_METRIC_DEW_POINT = 8; -} - // Enum to represent the various states that a sensor can be in. // This enum is unified across all sensor categories for consistency. enum SensorStateCode { @@ -207,18 +167,6 @@ message SensorStateSnapshot { repeated SensorDiagnostic errors = 4; } -// Representation of a sampled sensor metric along with its value. -message SensorMetricSample { - // The UTC timestamp of when the metric was sampled. - google.protobuf.Timestamp sample_time = 1; - - // The metric that was sampled. - frequenz.api.common.v1.metrics.Metric metric = 2; - - // The value of the sampled metric. - frequenz.api.common.v1.metrics.MetricValueVariant value = 3; -} - // SensorData message aggregates multiple metrics, operational states, and // errors, related to a specific microgrid sensor. //