Skip to content

Commit 59dcdc0

Browse files
Update sensor error representation (#310)
2 parents 2e89add + e821150 commit 59dcdc0

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
- Added new message definitions for communication components.
1616
- Added new message `ElectricalComponentDiagnostic` to represent warnings and errors in microgrid electrical components.
1717
- The enum `ComponentErrorCode` has now been renamed to `ElectricalComponentDiagnosticCode` to better reflect its shared usage with warnings and errors.
18+
- Added new message `SensorDiagnostic` to represent warnings and errors in microgrid sensors.
19+
- The enum `SensorErrorCode` has now been renamed to `SensorDiagnosticCode` to better reflect its shared usage with warnings and errors.
20+
- Added warnings to sensor `SensorState`.
1821

1922
## Bug Fixes
2023

proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,38 @@ message SensorData {
149149
repeated SensorState states = 3;
150150
}
151151

152+
// Represents an error or warning condition reported by a microgrid sensor.
153+
//
154+
// This message extends a standardized error code with contextual information
155+
// useful for diagnostics, such as subsystem names, measured values, or
156+
// vendor-specific insights.
157+
//
158+
// !!! example "Typical Sensor Error"
159+
// ```json
160+
// {
161+
// "diagnosticCode":
162+
// "SENSOR_DIAGNOSTIC_CODE_INTERNAL",
163+
// "vendorErrorCode": 2003,
164+
// "message": "Temperature sensor 3 reported 61.5°C (limit: 60°C)"
165+
// }
166+
// ```
167+
// !!! note "Vendor-Specific Codes"
168+
// When available, `vendor_error_code` will reflect manufacturer-defined
169+
// error identifiers, typically exposed via Modbus or similar interfaces.
170+
// These codes are vendor- and firmware-specific and must be interpreted
171+
// using the vendor's official documentation.
172+
message SensorDiagnostic {
173+
// A standardized error code representing the category of the issue.
174+
SensorDiagnosticCode diagnostic_code = 1;
175+
176+
// Optional vendor-provided error code for the error, for vendor-specific
177+
// insights or more granular diagnostics.
178+
optional uint32 vendor_error_code = 2;
179+
180+
// Optional human-readable message providing additional context.
181+
string message = 3;
182+
}
183+
152184
// Representation of a sensor state and errors.
153185
message SensorState {
154186
// The time at which the state was sampled.
@@ -161,6 +193,17 @@ message SensorState {
161193
// this list.
162194
repeated SensorStateCode states = 2;
163195

196+
// List of warnings for the microgrid sensor.
197+
//
198+
// !!! note
199+
// This list is expected to have warnings if and only if the sensor is
200+
// reporting warnings.
201+
//
202+
// !!! note
203+
// The list will contain unique members. No warning will exist twice in
204+
// this list.
205+
repeated SensorDiagnostic warnings = 3;
206+
164207
// List of errors for the microgrid sensor.
165208
//
166209
// !!! note
@@ -170,7 +213,7 @@ message SensorState {
170213
// !!! note
171214
// The list will contain unique members. No error will exist twice in
172215
// this list.
173-
repeated SensorErrorCode errors = 4;
216+
repeated SensorDiagnostic errors = 4;
174217
}
175218

176219
// Enum to represent the various states that a sensor can be in.
@@ -187,17 +230,18 @@ enum SensorStateCode {
187230
SENSOR_STATE_CODE_ERROR = 2;
188231
}
189232

190-
// A representation of all possible errors that can occur in sensors.
191-
enum SensorErrorCode {
233+
// A representation of all possible warnings and errors that can occur in
234+
// sensors.
235+
enum SensorDiagnosticCode {
192236
// Default value. No specific error is specified.
193-
SENSOR_ERROR_CODE_UNSPECIFIED = 0;
237+
SENSOR_DIAGNOSTIC_CODE_UNSPECIFIED = 0;
194238

195239
// The sensor is reporting an unknown or an undefined error, and the sender
196240
// cannot parse the sensor error to any of the variants below.
197-
SENSOR_ERROR_CODE_UNKNOWN = 1;
241+
SENSOR_DIAGNOSTIC_CODE_UNKNOWN = 1;
198242

199243
// Error indicating an internal error within the sensor.
200-
SENSOR_ERROR_CODE_INTERNAL = 2;
244+
SENSOR_DIAGNOSTIC_CODE_INTERNAL = 2;
201245
}
202246

203247
// Representation of a sampled sensor metric along with its value.

0 commit comments

Comments
 (0)