BeardedTek / HassPyFrigate

GNU General Public License v3.0
2 stars 0 forks source link

HassPyFrigate

DEPRICATED

https://github.com/BeardedTek-com/fEVR is the new version of this project.

fEVR-main

Python 3 CGI script for better looking notifications

PRERELEASE CONDITION: This is usable, however there are definitely bugs, security vulnerabilities, and severe "hackiness" going on at this point.

Features:

Snapshot View

v0.2 Snapshot Viewer

Clip View

v0.2 Clip Viewer

Event Viewer

v0.2 Event Viewer

SERVER SIDE SETUP

Home Assistant Setup

RESTful Command

Add the following to your configuration.yaml in Home Assistant:

rest_command:
  hasspyfrigate:
    url: http(s)://<HASSPYFRIGATE_URL/cgi-bin/hasspyrest.py
    method: POST
    headers:
      accept: "application/json, text/html"
      user-agent: "Mozilla/5.0 {{ useragent }}"
    payload: '{
      "table": "events",
      "debug": "1",
      "function": "INSERT",
      "columns" : {
      "event_id": "{{event_id}}",
      "url": "{{url}}",
      "camera": "{{camera}}",
      "type": "{{type}}",
      "bbox": "{{bbox}}"
      }
      }'
    content_type: "application/json; charset=utf-8"

Android Companion App Notification

Example Android Actionable Notification

Click on "Event Viewer" to view HassPyFrigate Event Viewer Android Actionable Notification The following Automation will send an actionable notification to the android companion app (Should work with iOS as well) Include the following in your automations.yaml file in Home Assistant

- id: 'hasspyfrigate'
  alias: HassPyFrigate
  description: Object Detection Alerts Using HassPyFrigate
  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\" or\n\
      \   trigger.payload_json[\"after\"][\"label\"] == \"bird\" or\n   trigger.payload_json[\"\
      after\"][\"label\"] == \"dog\" or\n   trigger.payload_json[\"after\"][\"label\"\
      ] == \"cat\" or\n   trigger.payload_json[\"after\"][\"label\"] == \"bear\" or\n\
      \   trigger.payload_json[\"after\"][\"label\"] == \"horse\" \n}}"
  action:
  - service: notify.mobile_app_sg20plus
    data:
      message: '{{ trigger.payload_json["after"]["label"] | title }} Detected'
      data:
        notification_icon: mdi:cctv
        ttl: 0
        priority: high
        sticky: true
        actions:
        - action: URI
          title: Event Viewer
          uri: http(s)://<HOME_ASSISTANT_URL/cgi-bin/hasspyfrigate.py?id={{trigger.payload_json['after']['id']}}&camera={{trigger.payload_json['after']['camera']}}&bbox=true
        image: /api/frigate/notifications/{{trigger.payload_json['after']['id']}}/snapshot.jpg?bbox=1
        tag: '{{trigger.payload_json["after"]["id"]}}'
        alert_once: true
  - service: rest_command.hasspyfrigate
    data:
      event_id: '{{trigger.payload_json[''after''][''id'']}}'
      camera: '{{trigger.payload_json[''after''][''camera'']}}'
      type: '{{ trigger.payload_json[''after''][''label''] | title }}'
      bbox: 1
  mode: single

Planned Features: