# 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 # Minimum Python version required runtime_version: ">=3.9" # 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