Skip to content

sensor-monitor: react to alert message when a rule resolves#8

Closed
Daniel Botros (danielbotros) wants to merge 4 commits into
mainfrom
react-on-resolve
Closed

sensor-monitor: react to alert message when a rule resolves#8
Daniel Botros (danielbotros) wants to merge 4 commits into
mainfrom
react-on-resolve

Conversation

@danielbotros

@danielbotros Daniel Botros (danielbotros) commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Adds a per-rule resolve_reaction to sensor-monitor: when a rule's sensor reading returns to the non-triggered side of the threshold, the monitor reacts to that rule's alert message with the configured emoji.

  • resolve_reaction lives on Rule. When unset, no reaction is added — no default, no disable sentinel.
  • On send, the monitor stores the notifier's response opaquely as sentMessage. On the clearing edge it passes that metadata back via DoCommand({"command": "react", "name": <emoji>, ...}), so the monitor doesn't know or care how a notifier identifies a message.
  • Reacts exactly once per episode, then clears the stored metadata. A cooldown re-notify overwrites it, so the reaction lands on the most recent alert.

Why

Closes the maintenance-alert loop: a Streamdeck "Refill" button resets a usage counter, the monitor sees the value drop below threshold on its next poll, and checkmarks the alert it sent.

Depends on

A notifier that supports the react command — see viam-modules/notifications#4. Best-effort: a failure (e.g. a notifier that can't react) is logged and never affects monitoring.

🤖 Generated with Claude Code

When a rule clears (its reading returns to the non-triggered side of the
threshold), add an emoji reaction — ✅ by default — to the
original alert message so operators get an at-a-glance "handled" marker
without a follow-up notification.

The monitor captures each alert's channel/ts from the notifier's send
response and, on the clearing edge, calls
DoCommand({"command": "react", ...}) on the notifier, then clears the stored
identity so it reacts exactly once. A cooldown re-send reacts to the latest
message. Requires a notifier that supports the react command and returns a
message ts (the viam:notifications:slack bot-token path); when no ts is
available (e.g. a Slack webhook) the step is silently skipped. Configurable
via resolve_reaction (set "-" to disable). Best-effort: failures are logged
and never affect monitoring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move resolve_reaction from the top-level config onto Rule, next to the
message it reacts to, and drop the default/disable sentinel: when a rule's
resolve_reaction is set the monitor reacts with that emoji on resolve, and
when it's unset nothing is added. Each rule opts in independently, and the
sensorMonitor no longer needs a resolveReaction field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… identity

Replace the Slack-specific msgChannel/msgTS fields on ruleState with a single
opaque sentMessage map holding the notifier's send response. On resolve the
monitor copies that response back and adds command/name, so it never has to
know how a notifier identifies a message. A test injects an opaque field into
the send response and asserts it is echoed verbatim on react.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rom Slack

Reword the sentMessage/sendNotification/sendResolveReaction comments to treat
the stored value as opaque message metadata rather than a notifier-specific
send response, make the test fake return an arbitrary opaque map instead of a
Slack-shaped ts/channel (folding the redundant echo test into the main one),
and drop the Slack bot-token / ts / webhook specifics from the README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant