Skip to content

Add merge DoCommand to stateful-sensor for single-key resets#6

Merged
Nicolas Palpacuer (NickPPC) merged 1 commit into
mainfrom
merge-command
Jun 5, 2026
Merged

Add merge DoCommand to stateful-sensor for single-key resets#6
Nicolas Palpacuer (NickPPC) merged 1 commit into
mainfrom
merge-command

Conversation

@jckras

Copy link
Copy Markdown
Contributor

What

Adds a merge command to the stateful-sensor's DoCommand. It overlays only the given keys onto the existing value map, leaving all other keys untouched, then persists like set.

{"merge": {"usage": 0}}   // reset usage to 0; regular_grinds/decaf_grinds/cleanings unchanged

Why

The existing set command replaces the entire value map. So resetting a single counter — e.g. a Stream Deck "filled water tank" button sending {"set": {"usage": 0}} — would wipe out every other counter. merge makes single-key resets safe, which is exactly what the per-action buttons need.

Notes

  • set is unchanged — this is a purely additive change (the diff doesn't disturb the existing set path).
  • Guards against a nil value map (a state file containing the literal null) so merge can't panic on a fresh machine.

Tests

  • TestMergeUpdatesOneKeyAndPreservesOthers — resets one key and asserts the others survive (the point of the feature).
  • TestMergeOnNilValueDoesNotPanic — seeds a null state file to exercise the nil-map guard.

Full suite + go vet pass.

🤖 Generated with Claude Code

The stateful-sensor's "set" command replaces the entire value map, so
resetting one counter (e.g. a Stream Deck "filled water tank" button)
would wipe the others. Add a "merge" command that overlays only the
given keys onto the existing value, leaving the rest untouched, and
persists the result like "set".

Guard against a nil value map (state file containing "null") so merge
cannot panic on a fresh machine. "set" is left unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NickPPC Nicolas Palpacuer (NickPPC) merged commit 48425e9 into main Jun 5, 2026
3 checks passed
@jckras Julie Krasnick (jckras) deleted the merge-command branch June 5, 2026 19:49
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.

2 participants