SgtBatten / HA_blueprints

Somewhere to store automation blueprints
212 stars 80 forks source link

Notification snapshots are not showing up #276

Open JoshuaSeidel opened 2 months ago

JoshuaSeidel commented 2 months ago

Describe the problem you are having or the outcome you are trying to achieve.

Recently after I tried changing the URL to the home assistant app I changed it back and now everytime I get a notification the snapshot shows, can not show image 404

Version

0.12.0.4d

Automation config

alias:%20Driveway%20Notifications%0Adescription%3A%20%22%22%0Ause_blueprint%3A%0A%20%20path%3A%20SgtBatten/Stable.yaml%0A%20%20input:%0A%20%20%20%20camera:%20camera.driveway%0A%20%20%20%20notify_device:%200fce7692dbc619c242f66452044447da%0A%20%20%20%20alert_once:%20true%0A%20%20%20%20attachment:%20snapshot.jpg?bbox=1%0A%20%20%20%20update_thumbnail:%20true%0A%20%20%20%20video:%20%3E-%0A%20%20%20%20%20%20%7B%7Bbase_url%7D%7D/api/frigate%7B%7Bclient_id%7D%7D/notifications/%7B%7Bid%7D%7D/%7B%7Bcamera%7D%7D/clip.mp4%0A%20%20%20%20ios_live_view:%20camera.driveway%0A%20%20%20%20labels:%0A%20%20%20%20%20%20-%20person%0A%20%20%20%20%20%20-%20car%0A%20%20%20%20disable_times:%0A%20%20%20%20%20%20-%20%2221%22%0A%20%20%20%20%20%20-%20%2220%22%0A%20%20%20%20title:%20Home%20Alert%0A%20%20%20%20silence_timer:%205%0A%20%20%20%20icon:%20%3E-%0A%20%20%20%20%20%20mdi:%7B%7B'account-outline'%20if%20label%20==%20'Person'%20else%20'dog'%20if%20label%20==%20'Dog'%0A%20%20%20%20%20%20else%20'cat'%20if%20label%20==%20'Cat'%20else%20'car'%20if%20label%20==%20'Car'%20else%0A%20%20%20%20%20%20'home-assistant'%7D%7D%0A%20%20%20%20zone_filter:%20true%0A%20%20%20%20zones:%0A%20%20%20%20%20%20-%20driveway-parking%0A%20%20%20%20cooldown:%2090%0A%20%20%20%20custom_filter:%20%3E-%0A%20%20%20%20%20%20%7B%25%20if%20is_state(%22sensor.driveway_ptz_pan_position%22,%20%22997%22)%20-%25%7D%20true%20%7B%25-%0A%20%20%20%20%20%20else%20-%25%7D%20false%20%7B%25-%20endif%20%25%7D%0A%20%20%20%20tap_action:%20%3E-%0A%20%20%20%20%20%20%7B%7Bbase_url%7D%7D/api/frigate%7B%7Bclient_id%7D%7D/notifications/%7B%7Bid%7D%7D/%7B%7Bcamera%7D%7D/clip.mp4%0A%20%20%20%20initial_delay:%200%0A%20%20%20%20debug:%20true%0A

Frigate Config

mqtt:
  enabled: true
  user: frigate_mqtt
  password: hhh
  host: 192.168.7.83

ffmpeg:
  hwaccel_args: preset-vaapi
 # input_args: preset-rtsp-stream
  #output_args:
   # record: preset-record-generic-audio-copy

cameras:
  steps_cam: # <------ Name the camera
    enabled: true
    audio:
      enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://wb:cCa3gT-hhh@192.168.9.144:8544/steps-cam # <----- The stream you want to use for detection
          roles:
            - record
            - detect
            - audio
      output_args:
        record: preset-record-generic-audio-copy
    objects:
      track:
        - dog
        - person
    review:
      detections:
        labels:
          - dog
          - person
        required_zones: steps
    zones:
      steps:
        coordinates: 0.412,0.006,0.222,1,0.824,1,0.578,0.009
        loitering_time: 0
    motion:
      mask: 0.723,0.938,0.974,0.933,0.976,0.98,0.723,0.979

  doorbell:
    enabled: true
    audio:
      enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/doorbell?video=copy&audio=aac
          input_args: preset-rtsp-restream-low-latency
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/doorbell_sub?video=copy&audio=aac
          input_args: preset-rtsp-restream-low-latency
          roles:
            - detect
            - audio
      output_args:
        record: preset-record-generic-audio-copy
    objects:
      track:
        - dog
        - person
        - car
        - motorcycle
        - cat
        - bicycle
        - fedex
        - ups
        - amazon
        - face
        - package
        - license_plate
    review:
      detections:
        labels:
          - dog
          - person
      alerts:
        required_zones:
          - Porch
          - sidewalk
    zones:
      Porch:
        coordinates: 
          0.381,0.999,0.384,0.961,0.47,0.969,0.473,0.908,0.723,0.866,0.73,0.874,0.875,0.801,0.999,0.881,0.999,0.999
        loitering_time: 0
        objects:
          - package
          - person
          - dog
          - cat
        inertia: 3
      sidewalk:
        coordinates: 
          0.57,0.897,0.584,0.791,0.624,0.758,0.67,0.74,0.706,0.724,0.698,0.78,0.696,0.82,0.694,0.866
        loitering_time: 0
        objects:
          - dog
          - person
  driveway:
    enabled: true
    audio:
      enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/driveway?video=copy&audio=aac
          input_args: preset-rtsp-restream-low-latency
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/driveway_sub?video=copy&audio=aac
          input_args: preset-rtsp-restream-low-latency
          roles:
            - detect
            - audio
      output_args:
        record: preset-record-generic-audio-copy
    objects:
      track:
        - dog
        - person
        - car
        - motorcycle
        - cat
        - bicycle
        - fedex
        - ups
        - amazon
        - face
        - package
        - license_plate
      filters:
        car:
          mask: 0.726,0,0.717,0.057,0.846,0.091,0.828,0,0.798,0
    review:
      detections:
        labels:
          - dog
          - person
          - car
          - motorcycle
    #onvif:
    #  host: 192.168.9.4
    #  port: 8000
    #  user: admin
    #  password: hhh
    #  autotracking:
    #    enabled: false
    #    calibrate_on_startup: false
    #    zooming: absolute
    #    zoom_factor: 0.3
    #    track:
    #      - person
    #      - car
    #    return_preset: home
    #    timeout: 10
    #    required_zones:
    #      - complete
        required_zones: complete
      alerts:
        required_zones: driveway-parking
    zones:
      complete:
        coordinates: 
          0.077,0.208,0.105,0.184,0.207,0.109,0.334,0.05,0.452,0.036,0.561,0.067,0.718,0.129,0.846,0.202,0.916,0.261,1,0.344,0.999,0.347,0.997,0.994,0.221,1,0.16,0.848
        loitering_time: 0
        inertia: 3
      driveway-parking:
        coordinates: 0.118,0.47,0.259,0.339,0.27,0.352,0.345,0.33,0.732,0.852,0.686,0.996,0.222,0.997
        loitering_time: 5
        objects:
          - person
          - motorcycle
          - car
        inertia: 3
    motion:
      threshold: 40
      contour_area: 20
      improve_contrast: true
      mask: 0.583,0.933,0.988,0.931,0.989,0.971,0.585,0.974
version: 0.14

go2rtc:
  streams:
    steps_Cam:
      - rtsp://wb:cCa3gT-hhh@192.168.9.144:8544/steps-cam
#      - ffmpeg:rtsp_cam#audio=opus
    #- rtsp://192.168.9.94:44795/aeb8b8fcf5232662
    doorbell:
      #- rtsp://admin:hhh@192.168.9.127:554/h264Preview_01_main#backchannel=0
      #- ffmpeg:http://192.168.9.127/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=hhh#video=copy#audio=copy#audio=opus
      #- rtsp://admin:hhh@192.168.9.127:554/Preview_01_sub
      - ffmpeg:rtsp://192.168.9.94:41733/b95d639deb29775d#rtsp_transport=tcp
      #- ffmpeg:doorbell#audio=opus#hardware
      - exec:/config/neolink/neolink_talk.sh#backchannel=1
    doorbell_sub:
      - ffmpeg:rtsp://192.168.9.94:41733/d8d1d597d389af24#rtsp_transport=tcp
      #- ffmpeg:http://192.168.9.127/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=hhh
      #- exec:/config/neolink/neolink_talk.sh#backchannel=1
      #- rtsp://admin:hhh@192.168.9.127:554/h264Preview_01_sub
      #- ffmpeg:doorbell_sub#audio=opus#hardware
    driveway:
      #- ffmpeg:http://192.168.9.4/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=hhh#video=copy#audio=copy#audio=opus
      - ffmpeg:rtsp://nvr:hhh@192.168.9.4:554/h264Preview_01_main#video=copy#audio=copy#audio=opus
      #- ffmpeg:rtsp://192.168.9.94:46275/ccad6ad377527f4e#rtsp_transport=tcp
      #- ffmpeg:doorbell#audio=opus#hardware
      #- exec:/config/neolink/neolink_talk.sh#backchannel=1
    driveway_sub:
      #- ffmpeg:http://192.168.9.4/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=hhh
      #- exec:/config/neolink/neolink_talk.sh#backchannel=1
     # - ffmpeg:rtsp://192.168.9.94:46275/3177b7e6fc5c8833#rtsp_transport=tcp
      - ffmpeg:rtsp://nvr:hhh@192.168.9.4:554/h264Preview_01_sub
      #- ffmpeg:doorbell_sub#audio=opus#hardware
