Upgrade Frigate to v0.14.0 #12
This commit is contained in:
		
							parent
							
								
									de4b7792d1
								
							
						
					
					
						commit
						dfd3b48201
					
				| 
						 | 
				
			
			@ -59,8 +59,8 @@ cameras:
 | 
			
		|||
      enabled: true
 | 
			
		||||
      width: 1920
 | 
			
		||||
      height: 1080
 | 
			
		||||
    record:
 | 
			
		||||
      events:
 | 
			
		||||
    review:
 | 
			
		||||
      alerts:
 | 
			
		||||
        required_zones:
 | 
			
		||||
        - front_door_zone
 | 
			
		||||
    snapshots:
 | 
			
		||||
| 
						 | 
				
			
			@ -146,11 +146,23 @@ ffmpeg:
 | 
			
		|||
  hwaccel_args: preset-vaapi  # Use VAAPI hardware acceleration by default
 | 
			
		||||
  input_args: preset-rtsp-generic
 | 
			
		||||
 | 
			
		||||
objects:
 | 
			
		||||
  track:
 | 
			
		||||
  - person
 | 
			
		||||
 | 
			
		||||
review:
 | 
			
		||||
  alerts:
 | 
			
		||||
    labels:
 | 
			
		||||
    - person
 | 
			
		||||
  detections:
 | 
			
		||||
 | 
			
		||||
detect:
 | 
			
		||||
  enabled: true
 | 
			
		||||
  fps: 5
 | 
			
		||||
  max_disappeared: 25  # Number of frames without a detection before Frigate considers an object to be gone
 | 
			
		||||
 | 
			
		||||
motion:
 | 
			
		||||
 | 
			
		||||
record:
 | 
			
		||||
  enabled: true
 | 
			
		||||
  expire_interval: 60
 | 
			
		||||
| 
						 | 
				
			
			@ -160,8 +172,6 @@ record:
 | 
			
		|||
  events:
 | 
			
		||||
    pre_capture: 5  # Number of seconds before the event to include
 | 
			
		||||
    post_capture: 5  # Number of seconds after the event to include
 | 
			
		||||
    objects:
 | 
			
		||||
    - person
 | 
			
		||||
    retain:
 | 
			
		||||
      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)
 | 
			
		||||
| 
						 | 
				
			
			@ -169,11 +179,9 @@ record:
 | 
			
		|||
snapshots:
 | 
			
		||||
  enabled: true
 | 
			
		||||
 | 
			
		||||
rtmp:
 | 
			
		||||
  enabled: false
 | 
			
		||||
 | 
			
		||||
motion:
 | 
			
		||||
 | 
			
		||||
birdseye:
 | 
			
		||||
  enabled: true
 | 
			
		||||
  enabled: false
 | 
			
		||||
  mode: continuous
 | 
			
		||||
 | 
			
		||||
auth:
 | 
			
		||||
  enabled: false
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
services:
 | 
			
		||||
  frigate:
 | 
			
		||||
    container_name: frigate
 | 
			
		||||
    image: ghcr.io/blakeblackshear/frigate:0.13.2
 | 
			
		||||
    image: ghcr.io/blakeblackshear/frigate:0.14.0
 | 
			
		||||
    labels:
 | 
			
		||||
      autoheal: 'true'
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
| 
						 | 
				
			
			@ -52,6 +52,7 @@ services:
 | 
			
		|||
    ports:
 | 
			
		||||
    - 127.0.0.1:10000:5000
 | 
			
		||||
    - 554:8554
 | 
			
		||||
    - 10010:8971
 | 
			
		||||
  wyze-bridge:
 | 
			
		||||
    container_name: frigate-wyze-bridge
 | 
			
		||||
    image: mrlt8/wyze-bridge:2.9.7
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,25 +8,25 @@ import paho.mqtt.client as mqtt
 | 
			
		|||
 | 
			
		||||
class FrigateEventNotifier:
 | 
			
		||||
    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:
 | 
			
		||||
            self.mqtt_client.username_pw_set(mqtt_username, password=mqtt_password)
 | 
			
		||||
        self.mqtt_client.on_connect = self._on_connect
 | 
			
		||||
        self.mqtt_client.on_message = self._on_message
 | 
			
		||||
            self._mqtt_client.username_pw_set(mqtt_username, password=mqtt_password)
 | 
			
		||||
        self._mqtt_client.on_connect = self._on_connect
 | 
			
		||||
        self._mqtt_client.on_message = self._on_message
 | 
			
		||||
 | 
			
		||||
        frigate_api_response = requests.get("http://frigate:5000/api/config")
 | 
			
		||||
        frigate_api_response.raise_for_status()
 | 
			
		||||
        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.last_notification_time = {}
 | 
			
		||||
        self._quiet_period = quiet_period
 | 
			
		||||
        self._camera_to_last_notification_time = {}
 | 
			
		||||
 | 
			
		||||
    def send_notification(self, event_id, camera, object_label, score, priority=3):
 | 
			
		||||
        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
 | 
			
		||||
            self.last_notification_time[camera] = now
 | 
			
		||||
            self._camera_to_last_notification_time[camera] = now
 | 
			
		||||
            camera_location = " ".join(word.capitalize() for word in camera.split("_"))
 | 
			
		||||
 | 
			
		||||
            ntfy_api_response = requests.post("https://ntfy.homelab.net", json={
 | 
			
		||||
| 
						 | 
				
			
			@ -83,8 +83,8 @@ class FrigateEventNotifier:
 | 
			
		|||
            ntfy_api_response.raise_for_status()
 | 
			
		||||
 | 
			
		||||
    def start(self):
 | 
			
		||||
        self.mqtt_client.connect(host="mqtt", port=1883)
 | 
			
		||||
        self.mqtt_client.loop_forever()
 | 
			
		||||
        self._mqtt_client.connect(host="mqtt", port=1883)
 | 
			
		||||
        self._mqtt_client.loop_forever()
 | 
			
		||||
 | 
			
		||||
    def _on_connect(self, client, userdata, flags, rc):
 | 
			
		||||
        print(f"Connected with return code {rc}")
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ class FrigateEventNotifier:
 | 
			
		|||
        camera = payload["after"]["camera"]
 | 
			
		||||
        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
 | 
			
		||||
            if payload["type"] == "new":
 | 
			
		||||
                event_id = payload["after"]["id"]
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ class FrigateEventNotifier:
 | 
			
		|||
        else:
 | 
			
		||||
            new_zones = set(payload["after"]["entered_zones"]) - set(payload["before"]["entered_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"]
 | 
			
		||||
                    score = payload["after"]["top_score"]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue