Upgrade Frigate to v0.14.0 #12
This commit is contained in:
parent
de4b7792d1
commit
16493e884d
|
@ -59,8 +59,8 @@ cameras:
|
||||||
enabled: true
|
enabled: true
|
||||||
width: 1920
|
width: 1920
|
||||||
height: 1080
|
height: 1080
|
||||||
record:
|
review:
|
||||||
events:
|
alerts:
|
||||||
required_zones:
|
required_zones:
|
||||||
- front_door_zone
|
- front_door_zone
|
||||||
snapshots:
|
snapshots:
|
||||||
|
@ -146,11 +146,22 @@ ffmpeg:
|
||||||
hwaccel_args: preset-vaapi # Use VAAPI hardware acceleration by default
|
hwaccel_args: preset-vaapi # Use VAAPI hardware acceleration by default
|
||||||
input_args: preset-rtsp-generic
|
input_args: preset-rtsp-generic
|
||||||
|
|
||||||
|
objects:
|
||||||
|
track:
|
||||||
|
- person
|
||||||
|
|
||||||
|
review:
|
||||||
|
alerts:
|
||||||
|
labels:
|
||||||
|
- person
|
||||||
|
|
||||||
detect:
|
detect:
|
||||||
enabled: true
|
enabled: true
|
||||||
fps: 5
|
fps: 5
|
||||||
max_disappeared: 25 # Number of frames without a detection before Frigate considers an object to be gone
|
max_disappeared: 25 # Number of frames without a detection before Frigate considers an object to be gone
|
||||||
|
|
||||||
|
motion:
|
||||||
|
|
||||||
record:
|
record:
|
||||||
enabled: true
|
enabled: true
|
||||||
expire_interval: 60
|
expire_interval: 60
|
||||||
|
@ -160,8 +171,6 @@ record:
|
||||||
events:
|
events:
|
||||||
pre_capture: 5 # Number of seconds before the event to include
|
pre_capture: 5 # Number of seconds before the event to include
|
||||||
post_capture: 5 # Number of seconds after the event to include
|
post_capture: 5 # Number of seconds after the event to include
|
||||||
objects:
|
|
||||||
- person
|
|
||||||
retain:
|
retain:
|
||||||
default: 30 # Number of days to retain recordings of events
|
default: 30 # Number of days to retain recordings of events
|
||||||
mode: all # Mode for retention: all (24/7), motion (only segments with motion), active_objects (only segments with active objects)
|
mode: all # Mode for retention: all (24/7), motion (only segments with motion), active_objects (only segments with active objects)
|
||||||
|
@ -169,11 +178,9 @@ record:
|
||||||
snapshots:
|
snapshots:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
rtmp:
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
motion:
|
|
||||||
|
|
||||||
birdseye:
|
birdseye:
|
||||||
enabled: true
|
enabled: false
|
||||||
mode: continuous
|
mode: continuous
|
||||||
|
|
||||||
|
auth:
|
||||||
|
enabled: false
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
services:
|
services:
|
||||||
frigate:
|
frigate:
|
||||||
container_name: frigate
|
container_name: frigate
|
||||||
image: ghcr.io/blakeblackshear/frigate:0.13.2
|
image: ghcr.io/blakeblackshear/frigate:0.14.0
|
||||||
labels:
|
labels:
|
||||||
autoheal: 'true'
|
autoheal: 'true'
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -52,6 +52,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:10000:5000
|
- 127.0.0.1:10000:5000
|
||||||
- 554:8554
|
- 554:8554
|
||||||
|
- 10010:8971
|
||||||
wyze-bridge:
|
wyze-bridge:
|
||||||
container_name: frigate-wyze-bridge
|
container_name: frigate-wyze-bridge
|
||||||
image: mrlt8/wyze-bridge:2.9.7
|
image: mrlt8/wyze-bridge:2.9.7
|
||||||
|
|
|
@ -8,25 +8,25 @@ import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
class FrigateEventNotifier:
|
class FrigateEventNotifier:
|
||||||
def __init__(self, mqtt_username, mqtt_password, quiet_period=3 * 60):
|
def __init__(self, mqtt_username, mqtt_password, quiet_period=3 * 60):
|
||||||
self.mqtt_client = mqtt.Client()
|
self._mqtt_client = mqtt.Client()
|
||||||
if mqtt_username is not None and mqtt_password is not None:
|
if mqtt_username is not None and mqtt_password is not None:
|
||||||
self.mqtt_client.username_pw_set(mqtt_username, password=mqtt_password)
|
self._mqtt_client.username_pw_set(mqtt_username, password=mqtt_password)
|
||||||
self.mqtt_client.on_connect = self._on_connect
|
self._mqtt_client.on_connect = self._on_connect
|
||||||
self.mqtt_client.on_message = self._on_message
|
self._mqtt_client.on_message = self._on_message
|
||||||
|
|
||||||
frigate_api_response = requests.get("http://frigate:5000/api/config")
|
frigate_api_response = requests.get("http://frigate:5000/api/config")
|
||||||
frigate_api_response.raise_for_status()
|
frigate_api_response.raise_for_status()
|
||||||
frigate_config = json.loads(frigate_api_response.content)
|
frigate_config = json.loads(frigate_api_response.content)
|
||||||
self.camera_zones = {camera_name: {required_zone: {object_label for object_label in camera_config["zones"][required_zone]["objects"]} for required_zone in camera_config["record"]["events"]["required_zones"]} for camera_name, camera_config in frigate_config["cameras"].items()}
|
self._camera_zones = {camera_name: {required_zone: {object_label for object_label in camera_config["zones"][required_zone]["objects"]} for required_zone in camera_config["review"]["alerts"]["required_zones"]} for camera_name, camera_config in frigate_config["cameras"].items()}
|
||||||
|
|
||||||
self.quiet_period = quiet_period
|
self._quiet_period = quiet_period
|
||||||
self.last_notification_time = {}
|
self._camera_to_last_notification_time = {}
|
||||||
|
|
||||||
def send_notification(self, event_id, camera, object_label, score, priority=3):
|
def send_notification(self, event_id, camera, object_label, score, priority=3):
|
||||||
now = dt.datetime.now()
|
now = dt.datetime.now()
|
||||||
if now - self.last_notification_time.get(camera, dt.datetime.min) >= dt.timedelta(seconds=self.quiet_period):
|
if now - self._camera_to_last_notification_time.get(camera, dt.datetime.min) >= dt.timedelta(seconds=self._quiet_period):
|
||||||
# Quiet period has passed since the last notification for this camera
|
# Quiet period has passed since the last notification for this camera
|
||||||
self.last_notification_time[camera] = now
|
self._camera_to_last_notification_time[camera] = now
|
||||||
camera_location = " ".join(word.capitalize() for word in camera.split("_"))
|
camera_location = " ".join(word.capitalize() for word in camera.split("_"))
|
||||||
|
|
||||||
ntfy_api_response = requests.post("https://ntfy.homelab.net", json={
|
ntfy_api_response = requests.post("https://ntfy.homelab.net", json={
|
||||||
|
@ -83,8 +83,8 @@ class FrigateEventNotifier:
|
||||||
ntfy_api_response.raise_for_status()
|
ntfy_api_response.raise_for_status()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.mqtt_client.connect(host="mqtt", port=1883)
|
self._mqtt_client.connect(host="mqtt", port=1883)
|
||||||
self.mqtt_client.loop_forever()
|
self._mqtt_client.loop_forever()
|
||||||
|
|
||||||
def _on_connect(self, client, userdata, flags, rc):
|
def _on_connect(self, client, userdata, flags, rc):
|
||||||
print(f"Connected with return code {rc}")
|
print(f"Connected with return code {rc}")
|
||||||
|
@ -95,7 +95,7 @@ class FrigateEventNotifier:
|
||||||
camera = payload["after"]["camera"]
|
camera = payload["after"]["camera"]
|
||||||
object_label = payload["after"]["label"]
|
object_label = payload["after"]["label"]
|
||||||
|
|
||||||
if not self.camera_zones[camera]:
|
if not self._camera_zones[camera]:
|
||||||
# No required zones, send notification on receipt of new event
|
# No required zones, send notification on receipt of new event
|
||||||
if payload["type"] == "new":
|
if payload["type"] == "new":
|
||||||
event_id = payload["after"]["id"]
|
event_id = payload["after"]["id"]
|
||||||
|
@ -105,7 +105,7 @@ class FrigateEventNotifier:
|
||||||
else:
|
else:
|
||||||
new_zones = set(payload["after"]["entered_zones"]) - set(payload["before"]["entered_zones"])
|
new_zones = set(payload["after"]["entered_zones"]) - set(payload["before"]["entered_zones"])
|
||||||
for zone in new_zones:
|
for zone in new_zones:
|
||||||
if zone in self.camera_zones[camera] and (not self.camera_zones[camera][zone] or object_label in self.camera_zones[camera][zone]):
|
if zone in self._camera_zones[camera] and (not self._camera_zones[camera][zone] or object_label in self._camera_zones[camera][zone]):
|
||||||
event_id = payload["after"]["id"]
|
event_id = payload["after"]["id"]
|
||||||
score = payload["after"]["top_score"]
|
score = payload["after"]["top_score"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue