Local realtime person detection for RTSP cameras

Hi all, I am considering a coral usb device, I can however not find anything on interaction with odroid n2+. Does anyone know if these are compatible?

Also, and I believe the question has been asked here but can’t distill the answer, does the hardware acceleration of the n2+ work for frigate?

Lastly, sorry if I am over asking, is there any plan to support home assistant cam entities in frigate like dood does? EG. Espcam through esphome?

If it’s the Coral USB, I suspect you should be fine. While mine is running on a Pi4, I have a bunch of Odroids arm systems around, and usually the armhf and arm64 stuff is compatible whether a Pi or Odroid based arm board. You can follow the instructions on the Google Coral site and add the repo and install it. If it installs, and the sample code runs (even without the TPU), I think you’ll be fine.

I want to share my automation for notification of Frigate events.

Here’s a few things I do that are interesting:

  • Create an input_boolean for each camera, named input_boolean.block_notify_<camera_name> If this input_boolean is on, I don’t get a notification. When that input_boolean gets enabled, I have another automation that waits for it to be on for 15 minutes, and then turns it back off.

  • Use a condition template to only allow notifications from certain cameras. I have a few cameras that are very busy, and I don’t want notifications from them. So I only send notifications from cameras that are part of a list.

Here’s my automation, partially from the new actionable notifications stuff, plus what was posted above. Hope this helps someone!

alias: Notify on Frigate events
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: template
    value_template: >-
      {{ trigger.payload_json["after"]["camera"] in ['front_door', 'rightside',
      'leftside', 'backyard', 'driveway'] }}
  - condition: template
    value_template: >-
      {{ is_state(
      "input_boolean.block_notify_"~(trigger.payload_json["after"]["camera"]),
      "off" ) }}
action:
  - alias: Set up action variables
    variables:
      action_snooze_15: '{{ ''SNOOZE_15'' ~ context.id }}'
  - service: notify.mobile_app_moralsnipe_iphone
    data_template:
      message: >-
        {{ trigger.payload_json["after"]["camera"] }}:  {{
        trigger.payload_json["after"]["label"] }}
      data:
        image: >-
          https://homeassistant.xxx.com:443/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=ios
        tag: '{{ trigger.payload_json["after"]["id"] }}'
        url: >-
          https://homeassistant.xxx.com:443/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
        group: '{{ trigger.payload_json["after"]["camera"] }}'
        color: '#2DF56D'
        actions:
          - action: URI
            title: View Video
            uri: >-
              https://homeassistant.xxx.com:443/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/{{trigger.payload_json["after"]["camera"]}}/clip.mp4
          - action: URI
            title: View Snapshot
            uri: >-
              https://homeassistant.xxx.com:443/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
          - action: '{{ action_snooze_15 }}'
            title: Snooze Alerts 15 Minutes
            authenticationRequired: false
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: '{{ action_snooze_15 }}'
    timeout: '300'
    continue_on_timeout: false
  - alias: Handle the response
    choose:
      - conditions:
          - condition: template
            value_template: '{{ wait.trigger.event.data.action == action_snooze_15 }}'
        sequence:
          - service: input_boolean.turn_on
            data_template:
              entity_id: >-
                {{
                "input_boolean.block_notify_"~(trigger.payload_json["after"]["camera"])
                }}
mode: parallel
max: 10

3 Likes

I’m still trying to figure out how to parallel it properly, and what the wait for trigger timeout should be. Probably drop the wait for timeout to just a minute.

Is it possible to configure a notification for a specific zone? I have two zones configured and only want a notification on my phone for one of the two zones and still get snapshots in my events for both zones.

You could do something similar to my condition template, but instead of checking the camera, you would check entered_zone.

Instead of:

- condition: template
    value_template: >-
      {{ trigger.payload_json["after"]["camera"] in ['front_door', 'rightside',
      'leftside', 'backyard', 'driveway'] }}

You would do something like:

- condition: template
    value_template: >-
      {{ trigger.payload_json["after"]["entered_zones"] in ['zone1', 'zone_foo'] }}