#    doorbell_snapshot:
#      - onvif://admin:hhh@192.168.9.127:8000?subtype=MediaProfile00000&snapshot
  webrtc:
    candidates:
      - 192.168.9.94:8555
      - stun:8555
  ffmpeg:
    bin: ffmpeg
    volume: -af "volume=30dB"

detectors:
  coral:
    type: edgetpu
    device: pci

model:
  path: plus://

review:
  alerts:
    labels:
      - person
      - dog
      - car
  detections:
    labels:
      - person
      - dog
      - car

record:
  enabled: true
  retain:
    days: 7
    mode: motion

audio:
  enabled: true
  listen:
    - bark
    - fire_alarm
    - scream
    - speech
    - yell

detect:
  enabled: true # <---- disable detection until you have a working camera feed
  width: 800
  height: 480
  stationary:
    interval: 50
    threshold: 50

birdseye:
  enabled: true
  mode: continuous #motion #objects

snapshots:
  enabled: true
  timestamp: true
  bounding_box: true
  retain:
    default: 30

tls:
  enabled: true

objects:
  filters:
    dog:
      min_score: .7
      threshold: .9
    face:
      min_score: .7
    package:
      min_score: .65
      threshold: .9
    license_plate:
      min_score: .6
    amazon:
      min_score: .75
    ups:
      min_score: .75
    fedex:
      min_score: .75
    person:
      min_score: .65
      threshold: .85
    car:
      min_score: .65
      threshold: .85

# Include all cameras by default in Birdseye view

Any other information that may be helpful

Frigate Notification DEBUG (in loop): Send Notification: False Info: sublabel: None, image: "/api/frigate/notifications/1725655178.526155-by5fif/snapshot.jpg?bbox=1" Title: Home Alert message: A Car was detected on the Driveway camera. iOS sound: disabled by alert once, Android Sound: disabled by alert once, iOS url: /api/frigate/notifications/1725655178.526155-by5fif/snapshot.jpg?bbox=1 video: "/api/frigate/notifications/1725655178.526155-by5fif/driveway/clip.mp4" critical: False, Triggers: New Snapshot: False Presence Changed: False, Stationary Moved: False, Entered Zones Changed: False, sublabel changed: False, Conditions: Loitering: 0 or Filters: Zones: Zone Filter Enabled: True, Multi Zone Enabled: False, Required Zones: ['driveway-parking'], Last Zones: [], Entered zones: 0 - [], TEST: FAIL, Object Filter: Input: ['person', 'car'], TEST: PASS, Presence entity (not home): Entity: , TEST: PASS, Time Filter: Disabled times: ['21', '20'], TEST: PASS State Filter: state filter toggle on: False, state filter entity: , required states: [], TEST: PASS, Custom Filter: PASS, triggered by automation Driveway Notifications mqtt topic frigate/events 4:40:09 PM - Now Frigate Notification DEBUG (in loop): Send Notification: False Info: sublabel: None, image: "/api/frigate/notifications/1725655178.526155-by5fif/snapshot.jpg?bbox=1" Title: Home Alert message: A Car was detected on the Driveway camera. iOS sound: disabled by alert once, Android Sound: disabled by alert once, iOS url: /api/frigate/notifications/1725655178.526155-by5fif/snapshot.jpg?bbox=1 video: "/api/frigate/notifications/1725655178.526155-by5fif/driveway/clip.mp4" critical: False, Triggers: New Snapshot: False Presence Changed: False, Stationary Moved: False, Entered Zones Changed: False, sublabel changed: False, Conditions: Loitering: 0 or Filters: Zones: Zone Filter Enabled: True, Multi Zone Enabled: False, Required Zones: ['driveway-parking'], Last Zones: [], Entered zones: 0 - [], TEST: FAIL, Object Filter: Input: ['person', 'car'], TEST: PASS, Presence entity (not home): Entity: , TEST: PASS, Time Filter: Disabled times: ['21', '20'], TEST: PASS State Filter: state filter toggle on: False, state filter entity: , required states: [], TEST: PASS, Custom Filter: PASS, triggered by automation Driveway Notifications mqtt topic frigate/events 4:40:09 PM - Now Frigate

