Guest User

Home Assistant AI Mail Delivery Detection

a guest
Apr 14th, 2026
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.12 KB | None | 0 0
  1. ## configuration.yaml for creating a secondary cropped view off of a camera in home assistant
  2.  
  3. camera:
  4.   - platform: proxy
  5.     entity_id: camera.YOUR_MAIN_CAMERA_NAME
  6.     name: NAME OF NEW CAMERA CROPPED VIEW
  7.     mode: crop
  8.     image_top: 0
  9.     image_left: 3200
  10.     max_image_width: 1000
  11.     max_image_height: 500
  12.     max_stream_width: 1000
  13.     max_stream_height: 500
  14.  
  15. ## advanced automation YAML for saving time-based thumbnails of AI analysis images for notifications (look for ALL UPPERCASE items below for things to change for your own usage)
  16.  
  17. description: "HITECHLIFE: AI Vision Mail Delivery Detection"
  18. mode: single
  19. triggers:
  20.   - trigger: state
  21.     entity_id:
  22.      - binary_sensor.CAMERA_MOTION_TRIGGER
  23.     from:
  24.      - "off"
  25.     to:
  26.      - "on"
  27. conditions:
  28.   - condition: time
  29.     weekday:
  30.      - mon
  31.       - tue
  32.       - wed
  33.       - thu
  34.       - fri
  35.       - sat
  36. actions:
  37.   - variables:
  38.       snapshot_filename: "{{ now().strftime('%Y%m%d-%H%M%S') }}.jpg"
  39.   - action: camera.snapshot
  40.     metadata: {}
  41.     target:
  42.       entity_id:
  43.        - camera.CROPPED_CAMERA_NAME
  44.     data:
  45.       filename: /config/www/mailbox/{{ snapshot_filename }}
  46.   - action: ai_task.generate_data
  47.     metadata: {}
  48.     data:
  49.       task_name: Identify postal vehicle
  50.       entity_id: ai_task.google_ai_task
  51.       attachments:
  52.         media_content_id: media-source://camera/camera.CROPPED_CAMERA_NAME
  53.         media_content_type: image/jpeg
  54.         metadata:
  55.           title: CROPPED CAMERA FRIENDLY NAME
  56.           thumbnail: /api/camera_proxy/camera.CROPPED_CAMERA_NAME
  57.           media_class: video
  58.           children_media_class: null
  59.           navigateIds:
  60.            - {}
  61.             - media_content_type: app
  62.               media_content_id: media-source://camera
  63.       instructions: >-
  64.         Review this image and assess whether a United States Postal Service
  65.         vehicle is seen in front of the mailbox.  Provide a single word
  66.         response, and no other text.  Respond with 'true' if a postal vehicle is
  67.         seen, otherwise with 'false' for any other conditions.
  68.     response_variable: mailbox_assessment
  69.   - if:
  70.       - condition: template
  71.         value_template: "{{ mailbox_assessment.data | lower == 'true' }}"
  72.     then:
  73.       - action: notify.DEVICE_TO_NOTIFY
  74.         metadata: {}
  75.         data:
  76.           title: 📬 AI
  77.           message: >-
  78.             Mail delivery detected: {{ now().astimezone().strftime('%Y-%m-%d
  79.             %I:%M %p %Z') }}
  80.           data:
  81.             image: /local/mailbox/{{ snapshot_filename }}
  82.             url: /local/mailbox/{{ snapshot_filename }}
  83.             push:
  84.               sound: default
  85.   - action: persistent_notification.create
  86.     data:
  87.       notification_id: mailbox_{{ snapshot_filename }}
  88.       title: >-
  89.         {% if mailbox_assessment.data | lower == 'true' %} 📬 MAIL DETECTED — {{
  90.         now().strftime('%m/%d %I:%M %p') }} {% else %} 🚫 No Mail — {{
  91.         now().strftime('%m/%d %I:%M %p') }} {% endif %}
  92.       message: |-
  93.         **Result:** {{ mailbox_assessment.data }}
  94.         ![mailbox](/local/mailbox/{{ snapshot_filename }})
  95.  
Advertisement
Add Comment
Please, Sign In to add comment