Frigate + Telegram

Boa noite.
Tenho o Frigate configurado e a trabalhar bem (inclusivamente com compreface e double take), tenho o telegram bot a trabalhar, e tenho duas automações (uma para snapshots e outra para clips) a notificar-me via telegram quando uma pessoa entra no espaço monitorizado pelas minhas câmaras. Quando tudo estiver a trabalhar, uno as duas automações em uma.
No entanto, tenho 8 câmaras ligadas ao frigate, o HA identifica pessoas em todas elas (o frigate card demonstra-o), quando pesquiso as media, encontro clips e snapshots de todas as câmaras, mas, no entanto, só recebo notificações de 4 dessas câmaras.
Junto anexo yamls (com informação sensível devidamente disfarçada):
Frigate:

mqtt:
  host: 192.168.XXX.XXX
  port: XXXX
  user: user
  password: password

detectors:
  coral:
    type: edgetpu
    device: usb

go2rtc:
  streams:
    F1:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=1&subtype=0
    F2:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=2&subtype=0
    L1:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=3&subtype=0
    F3:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=4&subtype=0
    L3:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=5&subtype=0
    L4:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=6&subtype=0
    F4:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=7&subtype=0
    F5:
      - ffmpeg:rtsp://xxxx:yyyy@192.168.X.XX:XXX/cam/realmonitor?channel=8&subtype=1

birdseye:
  enabled: True
  quality: 8
  mode: objects

database:
  # The path to store the SQLite DB (default: shown below)
  path: /media/frigate/frigate.db

logger:
  # Optional: Default log verbosity (default: shown below)
  default: info
  # Optional: Component specific logger overrides
  logs:
    frigate.app: debug
 
ffmpeg:
  hwaccel_args: preset-vaapi
  # Optional: global ffmpeg args (default: shown below)
  global_args: -hide_banner -loglevel warning -threads 1
  # Optional: global hwaccel args (default: shown below)
  # Optional: global input args (default: shown below)
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  # Optional: global output args
  output_args:
    # Optional: output args for detect streams (default: shown below)
    detect: -threads 1 -f rawvideo -pix_fmt yuv420p
    # Optional: output args for record streams (default: shown below)
    record: preset-record-generic

cameras:
  F1:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/F1
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: F1
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1440,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  F2:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/F2
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: F2
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  L1:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/L1
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: L1
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  F3:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/F3
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: F3
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  L3:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/L3
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: L3
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - car
        - motorcycle
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  L4:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/L4
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: L4
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - car
        - motorcycle
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  F4:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/F4
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: F4
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - car
        - motorcycle
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

  F5:
    ffmpeg:    
      inputs:
        - path: rtsp://127.0.0.1:8554/F5
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    live:
      stream_name: F5
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      max_disappeared: 25
      stationary:
        interval: 0
        threshold: 50
        max_frames:
          default: 3000
          objects:
            person: 1000
    objects:
      track:
        - person
        - car
        - motorcycle
        - bird
        - cat
        - dog
        - knife
        - cell phone
        - mouse
      mask: 0,0,1000,0,1000,200,0,200
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.7
          mask: 0,0,1000,0,1000,200,0,200
    motion:
      threshold: 25
      contour_area: 30
      delta_alpha: 0.2
      frame_alpha: 0.2
      frame_height: 50
      mask: 0,900,1080,900,1080,1920,0,1920
      improve_contrast: False
    best_image_timeout: 60
    # Optional: 24/7 recording configuration
    record:
      # Optional: Enable recording (default: global setting)
      enabled: True
      # Optional: Number of days to retain (default: global setting)
      retain:
        days: 3
        mode: motion
      events:
        retain:
          default: 7
          mode: active_objects
          objects:
            person: 50
    # Optional: RTMP re-stream configuration
    rtmp:
      # Required: Enable the live stream (default: True)
      enabled: False
    # Optional: Configuration for the jpg snapshots written to the clips directory for each event
    snapshots:
      # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
      # This value can be set via MQTT and will be updated in startup based on retained value
      enabled: True
      # Optional: print a timestamp on the snapshots (default: shown below)
      timestamp: True
      # Optional: draw bounding box on the snapshots (default: shown below)
      bounding_box: True
      # Optional: crop the snapshot (default: shown below)
      crop: True
      # Optional: height to resize the snapshot to (default: original size)
      height: 500
      # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
      required_zones: []
      # Optional: Camera override for retention settings (default: global values)
      retain:
        # Required: Default retention days (default: shown below)
        default: 10
        # Optional: Per object retention days
        objects:
          person: 15
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: True
      height: 500
      quality: 100

Automação Snapshot:

alias: Telegram Pessoas Snapshot
description: ""
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: template
    value_template: "{{ trigger.payload_json[\"type\"] == \"end\" }}"
  - condition: template
    value_template: "{{ trigger.payload_json['after']['label'] == 'person' }}"
action:
  - service: notify.telegrambot
    data_template:
      message: A {{trigger.payload_json["after"]["label"]}} was detected.
      data:
        photo:
          - url: >-
              https://xxyyzz.duckdns.org/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
            caption: >-
              A {{trigger.payload_json["after"]["label"]}} was detected on {{
              trigger.payload_json["after"]["camera"] }} camera
mode: single

Automação Clips:

alias: Telegram Pessoas Vídeo
description: ""
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: template
    value_template: "{{ trigger.payload_json[\"type\"] == \"end\" }}"
  - condition: template
    value_template: "{{ trigger.payload_json['after']['label'] == 'person' }}"
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 45
      milliseconds: 0
  - service: notify.daniel
    data_template:
      message: Video of alert
      data:
        video:
          - url: >-
              https://xxyyzz.duckdns.org/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/clip.mp4
            timeout: 1000
            caption: >-
              A {{trigger.payload_json["after"]["label"] == 'person' }} was
              detected on {{ trigger.payload_json["after"]["camera"] }} camera
mode: single

Volto a frisar, só recebo tanto snapshots como clips de F1, F2, F3 e F5 (nomes alterados, como é óbvio…).
Ajuda?

1 Curtiu

Tive alguns problemas com uma automação desse genero e depois encontrei uma blueprint que fazia o que queria.
Alterei a linguagem e ficou impec, dá uma vista de olhos.


Copyright © 2017-2021. Todos os direitos reservados
CPHA.pt - info@cpha.pt


FAQ | Termos de Serviço/Regras | Política de Privacidade