Skip to content

v0.2.0: migrate to ESPHome, delete custom C++ architecture - #8

Merged
basmeerman merged 2 commits into
mainfrom
feature/esphome-migration
Apr 19, 2026
Merged

basmeerman merged 2 commits into
mainfrom
feature/esphome-migration

Conversation

@basmeerman

Copy link
Copy Markdown
Owner

Summary

Replaces the entire v0.1.x custom PlatformIO + Arduino-ESP32 firmware (~2,000 LOC, 12 source files, Unity tests) with a single ESPHome YAML. Same hardware, same fan curve, same captive portal, same safety failsafe — ~200 lines of config driving the same outcome. See PROJECT_PLAN.md → "History" for the rationale.

Highlights

  • fancontrol.yaml: full firmware definition — DHT22 on GPIO 4, LEDC PWM on GPIO 25 with runtime-tunable 1000–5000 Hz, fan-curve lambda ported verbatim from the v0.1.x Unity-tested fan_curve::computeFromTemperature, sensor-stall failsafe, alarm binary sensors, restart counter, captive portal FanControl-Setup, ESPHome native API + optional MQTT, built-in web_server, password-gated OTA.
  • HA transport flipped from MQTT auto-discovery to ESPHome native API (encrypted, faster, zero-config on HA side). MQTT left available behind a commented block.
  • CI uses esphome/build-action@v10 for full compile gating.
  • Release workflow publishes firmware.bin + firmware.ota.bin + firmware.factory.bin + SHA-256. No more RSA signing — ESPHome's OTA is password+checksum based. SECURITY.md documents the new model and keeps the v0.1.x verification recipe for legacy binaries.

Removed

  • Entire src/ tree, test/, platformio.ini.
  • docs/api.md (no custom WS API), docs/mqtt_topics.md (MQTT now self-documents).
  • RSA-signed release pipeline (secret retained, unused).

Preserved for backward compatibility

  • docs/signing_public_key.pem — verify v0.1.x signed releases.
  • v0.1.0 and v0.1.1 tags + releases intact.

Verification

  • esphome config fancontrol.yaml → Configuration is valid
  • esphome compile fancontrol.yaml → SUCCESS, firmware.bin 945 KB (vs 1.07 MB custom C++), firmware.factory.bin 1.01 MB
  • CI will re-compile on this PR; intentional that config/compile are now the real gate (no more unit tests under ESPHome).

Test plan

  • CI green on this PR (esphome/build-action compiles cleanly)
  • After merge: tag v0.2.0, verify release workflow publishes the three binaries + checksums
  • After hardware arrives: fill in secrets.yaml, esphome run fancontrol.yaml over USB, walk through the first-boot captive-portal flow, confirm HA auto-discovers the device, cycle power to exercise restart_counter, unplug DHT22 to exercise the 60 s sensor-stall failsafe

Migration notes

  • Reflash required — v0.1.x NVS namespace isn't portable.
  • Captive portal FanControl-Setup reappears on first boot for WiFi reconfiguration.
  • OTA password now baked at compile time (via secrets.yaml) — no more "changeme" + first-boot rotation banner.

🤖 Generated with Claude Code

Bas Meerman and others added 2 commits April 19, 2026 12:04
Replaces the entire v0.1.x custom PlatformIO + Arduino-ESP32 firmware
(~2,000 LOC across 12 source files + Unity tests) with a single ESPHome
YAML. Same hardware, same fan curve, same captive portal, same safety
failsafe. Rationale in PROJECT_PLAN.md "History".

Added
- fancontrol.yaml: DHT22 + LEDC PWM with runtime-tunable frequency,
  5-point piecewise-linear fan-curve lambda (ported from the v0.1.x
  Unity-tested fan_curve::computeFromTemperature), sensor-stall
  failsafe (→ 100 %), alarm binary sensors, restart counter, captive
  portal, ESPHome native API + optional MQTT block, web_server, OTA.
- secrets.yaml.example: WiFi / API key / OTA password template.
- docs/home_assistant.md: integration walkthrough + automation ideas.

Changed
- HA transport: MQTT auto-discovery → ESPHome native API (encrypted,
  faster, zero-config on HA side). MQTT left commented out for users
  who prefer the v0.1.x topic shape.
- Web UI: custom 4-section PROGMEM dashboard → ESPHome web_server.
- CI (.github/workflows/ci.yml): esphome/build-action@v10 (full
  compile, not just lint) + 1.5 MB size gate + artifact upload.
- Release (.github/workflows/release.yml): publishes firmware.bin +
  firmware.ota.bin + firmware.factory.bin + SHA-256 checksums.
  No more RSA signing (ESPHome OTA uses password + checksum; see
  SECURITY.md for the why and for v0.1.x verification recipe).
- README, CLAUDE.md, CONTRIBUTING.md, PROJECT_PLAN.md, SECURITY.md:
  all rewritten for the ESPHome workflow.
- docs/wiring_diagram.md: pin map unchanged, refs updated.
- .github/PULL_REQUEST_TEMPLATE.md: checklist pivots from pio to esphome.

Removed
- Entire src/ tree: config, storage, sensor, fan, fan_curve, watchdog,
  wifi_manager, mqtt, webserver, websocket, index_html, version, main.
- test/ directory (Unity host tests).
- platformio.ini.
- docs/api.md (no custom HTTP / WS API under ESPHome).
- docs/mqtt_topics.md (MQTT is now optional + self-documenting via HA
  discovery).
- RSA-signed release pipeline. SECRET_RSA_KEY repo secret retained
  (unused from v0.2.0) so pre-v0.2.0 tags could theoretically be
  re-signed. docs/signing_public_key.pem preserved for verifying
  existing v0.1.0 / v0.1.1 signed binaries.

Verification
- esphome config fancontrol.yaml → Configuration is valid.
- esphome compile fancontrol.yaml → SUCCESS, firmware.bin 945 KB
  (vs 1.07 MB custom C++), firmware.factory.bin 1.01 MB.

Migration
- Reflash required; v0.1.x NVS namespace is not portable.
- Reconfigure via FanControl-Setup captive portal on first boot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@basmeerman
basmeerman merged commit 768824d into main Apr 19, 2026
1 check passed
@basmeerman
basmeerman deleted the feature/esphome-migration branch April 19, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant