Commit 95d6c03
Antonio ...
fix: Add throttled logging for sensor errors to prevent log spam (v1.3.16)
Fixed excessive logging when sensors become unavailable, which was causing Home Assistant to log warnings about too frequent logging (200+ messages).
Problem:
- When sensor.potenza_interna_abitazione returns 'unknown', Solar Surplus validation logs full error every minute
- Check runs every 1 minute by default
- Results in 200+ identical error messages
- Home Assistant detects log spam: "Module logging too frequently"
Solution:
- Implemented smart sensor error state tracking (_sensor_error_state dictionary)
- Only log full error details when error FIRST occurs or changes
- Subsequent identical errors: silent (debug level only)
- When sensor recovers: log success message with previous error
- Per-sensor tracking (independent error states)
Behavior:
Before (v1.3.15):
- 12:35:07 - ❌ Sensor validation failed: Home Consumption unknown
- 12:36:07 - ❌ Sensor validation failed: Home Consumption unknown
- 12:37:07 - ❌ Sensor validation failed: Home Consumption unknown
- ... (200+ identical messages)
After (v1.3.16):
- 12:35:07 - ❌ Sensor validation failed: Home Consumption unknown [LOGGED ONCE]
- 12:36:07 - [silent - debug only]
- 12:37:07 - [silent - debug only]
- 12:38:07 - ✅ Home Consumption sensor recovered (was: unknown) [LOGGED]
Technical Changes:
- Added _sensor_error_state dict to SolarSurplusAutomation __init__
- Modified sensor validation loop in _async_periodic_check()
- Track error state per sensor entity_id
- Detect state changes (new error, changed error, recovered)
- Log only on state transitions
Impact:
- Clean logs, no spam warnings
- Easier troubleshooting (see when errors start/stop)
- No performance impact
- Same diagnostic sensor updates
Files Modified:
- solar_surplus.py: Added error tracking, modified validation logic
- const.py: VERSION = 1.3.16
- manifest.json: version = 1.3.16
- CLAUDE.md: v1.3.16 release notes
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 507986a commit 95d6c03
4 files changed
Lines changed: 46 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
753 | 753 | | |
754 | 754 | | |
755 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
756 | 775 | | |
757 | 776 | | |
758 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
| |||
344 | 347 | | |
345 | 348 | | |
346 | 349 | | |
347 | | - | |
| 350 | + | |
348 | 351 | | |
349 | 352 | | |
350 | 353 | | |
351 | 354 | | |
352 | 355 | | |
353 | 356 | | |
354 | 357 | | |
| 358 | + | |
| 359 | + | |
355 | 360 | | |
356 | 361 | | |
| 362 | + | |
357 | 363 | | |
358 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
359 | 374 | | |
360 | 375 | | |
361 | | - | |
362 | | - | |
363 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
364 | 385 | | |
365 | 386 | | |
366 | 387 | | |
| |||
0 commit comments