fix: handle cameras without SD card storage

Return default values (0) for storage stats when a camera has no SD card
instead of an empty dict. This prevents KeyError when build_device_states
tries to access storage["used"].

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
pull/106/head
Jeff Culverhouse 6 days ago
parent 8cd2ca0b1b
commit af666c119b

@ -191,7 +191,7 @@ class AmcrestAPIMixin:
device = self.amcrest_devices[device_id]
states = self.states[device_id]
# return our last known state if something fails
# return our last known state if something fails, or defaults for cameras without storage
current: dict[str, str | float] = (
{
"used_percent": states["sensor"].get("storage_used_pct", 0),
@ -199,7 +199,7 @@ class AmcrestAPIMixin:
"total": states["sensor"].get("storage_total", 0),
}
if "sensor" in states
else {}
else {"used_percent": 0, "used": 0, "total": 0}
)
if not device["camera"]:

Loading…
Cancel
Save