All schemas (parameters, output, output_schema, conf_schema) now use the
StackStorm-style flat format expected by Attune:
{ param_name: { type, description, required, secret, ... } }
Instead of the standard JSON Schema format:
{ type: object, properties: { ... }, required: [...] }
Also fix rule template syntax: trigger.payload.* -> event.payload.*
74 lines
2.2 KiB
YAML
74 lines
2.2 KiB
YAML
# Counter Sensor
|
|
# Emits incrementing counter events, storing state in the Attune keystore
|
|
#
|
|
# Each subscribing rule gets its own independent counter, keyed by rule ref.
|
|
# The sensor listens for rule lifecycle events via RabbitMQ and manages
|
|
# per-rule timer loops that emit one event per second (configurable).
|
|
|
|
ref: python_example.counter_sensor
|
|
label: "Counter Sensor"
|
|
description: "Emits periodic counter events with per-rule state stored in the Attune keystore"
|
|
enabled: true
|
|
|
|
# Sensor runner type
|
|
runner_type: python
|
|
|
|
# Entry point for sensor execution
|
|
entry_point: counter_sensor.py
|
|
|
|
# Trigger types this sensor monitors
|
|
trigger_types:
|
|
- python_example.counter
|
|
|
|
# Sensor configuration schema (flat format with inline required/secret)
|
|
parameters:
|
|
default_interval_seconds:
|
|
type: integer
|
|
description: "Default interval between counter emissions (in seconds)"
|
|
default: 1
|
|
minimum: 1
|
|
maximum: 3600
|
|
key_prefix:
|
|
type: string
|
|
description: "Prefix for counter keys in the Attune keystore"
|
|
default: "python_example.counter"
|
|
|
|
# Poll interval (how often the sensor checks for events)
|
|
poll_interval: 1
|
|
|
|
# Tags for categorization
|
|
tags:
|
|
- counter
|
|
- python
|
|
- example
|
|
- keystore
|
|
|
|
# Metadata
|
|
meta:
|
|
builtin: false
|
|
system: false
|
|
description: |
|
|
The counter sensor demonstrates a stateful Python sensor that integrates
|
|
with the Attune keystore. It maintains a separate monotonically-increasing
|
|
counter for each subscribing rule, persisting the value in the keystore
|
|
so that counters survive sensor restarts.
|
|
|
|
Features exercised:
|
|
- Python sensor lifecycle (startup, rule subscription, shutdown)
|
|
- RabbitMQ integration for rule lifecycle events
|
|
- Attune keystore API for persistent state (GET/PUT/POST /api/v1/keys)
|
|
- Per-rule scoped state via keystore key naming
|
|
- Periodic event emission via POST /events API
|
|
- Graceful shutdown with thread cleanup
|
|
|
|
# Documentation
|
|
examples:
|
|
- description: "Counter firing every second (default)"
|
|
trigger_type: python_example.counter
|
|
trigger_config: {}
|
|
|
|
- description: "Counter firing every 5 seconds"
|
|
trigger_type: python_example.counter
|
|
trigger_config:
|
|
interval_seconds: 5
|