Skip to content

Commit

Permalink
Write default config if no config is saved (#10847)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Apr 5, 2024
1 parent 2318e79 commit 07ee39b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frigate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from frigate.storage import StorageMaintainer
from frigate.timeline import TimelineProcessor
from frigate.types import CameraMetricsTypes, PTZMetricsTypes
from frigate.util.builtin import save_default_config
from frigate.util.object import get_camera_regions_grid
from frigate.version import VERSION
from frigate.video import capture_camera, track_camera
Expand Down Expand Up @@ -120,6 +121,11 @@ def init_config(self) -> None:
if os.path.isfile(config_file_yaml):
config_file = config_file_yaml

if not os.path.isfile(config_file):
print("No config file found, saving default config")
config_file = config_file_yaml
save_default_config(config_file)

user_config = FrigateConfig.parse_file(config_file)
self.config = user_config.runtime_config(self.plus_api)

Expand Down
26 changes: 26 additions & 0 deletions frigate/util/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@ def find_by_key(dictionary, target_key):
return None


def save_default_config(location: str):
try:
with open(location, "w") as f:
f.write(
"""
mqtt:
enabled: False
cameras:
name_of_your_camera: # <------ Name the camera
enabled: True
ffmpeg:
inputs:
- path: rtsp://10.0.10.10:554/rtsp # <----- The stream you want to use for detection
roles:
- detect
detect:
enabled: False # <---- disable detection until you have a working camera feed
width: 1280
height: 720
"""
)
except PermissionError:
logger.error("Unable to write default config to /config")


def get_tomorrow_at_time(hour: int) -> datetime.datetime:
"""Returns the datetime of the following day at 2am."""
try:
Expand Down

0 comments on commit 07ee39b

Please sign in to comment.