Add offline and ntfy alerts

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-09 20:28:42 -04:00
co-authored by Copilot
parent 8b664667e5
commit 96332adab6
12 changed files with 1098 additions and 21 deletions
+41
View File
@@ -274,6 +274,47 @@ def _mounted_source(partition, mount_point, read_only):
return mount_point, True, False
def dashcam_storage_usage(mount_point=DEFAULT_MOUNT_POINT):
with _device_lock:
partition = find_dashcam_partition()
if partition is None:
return {"status": "no_device"}
source, mounted_here, _remounted = _mounted_source(
partition, mount_point, read_only=True
)
if source is None:
return {
"status": "mount_failed",
"path": partition["path"],
}
try:
usage = shutil.disk_usage(source)
used_percent = round(
usage.used / (usage.used + usage.free) * 100, 1
)
result = {
"status": "ok",
"path": partition["path"],
"total_bytes": usage.total,
"used_bytes": usage.used,
"free_bytes": usage.free,
"used_percent": used_percent,
}
except OSError as error:
result = {
"status": "read_failed",
"path": partition["path"],
"error": str(error),
}
finally:
if mounted_here and not unmount_device(mount_point):
result = {
"status": "unmount_failed",
"path": partition["path"],
}
return result
def list_dashcam_files(mount_point=DEFAULT_MOUNT_POINT):
"""List video files on the detected dashcam without copying them."""
with _device_lock: