Skip to content
Merged
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
9 changes: 6 additions & 3 deletions packages/modules/vehicles/vweuda/libeuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ def get_field_timestamp_by_key(D: dict, key: str) -> str:
return ret


CAR_TIMESTAMP = "car_captured_time"
CAR_TIMESTAMP1 = "car_captured_time"
CAR_TIMESTAMP2 = "timestamp"


def get_max_value_by_fieldname(D: dict, field: str) -> str:
Expand Down Expand Up @@ -810,9 +811,11 @@ def parse_vehicle_data(payload: dict) -> dict:
_ts = get_field_timestamp_by_key(data, 'ae0294b4-1286-3e98-a818-1485b8d88430')
soc_timestamp_str = re.sub(r'\....Z', 'Z', _ts)

# try to get soc_timestamp as max of all car_captured_time fields
# try to get soc_timestamp as max of all car_captured_time or timestamp fields
if soc_timestamp_str is None:
soc_timestamp_str = get_max_value_by_fieldname(data, CAR_TIMESTAMP)
soc_timestamp_str = get_max_value_by_fieldname(data, CAR_TIMESTAMP1)
if soc_timestamp_str is None:
soc_timestamp_str = get_max_value_by_fieldname(data, CAR_TIMESTAMP2)

# if soc is None, try sveral other fields
if soc is None:
Expand Down
Loading