8000 feat(automations): sensor readings, alert patterns and new devices as activities by adeelahmad · Pull Request #445 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): sensor readings, alert patterns and new devices as activities - #445

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-cyhjct
Oct 16, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-cyhjct

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Description

Before: automations and the activity timeline could not see sensors at all.

After: three new activity kinds. sensor.reading is a reading a sensor keeps (sensors set to store all or changes), marked noisy so it stays out of the timeline unless asked for, and a follower that names its sensors (hint: {"actors": ["lens:sensor/<id>"]}) reads only those. sensor.alert is raised once per pattern per hour when a log pattern labelled alert or notable shows up (not for paused sensors or labels the model wasn't sure of). sensor.joined is a device that discovery found reporting for the first time. Each is for admins unless the sensor belongs to one namespace.

How: a sensor_readings source reads each sensor's readings over its (sensor, at) index, a sensors source reads discovered sensors, and the intake logs the alert with a per-pattern-hour key so several processes raise it once. The timeline now breaks ties on published by each source's own position, so readings within one second keep their order.

Motivation and Context

Workflow Studio M3 (plan section 3): sensors as triggers for automations.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests. (tests/domain/test_events_streams.py, embedded and SurrealDB server)
  • My change requires documentation updates, and I have updated docs/ accordingly. (docs/automations.md, docs/sensors.md)
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md. n/a: the title says it.

Done questions (AGENTS.md)

  • Goal: sensors become activities automations can trigger on; merged on green CI.
  • Agents: activities are read through the events API and MCP like every other kind.
  • Zero setup: nothing to install or configure.
  • Fewest clicks and keystrokes: n/a, no new UI.
  • Configurable: n/a, no new settings; which sensors store readings and pattern labels are already in the web app.
  • Light: readings are read lazily over an index, one sensor at a time; no new service.
  • Private and secure: readings and log text are marked untrusted; threat model row for MQTT/syslog updated.
  • Cost: no model calls; alerts reuse the pattern labels already made.
  • User decides: only patterns the user (or a sure model) labelled alert/notable raise alerts; defaults unchanged.
  • Upgrades: two new indexes defined at start-up with IF NOT EXISTS; safe to run twice.
  • Honest: docs label the kinds built and list what to refine later.
  • Tests, docs and generated files updated (no API shape change, so no OpenAPI change).
  • Open standards: W3C Activity Streams 2.0; no new dependencies.
  • Result reported with evidence; "refine later" items in docs/automations.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QewNs6jxSB2vRoag2EvdyX


Generated by Claude Code

… activities

sensor.reading (noisy) reads the readings a sensor keeps, one sensor at a time
over the (sensor, at) index and only the sensors a follower's hint names;
sensor.alert is raised by the intake once per pattern per hour for patterns
labelled alert or notable; sensor.joined reads sensors discovery made. The
timeline breaks published ties by each source's own position.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QewNs6jxSB2vRoag2EvdyX
@adeelahmad
adeelahmad merged commit 781a47a into main Oct 16, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-cyhjct branch October 16, 2026 00:05
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

0