From 90e66bea48c5807cf8662ee03170facc570a8de8 Mon Sep 17 00:00:00 2001 From: Liam Scanlon Date: Fri, 22 May 2026 03:52:18 +0000 Subject: [PATCH] utils: None-guard dp1/dp2/dp3/dp4 Avoid TypeError: type NoneType doesn't define __round__ method when load_today_comparison passes None into rounding helpers (occurs when now_utc doesn't align to PREDICT_STEP boundary). Bug surface: load_adjusted_stamp only contains future minutes >= minutes_now, so an unaligned 'now' produces a None lookup. This is a candidate upstream PR. --- apps/predbat/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/predbat/utils.py b/apps/predbat/utils.py index c7d9c132c..9057db730 100644 --- a/apps/predbat/utils.py +++ b/apps/predbat/utils.py @@ -851,6 +851,8 @@ def dp1(value): """ Round to 1 decimal place """ + if value is None: + return None return round(value, 1) @@ -858,6 +860,8 @@ def dp2(value): """ Round to 2 decimal places """ + if value is None: + return None return round(value, 2) @@ -865,6 +869,8 @@ def dp3(value): """ Round to 3 decimal places """ + if value is None: + return None return round(value, 3) @@ -872,6 +878,8 @@ def dp4(value): """ Round to 4 decimal places """ + if value is None: + return None return round(value, 4)