service:
  name: ha-diag-agent
  # Deployed per-host: piha (site: ken) and chelsty-infra (site: chelsty)
  owner_node: per-host
  exposure: local-only
  monitor: true

  dependencies:
    - homeassistant

  healthcheck:
    type: http
    path: /health
    interval: 30s
    timeout: 10s
    retries: 3
    start_period: 20s

  restart_policy: unless-stopped

  persistence:
    paths:
      - /opt/homelab/events
      - /var/lib/ha-diag-agent

  runtime:
    env_vars:
      - HA_TOKEN                          # long-lived HA access token (required)
      - HA_URL                            # http://homeassistant.local:8123
      - NODE_NAME                         # canonical node name: piha, chelsty-infra
      - LOCATION_TAG                      # human site label: ken, chelsty
      - CHECK_INTERVAL                    # heartbeat interval seconds (default: 60)
      - CHECK_INTERVAL_UNAVAILABLE        # entity check interval seconds (default: 3600)
      - UNAVAILABLE_THRESHOLD_HOURS       # alert threshold (default: 24)
      - INTEGRATION_FAILURE_THRESHOLD_PCT # fraction threshold (default: 0.5)
      - INTEGRATION_FAILURE_MIN_ENTITIES  # min count for integration event (default: 3)
      - ALERT_COOLDOWN_HOURS              # re-alert suppression (default: 6)
      - PORT                              # FastAPI port (default: 8087)
      - LOG_LEVEL                         # default: info