SgtBatten commented 2 months ago

Recently after I tried changing the URL to the home assistant app I changed it back

I dont know what you are talking about here. SOunds liek this is the issue though if that's what made it stop working.

Have you tried setting a base url in the automation?

If you need more responses, please fix the format of the automation yaml. go to automations, edit in yaml mode and copy the contents.

JoshuaSeidel commented 2 months ago

alias: Driveway Notifications
description: ""
use_blueprint:
  path: SgtBatten/Stable.yaml
  input:
    camera: camera.driveway
    notify_device: 0fce7692dbc619c242f66452044447da
    alert_once: true
    attachment: snapshot.jpg?bbox=1
    update_thumbnail: true
    video: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    ios_live_view: camera.driveway
    labels:
      - person
      - car
    disable_times:
      - "21"
      - "20"
    title: Home Alert
    silence_timer: 5
    icon: >-
      mdi:{{'account-outline' if label == 'Person' else 'dog' if label == 'Dog'
      else 'cat' if label == 'Cat' else 'car' if label == 'Car' else
      'home-assistant'}}
    zone_filter: true
    zones:
      - driveway-parking
    cooldown: 90
    custom_filter: >-
      {% if is_state("sensor.driveway_ptz_pan_position", "997") -%} true {%-
      else -%} false {%- endif %}
    tap_action: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    initial_delay: 0
    debug: true
    base_url: https://ha.redacted.com
JoshuaSeidel commented 2 months ago

After I put the base URL in, there is no error but there is also no more thumbnail

SgtBatten commented 2 months ago

Try disabling wifi and let me know if that makes a difference

blueharford commented 2 months ago

Try disabling wifi and let me know if that makes a difference

Nope no difference

blueharford commented 2 months ago

IMG_3627

SgtBatten commented 2 months ago

404 says the url is not accessible.

So please confirm you can access BASE URL HERE/api/frigate/notifications/1725655178.526155-by5fif/snapshot.jpg

JoshuaSeidel commented 2 months ago

Confirmed the url opens a snapshot

SgtBatten commented 2 months ago

Not sure then, something is blocked between your HA instance and your phone. maybe reinstall the app. but I don;t knwo what I can do if it's not the wifi issue everyone on IOS is having

schmuy commented 2 months ago

I'm having the same issue. I updated from blueprint 0.12.0.2 to 0.12.0.4 and now attachments don't show in notification. If I click on "view snapshot" in notification it shows the snapshot just fine in the browser.

JoshuaSeidel commented 2 months ago

The only way I can get it to work is if I disable clips. It doesn't like it when I do some nail or snapshot and clip.

SgtBatten commented 2 months ago

I'm having the same issue. I updated from blueprint 0.12.0.2 to 0.12.0.4 and now attachments don't show in notification. If I click on "view snapshot" in notification it shows the snapshot just fine in the browser.

please go back to 0.12.0.2 and test again. As far as i've investigated this the snapshot code is unchanged between these versions.

SgtBatten commented 2 months ago

The only way I can get it to work is if I disable clips. It doesn't like it when I do some nail or snapshot and clip.

IOS is a pain in my butt

JoshuaSeidel commented 2 months ago

Tell me about it, I switched from a house full of Ring to Reolink with frigate. All works good but notifications. I can see logs in logbook that when I went out back I wasn't in zone. Did a debug and it shows me in zone.

I know this blueprint is taking data from mqtt, I know a bunch is iOS too. I have alot of Apple products or id give android another go.

SgtBatten commented 2 months ago

zones kinda suck for the blueprint and always have, especially if you don;t use update snapshot or if the target object isn't moving closer to camera.

It's much better in 0.14 using the blueprint in #216 because we are using frigate to determine if it is an alert or detection or not and only then does a reviews mqtt message get sent.

schmuy commented 2 months ago

I'm having the same issue. I updated from blueprint 0.12.0.2 to 0.12.0.4 and now attachments don't show in notification. If I click on "view snapshot" in notification it shows the snapshot just fine in the browser.

please go back to 0.12.0.2 and test again. As far as i've investigated this the snapshot code is unchanged between these versions.

Before I saw this I ended up messing around with the configuration of the blueprint, removing and re-adding setting values. I did not have a base URL before with 0.12.0.2, but I added it into 0.12.0.4. It seems to be working consistently again on 0.12.0.4 with whatever I did. Thanks for the quick response.