Add merge DoCommand to stateful-sensor for single-key resets#6
Merged
Conversation
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>
Nicolas Palpacuer (NickPPC)
approved these changes
Jun 5, 2026
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.
What
Adds a
mergecommand to the stateful-sensor'sDoCommand. It overlays only the given keys onto the existing value map, leaving all other keys untouched, then persists likeset.{"merge": {"usage": 0}} // reset usage to 0; regular_grinds/decaf_grinds/cleanings unchangedWhy
The existing
setcommand 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.mergemakes single-key resets safe, which is exactly what the per-action buttons need.Notes
setis unchanged — this is a purely additive change (the diff doesn't disturb the existingsetpath).null) somergecan't panic on a fresh machine.Tests
TestMergeUpdatesOneKeyAndPreservesOthers— resets one key and asserts the others survive (the point of the feature).TestMergeOnNilValueDoesNotPanic— seeds anullstate file to exercise the nil-map guard.Full suite +
go vetpass.🤖 Generated with Claude Code