Add "Firmware Days Behind" sensor (closes #8)#23
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: parseYYYY.MM.DD→ civil days (Howard Hinnant'sdays_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 viaesphome: includes:and adds a "Firmware Days Behind" template sensor whose lambda is a one-line call intowillowbird::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