SgtBatten / HA_blueprints

Somewhere to store automation blueprints
151 stars 55 forks source link

[Issue]: Restricting events notifications to specific zones not working #188

Closed asemev closed 3 months ago

asemev commented 3 months ago

Description

My issue might be the same as #185 but i'm not sure, so i wanted to post it here anyways.

image image image image image

Thank you very much!

Version

0.12.0.2

Automation Config

alias: Frigate - Door Person
description: ""
use_blueprint:
  path: SgtBatten/Stable.yaml
  input:
    camera: camera.door
    notify_device: e00c1c0945954b1f084708607893d66f
    zones:
      - zone_0
    labels:
      - person
    cooldown: 10
    silence_timer: 10

Frigate Config

detectors:
  coral:
    type: edgetpu
    device: 'usb'
    num_threads: 4
mqtt:
  host: 
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user:
  password: 
#ffmpeg:
#  hwaccel_args:
#    - '-c:v'
#    - h264_v4l2m2m

#ffmpeg:
#  hwaccel_args: preset-rpi-64-h264

cameras:
#  Garage:
#    ffmpeg:
#      inputs:
#        - path: 'rtsp://
#          global_args: '-hide_banner -loglevel error'
#          roles:
#            - detect
#            - record
#    detect:
#     width: 1920
#      height: 1080
#      fps: 5
#    motion:
#      mask: >-
#        -0,0,1920,0,1920,1080,1490,1080,1659,694,690,270,121,417,345,1080,0,1080
#    snapshots:
#      enabled: true
#      timestamp: true
#      bounding_box: true
#      crop: false
#      height: 175
#      retain:
#        default: 10
#        objects:
#          person: 10
#    mqtt:
#      enabled: true
#      timestamp: true
#      bounding_box: true
#      crop: true
#      height: 270
#    objects:
#      track:
#        - person
#
#      filters:
#        person:
#          min_area: 5000
#          max_area: 100000
#          min_score: 0.5
#          threshold: 0.7
#          mask: >-
#            -2,1,1920,0,1920,1080,1490,1080,1678,653,547,227,533,73,354,86,370,292,116,340,285,1012,680,1014,678,1080,0,1080
#    zones:
#      car:
#        coordinates: 343,1058,1477,1080,1654,683,776,252,123,394
#    record:
#      enabled: true
#      retain: 
#        days: 3
#        mode: motion 
#      events:
#        retain:
#          default: 3
#          mode: active_objects

  Package:
    ffmpeg:
      inputs:
        - path: 
          global_args: '-hide_banner -loglevel error'
          roles:
            - detect
            - record
    detect:
      width: 1920
      height: 1080
      fps: 5
    motion:
      mask:
        - 0,1080,1920,1080,1350,547,1408,891,1081,899,1105,544,1307,523,1920,1080,1920,0,0,0

    snapshots:
      enabled: true
      timestamp: true
      bounding_box: true
      crop: false
      height: 175
      retain:
        default: 10
        objects:
          person: 10

    mqtt:
      enabled: true
      timestamp: true
      bounding_box: true
      crop: true
      height: 270
    objects:
      track:
        - person

    zones:
      box:
        coordinates: 1128,888,1408,891,1356,564,1073,535
    record:
      enabled: true
      retain: 
        days: 3
        mode: motion 
      events:
        retain:
          default: 3
          mode: active_objects

  Door:
    ffmpeg:
      inputs:
        - path: 
          global_args: '-hide_banner -loglevel error'
          roles:
            - detect
            - record
    detect:
      width: 1920
      height: 1080
      fps: 5
    motion:
    record:
      enabled: true
      retain: 
        days: 10
        mode: motion 
      events:
        required_zones:
          - entire_yard
        retain:
          default: 10
          mode: active_objects
    snapshots:
      required_zones:
        - zone_0
      enabled: true
      timestamp: true
      bounding_box: true
      crop: false
      height: 175
      retain:
        default: 10
        objects:
          person: 10
    mqtt:
      enabled: true
      timestamp: true
      bounding_box: true
      crop: true
      height: 270
    objects:
      track:
        - person
    zones:
      zone_0:
        coordinates: 235,1080,1920,1080,1734,387,502,324
        inertia: 3
        objects:
          - person
