Skip to content

feat: power input methods — docs, staleness, HW energy, manual IP, diagnostics (#71-#75)#86

Merged
basmeerman merged 6 commits intomasterfrom
work/plan-09
Mar 19, 2026
Merged

feat: power input methods — docs, staleness, HW energy, manual IP, diagnostics (#71-#75)#86
basmeerman merged 6 commits intomasterfrom
work/plan-09

Conversation

@basmeerman
Copy link
Copy Markdown
Owner

Summary

  • Comprehensive documentation for all 5 power input methods with reliability ranking, decision tree, setup guides, and troubleshooting (docs/power-input-methods.md)
  • API/MQTT staleness detection — configurable timeout (default 120s) falls back to MaxMains instead of stopping charging; suppresses CT_NOCOMM for API mode
  • HomeWizard P1 energy data — reads total_power_import_kwh / total_power_export_kwh from the P1 API for HA energy dashboard
  • HomeWizard P1 manual IPSet/HomeWizardIP MQTT command bypasses mDNS for networks where discovery is unreliable
  • Metering diagnostic countersMeterTimeoutCount, MeterRecoveryCount, ApiStaleCount published as HA diagnostic entities

Test plan

  • 40 test suites, all passing (873 annotated tests, 100% traceability)
  • 22 new tests across 2 new test files (test_api_staleness.c, test_metering_diagnostics.c)
  • Address/UB sanitizer clean
  • cppcheck static analysis clean
  • ESP32 build: Flash 85.5%, RAM 21.2%
  • CH32 build: Flash 63.1%, RAM 20.6%

Closes #71, closes #72, closes #73, closes #74, closes #75

🤖 Generated with Claude Code

basmeerman and others added 6 commits March 19, 2026 09:51
Create docs/power-input-methods.md covering all 5 metering methods
(Modbus RTU, Sensorbox, HomeWizard P1, Battery MQTT, API/MQTT feed)
with reliability ranking, decision tree, per-method setup guides,
comparison table, migration guide, and troubleshooting.

Add cross-references from README.md, configuration.md, and
installation.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add staleness detection for API metering mode (type 9). When no update
arrives within the configurable timeout (default 120s), all phases fall
back to MaxMains as a safe default — charging continues at safe limits
instead of stopping with CT_NOCOMM. When staleness detection is enabled,
CT_NOCOMM is suppressed for API mode.

New MQTT command: Set/MainsMeterTimeout (0=disabled, 10-3600 seconds)
New ctx fields: api_mains_staleness_timer, api_mains_timeout, api_mains_stale
12 new tests covering countdown, fallback, recovery, suppression, and parser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend getMainsFromHomeWizardP1() to parse total_power_import_kwh and
total_power_export_kwh from the P1 API response, converting kWh to Wh.
Energy data is now set on MainsMeter.Import_active_energy and
Export_active_energy, making it available for the HA energy dashboard
via existing MQTT publishing.

Return type changed from std::pair to HomeWizardP1Result struct for
cleaner interface. JSON filter and doc sizes increased to accommodate
the two additional fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Set/HomeWizardIP MQTT command to bypass mDNS discovery. When set,
discoverHomeWizardP1() returns the manual IP directly instead of doing
mDNS lookup. Send empty payload to re-enable mDNS. This fixes
intermittent mDNS failures on networks with mDNS-unfriendly routers
or VLAN isolation.

Also adds dispatch cases for MQTT_CMD_MAINS_METER_TIMEOUT and
MQTT_CMD_HOMEWIZARD_IP in the MQTT command switch in esp32.cpp.

3 new MQTT parser tests (valid IP, empty/clear, too long).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add per-method diagnostic counters to track metering health:
- meter_timeout_count: CT_NOCOMM timeout events
- meter_recovery_count: CT_NOCOMM recovery events
- api_stale_count: API staleness detection events

Counters are incremented in evse_tick_1s, published via MQTT as
diagnostic entities with HA discovery (total_increasing state class,
disabled by default). MQTT_CACHE_MAX_SLOTS bumped from 84 to 88.

7 new tests in test_metering_diagnostics.c covering init, increment,
cumulative, recovery, and suppression scenarios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Combine plan-09 additions (staleness, HomeWizard IP) with plan-06
additions (diag_profile, diag_telemetry) in mqtt_parser.h, esp32.cpp,
and Makefile. All 43 test suites pass, both firmware builds succeed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@basmeerman basmeerman merged commit dc3bfc2 into master Mar 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant