From 7fe0726ec3e086bc6ee405d227ff94e2cc4b7b48 Mon Sep 17 00:00:00 2001 From: murderbeard <23704547+murderbeard@users.noreply.github.com> Date: Fri, 10 Apr 2026 23:24:33 +0200 Subject: [PATCH 1/2] Add check for NoneType in get_elec_consumption As my trip data would no longer load. The log states that end[LEVEL] could be NoneType, which trip_parser did not like. With this check in place my trip data is working again. --- psa_car_controller/psacc/application/trip_parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psa_car_controller/psacc/application/trip_parser.py b/psa_car_controller/psacc/application/trip_parser.py index 6b066b3b..84c423bb 100644 --- a/psa_car_controller/psacc/application/trip_parser.py +++ b/psa_car_controller/psacc/application/trip_parser.py @@ -29,7 +29,10 @@ def get_thermal_consumption(start, end): @staticmethod def get_elec_consumption(start, end): - return [start[LEVEL] - end[LEVEL], 0] + if start[LEVEL] is not None and end[LEVEL] is not None: + return [start[LEVEL] - end[LEVEL], 0] + else: + return [0, 0] @staticmethod def get_hybrid_consumption(start, end): From 2347e95da83d304c76fc9a636e8520e969bd7bed Mon Sep 17 00:00:00 2001 From: murderbeard <23704547+murderbeard@users.noreply.github.com> Date: Fri, 10 Apr 2026 23:32:26 +0200 Subject: [PATCH 2/2] Update trip_parser.py --- psa_car_controller/psacc/application/trip_parser.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/psa_car_controller/psacc/application/trip_parser.py b/psa_car_controller/psacc/application/trip_parser.py index 84c423bb..e6b03e37 100644 --- a/psa_car_controller/psacc/application/trip_parser.py +++ b/psa_car_controller/psacc/application/trip_parser.py @@ -31,8 +31,7 @@ def get_thermal_consumption(start, end): def get_elec_consumption(start, end): if start[LEVEL] is not None and end[LEVEL] is not None: return [start[LEVEL] - end[LEVEL], 0] - else: - return [0, 0] + return [0, 0] @staticmethod def get_hybrid_consumption(start, end):