database:
  path: /media/frigate.db
logger:
  default: info
  logs:
    frigate.mqtt: error

Any other relevant information

No response

SgtBatten commented 3 months ago

Thanks for the report.

I've tested so extensively with the beta I really can't comprehend what I've missed here. Did you create the beta version as a new automation? Please do so if not.

Please don't bother with stable for object filtering, let's just focus on beta to get it fixed.

One note. You can create object masks rather than image masks to stop objects being detected in frigate. But this only hides your symptoms not the issue at hand.

asemev commented 3 months ago

Happy to help. Yes i did create the beta as a brand new automation. Chose the camera, added the zone name and person as object condition, chose my phone model and set it up. It behaves exactly like the 0.2 version. So my observation is that somehow its completely ignoring the zone setting entirely. I know you have extensively tested it, so its really strange. I also asked help in the frigate forum to see if the issue is somehow caused by frigate itself but they confirmed that ifrigate is working exactly as intended, i.e. not registering the event at all. (https://github.com/blakeblackshear/frigate/discussions/10539). Is there anything i can do to help?

Here is the YAML code for the beta automation:

alias: Frigate Door Beta description: "" use_blueprint: path: SgtBatten/Beta.yaml input: camera: camera.door notify_device: e00c1c0945954b1f084708607893d66f zones:

SgtBatten commented 3 months ago

can you enable debug and provide a full trace of one that you shouldn't get a notification from, but did

asemev commented 3 months ago

Here you go. It happens constantly.

Frigate Notification DEBUG (in loop): Send Notification: False Info: sublabel: None, image: "/api/frigate/notifications/1711089079.068587-458pm7/snapshot.jpg?bbox=1" Title: message: A Person was detected on the Door camera. iOS sound: enabled, Android Sound: enabled, iOS url: /api/frigate/notifications/1711089079.068587-458pm7/door/clip.mp4 video: "/api/frigate/notifications/1711089079.068587-458pm7/door/clip.mp4" critical: False, Triggers: New Snapshot: False - Disabled Presence Changed: False, Stationary Moved: False, Entered Zones Changed: False - Disabled, sublabel changed: False, Conditions: Loitering: 0 or Filters: Zones: Zone Filter Enabled: False, Multi Zone Enabled: False, Required Zones: ['zone_0'], Last Zones: [], Entered zones: 0 - [], TEST: PASS, Object Filter: Input: ['person'], TEST: PASS, Presence entity (not home): Entity: , TEST: PASS, Time Filter: Disabled times: [], TEST: PASS State Filter: state filter toggle on: False, state filter entity: , required states: [], TEST: PASS, Custom Filter: PASS, triggered by automation Frigate Door Beta mqtt topic frigate/events

asemev commented 3 months ago

And as you can see, the event doesnt exist in Frigate timeline:

image

The guy in the picture is me, from earlier this morning around 7am and nothing since. While the event log i sent you above is from 7:31.

asemev commented 3 months ago

I might have found a possible cause! I started watching the frigate debus screen and noticed that frigate creates a green box around the subject when it detects motion (and gthen analyses the motiuon and detects the object and puts a red bounding box around the subject). and the green box is a big box and that box falls over my zone. is it possible that that green box is triggering your automation somehow??

https://docs.frigate.video/configuration/masks/

image

image

asemev commented 3 months ago

image image

SgtBatten commented 3 months ago

Ahh... You don't actually have the zone filter enabled. Seperate toggle.

asemev commented 3 months ago

Oh my! I'm so terribly sorry to have wasted your time kind sir!