You are implementing Plan 09: comprehensive documentation for all 5 power input methods, plus feature gap fixes (API staleness detection, HomeWizard P1 energy data, manual IP fallback, and diagnostic counters).
Read the full plan at: /Users/basmeerman/Downloads/EVSE-team-planning/plan-09-power-input-methods.md
- Branch:
work/plan-09 - Remote: Push to
myfork(basmeerman/SmartEVSE-3.5), NEVER toorigin - Workflow: Specification-first for code changes (SbE → test → implement → verify)
- Verify after each code increment:
cd SmartEVSE-3/test/native && make clean test - Verify firmware builds:
pio run -e release -d SmartEVSE-3/ - Commit and push after each increment — do not batch multiple increments into one commit
- #71 — Power Input Methods Documentation (Increment 1) — START HERE
- #72 — API/MQTT Staleness Detection (Increment 2)
- #73 — HomeWizard P1 Energy Data (Increment 3)
- #74 — HomeWizard P1 Manual IP Fallback (Increment 4)
- #75 — Diagnostic Counters (Increment 5)
docs/power-input-methods.md— Comprehensive power input guide (Increment 1)SmartEVSE-3/test/native/tests/test_metering_diagnostics.c— Diagnostic counter tests (Increment 5)
SmartEVSE-3/src/mqtt_parser.c/mqtt_parser.h— Add staleness timeout parsing, HomeWizardIP commandSmartEVSE-3/src/evse_ctx.h— Addapi_mains_last_update_ms,api_mains_timeout_ms, diagnostic counter fieldsSmartEVSE-3/src/evse_state_machine.c— Staleness check in tick function (CRITICAL — must have tests)SmartEVSE-3/test/native/Makefile— Add test_metering_diagnostics build ruleREADME.md— Add "Power Input Methods" to documentation table
These files are also modified by Plan 06 and/or Plan 07:
network_common.cpp: You modifygetMainsFromHomeWizardP1()to read energy fields (Increment 3) and add HomeWizardIP manual fallback in mDNS discovery (Increment 4). Keep your changes in clearly marked sections with comments like// BEGIN PLAN-09: HomeWizard energy dataand// END PLAN-09.
- CRITICAL:
evse_state_machine.cchanges MUST have tests — this is safety-critical - Staleness detection must use pure C, testable natively
- Use
snprintfeverywhere, neversprintf - All test functions MUST have SbE annotations (@feature, @req, @scenario, etc.)
- Use
test_framework.h(NOT unity.h) - New
evse_ctx.hfields must be documented with comments - Never change existing MQTT topic names — only add new ones
- Never change existing
/settingsJSON field names — only add new fields - Requirement prefix:
REQ-MTR-for metering,REQ-MQTT-for MQTT
- Read the plan's Section 1 (Power Input Method Analysis) thoroughly
- Read existing code to verify the data flow descriptions:
main.cpp:ModbusRequestLoop()for Modbus RTU and Sensorboxesp32.cpp:homewizard_loop()/getMainsFromHomeWizardP1()for HomeWizardnetwork_common.cpp: MQTT callback for API/MQTT feed
- Create
docs/power-input-methods.mdwith:- Reliability ranking table (most reliable first)
- Decision tree flowchart (text-based)
- Per-method setup guide (5 methods)
- Comparison table
- Troubleshooting section
- Update
README.mddocumentation table with link - Commit and push
- Write SbE scenarios:
- Given API metering, when no update for 120s, then fall back to MaxMains
- Given API metering, when update received, then reset staleness timer
- Given API metering, when staleness detected, then set diagnostic flag
- Given non-API metering, then staleness check is skipped
- Add fields to
evse_ctx.h:api_mains_last_update_ms,api_mains_timeout_ms - Write tests in existing test file or new test file
- Implement staleness check in
evse_state_machine.c - Add MQTT parser for timeout setting
- Run
make clean test - Verify firmware builds
- MQTT parser pattern:
src/mqtt_parser.c(see existingSet/MainsMeterhandler) - HomeWizard code: search for
HomeWizardinesp32.cppandnetwork_common.cpp - Modbus metering:
main.cppModbusRequestLoop() - State machine:
src/evse_state_machine.c - Context struct:
src/evse_ctx.h - Test framework:
test/native/include/test_framework.h - Existing meter tests:
test/native/tests/test_meter_decode.c