Skip to content

Commit

Permalink
Add total trip consumption attributes for EVs
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator authored Jan 3, 2025
1 parent fb69de8 commit fbcb68e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions weconnect/elements/trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(
self.averageSpeed_kmph = AddressableAttribute(localAddress='averageSpeed_kmph', parent=self, value=None, valueType=int)
self.averageAuxConsumption = AddressableAttribute(localAddress='averageAuxConsumption', parent=self, value=None, valueType=float)
self.averageRecuperation = AddressableAttribute(localAddress='averageRecuperation', parent=self, value=None, valueType=float)
self.totalAuxConsumption_Kwh = AddressableAttribute(localAddress='totalAuxConsumption_Kwh', parent=self, value=None, valueType=float)
self.totalElectricConsumption_kwh = AddressableAttribute(localAddress='totalElectricConsumption_kwh', parent=self, value=None, valueType=float)

self.fixAPI = fixAPI

Expand All @@ -58,6 +60,8 @@ def update( # noqa: C901 # pylint: disable=too-many-branches
self.averageSpeed_kmph.fromDict(fromDict, 'averageSpeed_kmph')
self.averageAuxConsumption.fromDict(fromDict, 'averageAuxConsumption')
self.averageRecuperation.fromDict(fromDict, 'averageRecuperation')
self.totalAuxConsumption_Kwh.fromDict(fromDict, 'totalAuxConsumption_Kwh')
self.totalElectricConsumption_kwh.fromDict(fromDict, 'totalElectricConsumption_kwh')

for key, value in {key: value for key, value in fromDict.items()
if key not in ['id',
Expand All @@ -72,7 +76,9 @@ def update( # noqa: C901 # pylint: disable=too-many-branches
'averageElectricConsumption',
'averageSpeed_kmph',
'averageAuxConsumption',
'averageRecuperation']}.items():
'averageRecuperation',
'totalAuxConsumption_Kwh',
'totalElectricConsumption_kwh']}.items():
LOG.warning('%s: Unknown attribute %s with value %s', self.getGlobalAddress(), key, value)

class TripType(Enum):
Expand Down Expand Up @@ -108,6 +114,10 @@ def __str__(self): # noqa: C901
if self.averageAuxConsumption.enabled:
returnString += f'Average Aux Consumption: {self.averageAuxConsumption.value}\n'
if self.averageRecuperation.enabled:
returnString += f'Average Recuperation: {self.averageRecuperation.value}\n'
returnString += f'Average Recuperation: {self.averageRecuperation.value}\n'
if self.totalAuxConsumption_Kwh.enabled:
returnString += f'Total Aux Consumption: {self.totalAuxConsumption_Kwh}'
if self.totalElectricConsumption_kwh.enabled:
returnString += f'Total Electric Consumption: {self.totalElectricConsumption_kwh}'
returnString += '\n'
return returnString

0 comments on commit fbcb68e

Please sign in to comment.