Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend checking to handle None value in case of hybrid car #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions weconnect_cupra/api/cupra/elements/charging_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update(self, fromDict, ignoreAttributes=None): # noqa: C901
self.chargingState.fromDict(fromDict['value'], 'chargingState')
self.chargeMode.fromDict(fromDict['value'], 'chargeMode')
self.chargePower_kW.fromDict(fromDict['value'], 'chargePower_kW')
if 'chargePower_kW' in fromDict['value']:
if 'chargePower_kW' in fromDict['value'] and fromDict['value']['chargePower_kW'] is not None:
chargePower_kW = float(fromDict['value']['chargePower_kW'])
if self.fixAPI and chargePower_kW != 0 \
and self.chargingState.value in [ChargingStatus.ChargingState.OFF,
Expand All @@ -58,7 +58,7 @@ def update(self, fromDict, ignoreAttributes=None): # noqa: C901
self.chargePower_kW.setValueWithCarTime(chargePower_kW, lastUpdateFromCar=None, fromServer=True)
else:
self.chargePower_kW.enabled = False
if 'chargeRate_kmph' in fromDict['value']:
if 'chargeRate_kmph' in fromDict['value'] and fromDict['value']['chargeRate_kmph'] is not None:
chargeRate_kmph = float(fromDict['value']['chargeRate_kmph'])
if self.fixAPI and chargeRate_kmph != 0 \
and self.chargingState.value in [ChargingStatus.ChargingState.OFF,
Expand Down