Skip to content

Commit d202027

Browse files
authored
Merge pull request #460 from SAIC-iSmart-API/fix/extract-soc-kwh-warning-spam
fix(extractors): suppress SoC kWh warning spam for non-EV vehicles
2 parents d806387 + 77c4581 commit d202027

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/extractors/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ def extract_soc_kwh(
4343
charge_status: ChrgMgmtDataRespProcessingResult | None,
4444
soc: float | None,
4545
) -> float | None:
46-
if (
47-
charge_status is not None
48-
and (raw_soc_kwh := charge_status.soc_kwh) is not None
49-
and (soc_kwh := __validate_and_convert_soc_kwh(raw_soc_kwh)) is not None
50-
):
46+
if charge_status is None:
47+
return None
48+
49+
if (raw_soc_kwh := charge_status.soc_kwh) is not None and (
50+
soc_kwh := __validate_and_convert_soc_kwh(raw_soc_kwh)
51+
) is not None:
5152
LOG.debug("SoC kWh derived from realtimePower")
5253
return soc_kwh
5354

5455
if (
5556
soc is not None
56-
and charge_status is not None
5757
and (
5858
capacity := __validate_and_convert_soc_kwh(
5959
charge_status.real_total_battery_capacity

0 commit comments

Comments
 (0)