check if motion dataframe is empty (#11593)

This commit is contained in:
Josh Hawkins 2024-05-28 12:33:28 -05:00 committed by GitHub
parent 8546d3d315
commit f7c3ddd380
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -440,6 +440,11 @@ def motion_activity():
# resample data using pandas to get activity on scaled basis # resample data using pandas to get activity on scaled basis
df = pd.DataFrame(data, columns=["start_time", "motion", "camera"]) df = pd.DataFrame(data, columns=["start_time", "motion", "camera"])
if df.empty:
logger.warning("No motion data found for the requested time range")
return jsonify([])
df = df.astype(dtype={"motion": "float16"}) df = df.astype(dtype={"motion": "float16"})
# set date as datetime index # set date as datetime index