SgtBatten / HA_blueprints

Somewhere to store automation blueprints
212 stars 80 forks source link

[Issue]: ordered_zones_match not working in a specific case #304

Open andilee7 opened 4 weeks ago

andilee7 commented 4 weeks ago

Description

In general the ordered_zones_match does exactly what I expect. But I have a specific video clip where nothing will be triggered. I have street, carport_outer and carport_inner zones. If something transitions from street to carport_outer i want the notification. Yesterday I came home by car and needed to park on the street zone because the trash can was blocking my path. So I went out of the car, car went stationary and a person was detected. I moved away the trash can, sat into the car and moved forward. Car was non-stationary again in the street zone and then in the carport_outer zone. No notification Then from the carport_inner zone I walked out into the street zone to get my trash can and transfered back into the carport_outer and then carport_inner. Also no notification from street to carport_outer. Going that path had always triggered the notification.

I'm a bit lost in what I should look at. I've exported the frigate clip and tried it in debug mode and played a bit with the stationary settings. Also when i increase my stationary threshold that the car is never tracked as stationary I got no notification

Not sure if I should upload the clip too.

image

Version

0.12.0.4o and tested with 0.12.0.4p too

Automation Config

alias: Test Cam Benachrichtigung
description: ""
trace:
  stored_traces: 100
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera:
      - camera.test
    notify_device: 7a349fcf43f6b8a9bb2572bc1a692a0f
    zone_filter: true
    zones:
      - test_street
      - test_carport_outer
    cooldown: 0
    debug: true
    zone_multi: true
    zone_order_enforced: true
    message: "{{ label }} detected - {{ camera_name }}"
    video: ""
    icon: mdi:cctv
    button_1: Video
    button_2: Bild
    button_3: Stummschalten
    sticky: true
    attachment: snapshot.jpg?bbox=1&crop=1
    update_thumbnail: true

Frigate Config

detectors:
  coral:
    type: edgetpu
    device: usb

mqtt:
  host: ***
  port: 8883
  user: ***
  password: ***
  tls_ca_certs: /mosquitto/cert/ca.pem
  tls_insecure: false

go2rtc:
  streams:
    carport:
      - ***

detect:
  # Optional: Configuration for stationary object tracking
  stationary:
    # Optional: Frequency for running detection on stationary objects (default: shown below)
    # When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame.
    # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s)
    # set interval to 5 frames. otherwise a temporary parking/stationary car on the street will remain stationary even tough it is already in the outer carport zone
    interval: 1
    threshold: 50 
    # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever)
    # This can help with false positives for objects that should only be stationary for a limited amount of time.
    # It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave
    # car at the default.
    # WARNING: Setting these values overrides default behavior and disables stationary object tracking.
    #          There are very few situations where you would want it disabled. It is NOT recommended to  
    #          copy these values from the example config into your config unless you know they are needed.
    # disable as due to config reference
    # max_frames:
    #   # Optional: Default for all object types (default: not set, track forever)
    #   default: 150 # stationary for 30 seconds
    #   # Optional: Object specific values
    #   #objects:
    #   #  person: 1000  