Note that this isn’t correct, but it’s close.

3 Likes

Since Coral USB is sold out everywhere,
Would using M.2 adapter to USB for the M.2 coral board work with Pi4?

@tonioa it’s working now, the video button redirects to the video link
Btw, could we actually configure to play the video stream directly on the notification?

You could probably link to video on click notification

Thanks, that’s helpful!

it runs without the coral. Not sure though how to access hardware acceleration (other N2+ users in this thread?) and would be good to understand, does this only work with rtsp? Or are there plans to also access home assistant embedded cams (like doods can do).

This is much more elegant than my cobbled together notification script. Would you mind sharing the YAML for the 15 min snooze reactivation automation?

Jason

Sure thing! It’s not perfect. It simply looks for the input_boolean going to on for 15 minutes, and then turns it back off. I’ve done this different ways in the past.

alias: Re-enable camera notification after  15 minutes
description: ''
trigger:
  - platform: state
    entity_id: >-
      input_boolean.block_notify_backyard,input_boolean.block_notify_driveway,input_boolean.block_notify_front_door,input_boolean.block_notify_leftside,input_boolean.block_notify_rightside
    from: 'off'
    to: 'on'
    for: '00:15:00'
condition: []
action:
  - service: input_boolean.turn_off
    data_template:
      entity_id: |-
        {{
          trigger.to_state.entity_id
        }}
mode: single

Awesome. Thank you so much!

Have you noticed a behavior when you use one of the actions in the notification that cross-launches the HA app, it gets stuck displaying that image/clip?

Anyone over here could help me to install Frigate NVR in docker running on Synology (DS918+)?
I don’t know what image I should use.

https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Compatibility_Peripherals/What_kind_of_CPU_does_my_NAS_have

The issue that I’m currently seeing is that the runs are not timing out properly, and I’m hitting my max parallel runs. I haven’t seen what you’re describing however.

Hi community,

my Frigate Addon is not starting anymore. I’m not sure, if it is related to the latest HA update.

Frigate logs are empty. HA logs are showing this message:

This error originated from a custom integration.

Logger: custom_components.frigate
Source: helpers/update_coordinator.py:212
Integration: Frigate (documentation, issues)
First occurred: 19 May 2021, 23:26:58 (879 occurrences)
Last logged: 20:09:22

Error fetching frigate data:

and

This error originated from a custom integration.

Logger: custom_components.frigate
Source: custom_components/frigate/api.py:90
Integration: Frigate (documentation, issues)
First occurred: 19 May 2021, 23:26:58 (882 occurrences)
Last logged: 20:13:38

Error fetching information from http://ccab4aaf-frigate:5000/api/stats - Cannot connect to host ccab4aaf-frigate:5000 ssl:default [Try again]

“rebuild” via Supervisor wasn’t successful too.

Any idea, where I should look at first?

Thank you!!

Close the HA app, reopen and you still get the last viewed image.
Reset the frontend cache, reopen you still get the last viewed image.
Reboot your phone, reopen the app you still get the last viewed image.

No amount of swiping or pinching will get you back to the dashboard.

Obviously nothing to do with this automation in particular but possibly an issue with the app and reactive notifications in iOS.

Jason

Thank you :slight_smile:
I’ve managed to execute it however it cannot find my USB Coral Stick. It can initi it however after it fails to load delegate from libedgetpu.so.1.0.

sudo docker run -d \ 
--name frigate \
--privileged \
--restart unless-stopped \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
--device /dev/bus/usb:/dev/bus/usb \
--device /dev/dri/renderD128 \
-v /volume1/docker/frigate/media/frigate:/media/frigate \
-v /volume1/docker/frigate/config/config.yml:/config/config.yml:ro \
-e FRIGATE_RTSP_PASSWORD='password' \
-p 5000:5000 \
-p 1935:1935 \
blakeblackshear/frigate:0.8.2-amd64

Just solved it by a complete reinstall. Just in case, backup the config before. :wink:

1 Like

Did you change platforms? I had to do this for both Frigate & MariaDB when rehosting from RPi to NUC.

1 Like