Successfully implemented health monitoring alerts with threshold checking for temperature, voltage, and accelerometer data.
Added four new message type handlers:
-
TemperatureHandler:
- Calculates average temperature from 4 sensors
- Threshold: > 60°C triggers error badge
- Color:
badge-error(red) when high,badge-success(green) when normal
-
SupplyVoltageHandler:
- Uses mean supply voltage
- Normal range: 12-18V
- Color:
badge-warning(yellow) when out of range,badge-successwhen normal
-
CPUDataHandler:
- Displays CPU load percentage
- No threshold checking (as per requirements)
- Color:
badge-info(blue)
-
AccelerometerHandler:
- Calculates magnitude: sqrt(x² + y² + z²)
- Threshold: > 2g triggers error badge
- Color:
badge-error(red) when high,badge-success(green) when normal
- Imported new handlers
- Registered handlers for message types:
Temperature,SupplyVoltage,CPUData,Accelerometer
Updated System Health section to display visual alerts:
-
Temperature:
- Red ring border when > 60°C
- Red text color for value
- "HIGH" badge indicator
-
Voltage:
- Yellow ring border when outside 12-18V range
- Yellow text color for value
- "OUT OF RANGE" badge indicator
-
Accelerometer:
- Red ring border when > 2g
- Red text color for value
- "⚠ WARNING" badge indicator
-
CPU Load: No highlighting (no threshold specified)
All unit tests pass (38 tests total):
- ✓ Temperature handler with normal and high values
- ✓ Voltage handler with normal, low, and high values
- ✓ CPU load handler
- ✓ Accelerometer handler with normal and high values
- ✓ StateAggregator integration for all new handlers
- ✓ Requirement 7.4: Temperature threshold checking (> 60°C)
- ✓ Requirement 7.5: Voltage range checking (12-18V)
- ✓ Requirement 8.3: Accelerometer threshold checking (> 2g)
The UI now provides clear visual feedback:
- Ring borders around stat cards when thresholds are exceeded
- Color-coded text for values (red for errors, yellow for warnings)
- Badge indicators with descriptive text (HIGH, OUT OF RANGE, WARNING)
To verify the implementation:
- Start the Fastify server:
npm run start:fastify - Start the frontend:
npm run dev - Send test telemetry messages with:
- Temperature > 60°C (should show red highlighting)
- Voltage < 12V or > 18V (should show yellow highlighting)
- Accelerometer magnitude > 2g (should show red highlighting)
- Verify the System Health section displays appropriate visual alerts
- The implementation follows DaisyUI badge color conventions
- Thresholds are configurable in the handler classes
- The UI gracefully handles missing data (displays "-" with info color)
- All existing tests continue to pass