sensor-monitor: action-based triggers with capture/reference data passing#9
Merged
Merged
Conversation
Add per-rule on_trigger / on_resolve action lists, each naming a resource and a DoCommand payload. On the triggering edge the monitor fires every on_trigger action; on the clearing edge it fires every on_resolve action — best-effort, edge-only (not repeated on cooldown). Action resources are declared as required dependencies in Validate and resolved at construction by short name across any API (every resource implements DoCommand), so an action can target a board, sensor, generic service, etc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Remove the dedicated notifier (notifier field, message templating,
sendNotification): notifying is now just an on_trigger action targeting a
notification service. Each rule's on_trigger/on_resolve actions fire DoCommands
on any resource, on the trigger edge (and cooldown repeats) and the resolve
edge respectively.
Action commands support ${...} references resolved before sending — against
rule context (${value}, ${key}, ${threshold}, ${operator}) and against
responses captured from earlier actions via "capture". This lets a message sent
on trigger be reacted to on resolve by capturing the send response and
referencing ${msg.ts}/${msg.channel}. An unresolved reference skips that action.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Nicolas Palpacuer (NickPPC)
approved these changes
Jun 25, 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
Reworks
sensor-monitorfrom "watch a sensor and notify via a fixed notifier" into a general action model: when a rule triggers or resolves, it firesDoCommands on any resources you name.on_triggerandon_resolveaction lists; each action is{ "resource": <name>, "command": <DoCommand payload> }targeting any component or service.{ "command": "send", ... }. The dedicatednotifier/message/sendNotificationpath is removed; the only fixed dependency is the watched sensor.on_triggerfires on the triggering edge and repeats percooldown_secondswhile triggered (default0= edge-only);on_resolvefires on the clearing edge.Validateand resolved at construction by short name across any API (everyresource.ResourceimplementsDoCommand).Capture & references (carrying data between commands)
Command string values may embed
{{...}}references, resolved just before sending:{{value}},{{key}},{{threshold}},{{operator}}(this also replaces the old{value}message templating)."capture": "<name>"stores its DoCommand response; later actions reference its fields as{{name.field}}.A value that is exactly one reference keeps the referenced value's type; an embedded reference is substituted as text. An unresolved reference skips that action. This is how a Slack message sent on trigger is reacted to on resolve —
capture: "msg"on the send, then{{msg.ts}}/{{msg.channel}}in the resolvereactcommand. Captures are overwritten on each cooldown re-fire (so resolve uses the latest) and cleared on resolve.Tests & docs
resolveValueunit tests (typed/embedded/nested/missing), trigger+resolve firing, cooldown repeat, capture-carries-across-trigger-resolve, capture-missing skip, and unresolved-dependency build failure. README rewritten for the action model.Notes
notifier+ per-rulemessagefields are gone. Existing configs migrate by moving eachmessageinto anon_triggersend action (with{{value}}in place of{value}).reactcommand for the reaction use case — see Add "react" command for emoji reactions notifications#4. The bot token needs thereactions:writescope.🤖 Generated with Claude Code