cameras:

  ############ TEST CAMERA ############

  test:
    ffmpeg:
      inputs:
        # - path: /media/frigate/exports/carport_448qbi.mp4 ## ich komme heim ohne erkannt zu werden
        # - path: /media/frigate/exports/carport_yr3z40.mp4 ## schneller postler bei tageslicht 
        # - path: /media/frigate/exports/carport_cozuk7.mp4 ## person im dunkeln
        # - path: /media/frigate/exports/carport_jwbzvn.mp4 ## auto heim im dunkeln
        # - path: /media/frigate/exports/carport_29y1ab.mp4 ## auto heim im dunklen 2
        # - path: /media/frigate/exports/carport_k69z2w.mp4 ## auto heim im dunkeln 3
        - path: /media/frigate/exports/carport_sfrq35.mp4 ## auto heim bei tageslicht nicht erkann
          input_args: -re -stream_loop -1 -fflags +genpts
          roles:
            - detect
    detect:
      width: 896
      height: 672
      fps: 15
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      retain:
        default: 28
    record:
      enabled: true
      retain:
        days: 28
        mode: motion
      events:
        #max_seconds: 600
        pre_capture: 2
        post_capture: 10
        retain:
          default: 28
          mode: motion
    motion:
      lightning_threshold: 0.9
      improve_contrast: true
      mask:
        - 512,45,512,10,880,10,880,45 #clock      
        - 0,0.101,0.219,0.046,0.316,0.031,0.369,0.026,0.458,0.047,0.539,0.069,0.543,0.182,0.61,0.2,0.61,0.113,0.613,0.058,0.636,0,0,0
        - 896,500,896,86,654,42,663,100,725,123,698,345 # tuer-glasscheibe wegen reflexionen und innenlicht + wand wegen schattenspiel        
    objects:
      track:
        - person
        - dog
        - cat
        - bicycle
        - motorcycle
        - car
      filters:
        person:
          threshold: 0.5
          min_area: 750
          max_area: 100000
          mask:
            - 0,504,42,387,187,395,204,494,173,672,0,672 #back window of skoda will often detect as person
            - 795,672,717,520,624,419,534,356,457,436,535,672 #back window of dacia will often detect as person
        dog:
          threshold: 0.5
        cat:
          threshold: 0.5
        car:
          min_area: 1000 #to avoid neighbors parking car
          mask:                             #dont detect cars in the area where cars are parking
            - 1,0.491,0,0.487,0,1,1,1
            - 0.512,0.121,0.506,0.192,0.618,0.19,0.616,0.094
        motorcycle:
          min_area: 1000 #to avoid neighbors parking car
          mask: 896,330,0,327,0,672,896,672 #dont detect false motorcycles in the area where cars are parking
    zones:
      test_street:
        coordinates: 
          0,0.199,0,0,0.62,0,0.612,0.224,0.451,0.184,0.372,0.176,0.26,0.202,0.056,0.233,0.044,0.194
        inertia: 1
        loitering_time: 0
      test_carport_outer:
        coordinates: 
          0,0.459,0.608,0.434,0.607,0.316,0.607,0.225,0.474,0.19,0.365,0.179,0.269,0.204,0.058,0.235,0.042,0.197,0,0.2
        inertia: 1
        loitering_time: 0
      test_carport_inner:
        coordinates: 0,1,1,1,1,0,0.621,0,0.606,0.437,0,0.462
        inertia: 3
        loitering_time: 0
    review:
      alerts:
        required_zones: test_carport_outer

  ############ TEST CAMERA ############

logger:
  default: info
  logs:
    frigate.mqtt: error

# Optional: birdseye configuration
birdseye:
  # Optional: Enable birdseye view (default: shown below)
  enabled: true
  # Optional: Width of the output resolution (default: shown below)
  width: 1280
  # Optional: Height of the output resolution (default: shown below)
  height: 720
  # Optional: Encoding quality of the mpeg1 feed (default: shown below)
  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 8
  # Optional: Mode of the view. Available options are: objects, motion, and continuous
  #   objects - cameras are included if they have had a tracked object within the last 30 seconds
  #   motion - cameras are included if motion was detected in the last 30 seconds
  #   continuous - all cameras are included always
  mode: continuous
version: 0.14
camera_groups:
  Carport:
    order: 1
    icon: LuWebhook
    cameras: carport

Any other relevant information

No response

SgtBatten commented 3 weeks ago

it makes sense that the initial notification is bypassed because both zones were not true. so that bit is not relevant. need to look at the loop. and the debug outputs.

andilee7 commented 3 weeks ago

Why does it make sense that the initial car is bypassed? After it was stationary it went to not-stationary in the street zone and passed into the second carport_outer zone. I would love to provide the loop and the debug output, but the stranges thing is that every single Trace looks like the screenshot above. It never went into the automation logic

SgtBatten commented 3 weeks ago

Why does it make sense that the initial car is bypassed?

because the automation starts the moment the object is detected, regardless of zones.

So unless the zones condition is met in the first mqtt message, it makes sense the initial notification is bypassed.

The loop takes care of all follow up notifications after the event has started. This chanfges with frigate reviews in 0.14 where frigate waits until the conditions are met (as configured by you in frigate) before sending the mqtt message