Skip to content

DRV-42: copier update to template v0.7.0 (fix BOOL variable format)#61

Merged
svc-finitelabs[bot] merged 2 commits into
mainfrom
agent/DRV-42-copier-update-template-v0.7.0
May 22, 2026
Merged

DRV-42: copier update to template v0.7.0 (fix BOOL variable format)#61
svc-finitelabs[bot] merged 2 commits into
mainfrom
agent/DRV-42-copier-update-template-v0.7.0

Conversation

@svc-finitelabs

Copy link
Copy Markdown
Contributor

Fixes DRV-42 / closes #55.

Summary

`copier update` from template v0.5.0 → v0.7.0. The only material change in driver behavior comes from template v0.6.0: BOOL variables now serialize as `"0"`/`"1"` instead of `"true"`/`"false"`, which is what Control4 actually expects. Without this, BOOL variables created by the driver (the ` State` variable for `binary_sensor` and `switch`, plus all BTHome BOOL sensors) showed `False` permanently in the Variables Agent even though the value was changing under the hood.

Template v0.7.0 is a one-line copier housekeeping change (adds the answers-file template so future `copier update` runs persist `_commit` and any new answers).

What changed in the driver

Only two files:

  • `src/lib/values.lua` — rendered output of the updated template.
  • `.copier-answers.yml` — `_commit` bumped to v0.7.0, `lib_modules` answer added (template v0.6.0 introduced this question; defaulted to the full module set so nothing is excluded).

Why this is safe

  • The new `values:update` signature is backward-compatible with every existing callsite in this repo:
    • 3-arg calls (`values:update(name, value, type)`) — unchanged behavior, except now `nil` as the callback arg means "leave the OVC handler alone" instead of "clear it". Callers that never registered a callback (binary_sensor, sensor, etc.) are unaffected.
    • 4-arg calls with a `function` (`switch`, `text`, `select`, `number`, `date`, `time`, `datetime`) — still register the callback. No behavior change for the user.
  • BOOL serialization fix is the documented bug fix; the value path through `toboolean` already produced a Lua boolean, this just stringifies it the way C4 wants.
  • A side-effect of the v0.6.0 patch: inbound state pushes no longer clobber a registered OVC callback. That fixes a latent issue where a state arriving while a programming-managed callback was wired would silently drop the callback.

Verification

  • `make build` runs clean end-to-end (preprocess → gen-squishy → update-xml → docs → fmt → package → zip). No dirty tree.
  • One stylua nit collapsed a multi-line `log:trace` call to a single line (template ships it multi-line, stylua at 120 cols folds it). Amended into this commit; will file a follow-up to fix the template formatting so future `copier update` runs stop drifting.

Out of scope (follow-up)

The same template fix needs to roll into `control4-mqtt`, `control4-home-connect`, and `control4-finite-labs-essentials` (all pinned at v0.5.0). I'll handle those as separate per-repo `copier update` PRs after this one is signed off — touching one driver at a time keeps the blast radius small if anything regresses.

svc-finitelabs Bot added 2 commits May 21, 2026 21:33
Pulls in template v0.6.0 fix for src/lib/values.lua: BOOL variables now
serialize to '0'/'1' instead of 'true'/'false', matching what C4 expects.
This restores BOOL state visibility in the Variables Agent for binary_sensor
and switch entities (GitHub issue #55).

v0.6.0 also reorganizes update() to leave the OVC callback alone on inbound
state pushes (split into setCallback), so a state arriving while a callback
is registered no longer clears it. Existing callsites in this driver
(binary_sensor, switch, etc.) remain source-compatible.

v0.7.0 adds the answers-file template so future copier updates persist
_commit and any new answers.

Closes GH-55.
Variables Agent users will see this go from showing False permanently to
reflecting actual state, which is worth a user-facing changelog note.
@svc-finitelabs svc-finitelabs Bot merged commit 2cfa24a into main May 22, 2026
1 check passed
@svc-finitelabs svc-finitelabs Bot deleted the agent/DRV-42-copier-update-template-v0.7.0 branch May 22, 2026 04:03
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.

Possible issue with bool variables in ESPhome driver

1 participant