Skip to content
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
12 changes: 11 additions & 1 deletion 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 @@ -109,5 +115,9 @@ def __str__(self): # noqa: C901
returnString += f'Average Aux Consumption: {self.averageAuxConsumption.value}\n'
if self.averageRecuperation.enabled:
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