# example_9_3_1.yaml
image_processing:
  - platform: dlib_face_identify
    scan_interval: 1000000
    source:
      - entity_id: camera.cam_input
        name: face_id
    faces:
      Trump: /home/pi/Pictures/trump.jpg
      Obama: /home/pi/Pictures/obama.jpg
      Clinton: /home/pi/Pictures/clinton.jpg
script:
  dlib_face_identify:
    alias: 人脸识别
    sequence:
      - service: image_processing.scan
        data:
          entity_id: image_processing.face_id
      # - service: camera.snapshot
        # data:
          # entity_id: camera.cam_input
          # filename: '/home/pi/Pictures/face.jpg'
# camera:
  # - platform: local_file
    # name: image_to_be_processed
    # file_path: /home/pi/Pictures/face.jpg

automation:
  - alias: Clinton coming
    trigger:
      platform: event
      event_type: image_processing.detect_face
      event_data:
        entity_id: image_processing.face_id
        name: 'Clinton'
    action:
      service: persistent_notification.create
      data:
        title: '发现认识的人'
        message: '克林顿出现在屏幕上'
  - alias: Obama coming
    trigger:
      platform: event
      event_type: image_processing.detect_face
      event_data:
        entity_id: image_processing.face_id
        name: 'Obama'
    action:
      service: persistent_notification.create
      data:
        title: '发现认识的人'
        message: '奥巴马出现在屏幕上'
  - alias: Trump coming
    trigger:
      platform: event
      event_type: image_processing.detect_face
      event_data:
        entity_id: image_processing.face_id
        name: 'Trump'
    action:
      service: persistent_notification.create
      data:
        title: '发现认识的人'
        message: '川普出现在屏幕上'
