  - alias: 'AI overvågning'
    trigger:
      platform: state
      entity_id: binary_sensor.indkorsel_sensor_motion
      to: 'on'
    conditions:
      - condition: template
        value_template: >-
          {% set last = state_attr('automation.ai_overvagning', 'last_triggered') %}
          {% set someone_home = is_state('binary_sensor.family_presence', 'on') %}
          {{ not someone_home or last is none or (now() - last).total_seconds() > 900 }}
      - condition: not
        conditions:
          - condition: state
            entity_id: vacuum.roborock_s8_pro_ultra
            state:
              - cleaning
              - returning
    actions:
      - action: script.overvaagning
        metadata: {}
        data: {}
    mode: single
