Skip to content

Add "Firmware Days Behind" sensor (closes #8)#23

Merged
jbunting merged 1 commit into
mainfrom
feat/firmware-days-behind
Jul 7, 2026
Merged

Add "Firmware Days Behind" sensor (closes #8)#23
jbunting merged 1 commit into
mainfrom
feat/firmware-days-behind

Conversation

@jbunting

@jbunting jbunting commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Adds the last remaining piece of #8 — "how far out of date" — as a numeric sensor, and pilots the #7 pattern for externalizing device logic that's too gnarly for a clean inline lambda.

What

  • devices/common/firmware_status.h — a real C++ header with the CalVer date math: parse YYYY.MM.DD → civil days (Howard Hinnant's days_from_civil), diff current vs latest. Returns unknown for dev builds or before the first update check; never negative (a device at/ahead of latest reports 0).
  • cicd.yaml — pulls the header via esphome: includes: and adds a "Firmware Days Behind" template sensor whose lambda is a one-line call into willowbird::days_behind(...).

Why this shape

Per discussion on #7: rather than a heavy custom component or a gnarly inline date-math lambda, complex logic lives in a proper C++ header (real tooling/formatting) with a thin lambda binding. This is the reusable pattern for future devices when their logic outgrows a one-liner. The existing simple lambdas and the vendored TubesZB logic are left untouched.

Verified

Local esphome compile (2026.6.4) succeeds; the include path resolves correctly through the package (devices/common/firmware_status.h).

Closes #8.

🤖 Generated with Claude Code

Adds the last piece of #8 — "how far out of date" — as a numeric sensor, and
pilots the pattern from #7 for externalizing device logic that's too complex
for a clean inline lambda.

- devices/common/firmware_status.h: a real C++ header with the CalVer date
  math (parse YYYY.MM.DD -> civil days, diff current vs latest). Unknown for
  dev builds or before the first update check; never negative.
- cicd.yaml: pull it via `esphome: includes:` and add a "Firmware Days Behind"
  template sensor whose lambda is a one-line call into the helper.

Leaves the existing simple lambdas and the vendored TubesZB logic untouched.
Verified with a local `esphome compile` (2026.6.4).

Closes #8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jbunting
jbunting merged commit c511df7 into main Jul 7, 2026
11 checks passed
@jbunting
jbunting deleted the feat/firmware-days-behind branch July 7, 2026 04:00
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.

Status/version sensors

1 participant