# Timer Sensor
# Monitors time and fires all timer trigger types

ref: core.interval_timer_sensor
label: "Interval Timer Sensor"
description: "Built-in sensor that monitors time and fires timer triggers (interval, cron, and one-shot datetime)"
enabled: true

# Sensor runner type
runner_type: native

# Entry point for sensor execution
entry_point: attune-core-timer-sensor

# Trigger types this sensor monitors
trigger_types:
  - core.intervaltimer
  - core.crontimer
  - core.datetimetimer

# Sensor configuration schema (StackStorm-style flat format)
parameters:
  check_interval_seconds:
    type: integer
    description: "How often to check if triggers should fire (in seconds)"
    default: 1
    minimum: 1
    maximum: 60

# Poll interval (how often the sensor checks for events)
poll_interval: 1

# Tags for categorization
tags:
  - timer
  - interval
  - system
  - builtin

# Metadata
meta:
  builtin: true
  system: true
  description: |
    The timer sensor is a built-in system sensor that monitors all timer-based
    triggers and fires events according to their schedules. It supports three
    timer types:

    1. Interval timers: Fire at regular intervals (seconds, minutes, hours, days)
    2. Cron timers: Fire based on cron schedule expressions (e.g., "0 0 * * * *")
    3. DateTime timers: Fire once at a specific date and time (one-shot)

    This sensor uses tokio-cron-scheduler for efficient async scheduling and
    runs continuously as part of the Attune sensor service.

# Documentation
examples:
  - description: "Interval timer - fires every 10 seconds"
    trigger_type: core.intervaltimer
    trigger_config:
      unit: "seconds"
      interval: 10

  - description: "Interval timer - fire every 5 minutes"
    trigger_type: core.intervaltimer
    trigger_config:
      unit: "minutes"
      interval: 5

  - description: "Cron timer - fire every hour on the hour"
    trigger_type: core.crontimer
    trigger_config:
      expression: "0 0 * * * *"

  - description: "Cron timer - fire every weekday at 9 AM"
    trigger_type: core.crontimer
    trigger_config:
      expression: "0 0 9 * * 1-5"
      timezone: "UTC"

  - description: "DateTime timer - fire once at specific time"
    trigger_type: core.datetimetimer
    trigger_config:
      fire_at: "2024-12-31T23:59:59Z"
      timezone: "UTC"
