From 77c4581b3575ed9e026616bc84dd9a1d20f8bd41 Mon Sep 17 00:00:00 2001 From: Giovanni Condello Date: Wed, 24 Jun 2026 23:05:25 +0200 Subject: [PATCH] fix(extractors): suppress SoC kWh warning for non-EV vehicles extract_soc_kwh now returns None silently when charge_status is None, which is the expected state for non-EV vehicles on every poll cycle. The WARNING is preserved for EVs where charge_status is present but kWh derivation fails. --- src/extractors/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/extractors/__init__.py b/src/extractors/__init__.py index 2ebd343..746a735 100644 --- a/src/extractors/__init__.py +++ b/src/extractors/__init__.py @@ -43,17 +43,17 @@ def extract_soc_kwh( charge_status: ChrgMgmtDataRespProcessingResult | None, soc: float | None, ) -> float | None: - if ( - charge_status is not None - and (raw_soc_kwh := charge_status.soc_kwh) is not None - and (soc_kwh := __validate_and_convert_soc_kwh(raw_soc_kwh)) is not None - ): + if charge_status is None: + return None + + if (raw_soc_kwh := charge_status.soc_kwh) is not None and ( + soc_kwh := __validate_and_convert_soc_kwh(raw_soc_kwh) + ) is not None: LOG.debug("SoC kWh derived from realtimePower") return soc_kwh if ( soc is not None - and charge_status is not None and ( capacity := __validate_and_convert_soc_kwh( charge_status.real_total_battery_capacity