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
15 changes: 14 additions & 1 deletion packages/modules/vehicles/renault/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,18 @@ def fetch_soc(config: RenaultConfiguration) -> CarState:
responsetext = response.read()
batt = json.loads(responsetext)

# Step 9 - cockpit data for odometer/totalMileage
data = urllib.parse.urlencode(country_data)
data = data.encode('Big5')
reg = urllib.request.Request(KAMEREON_ROOTURL + '/commerce/v1/accounts/' +
kamereonaccountid + '/kamereon/kca/car-adapter/v1/cars/'
+ vin + '/cockpit?' + data.decode("utf-8"))
Comment thread
seaspotter marked this conversation as resolved.
Resolved
reg.add_header('x-gigya-id_token', gigya_jwttoken)
reg.add_header('apikey', KAMEREON_API_KEY)
response = urllib.request.urlopen(reg)
responsetext = response.read()
cockpit = json.loads(responsetext)
Comment thread
seaspotter marked this conversation as resolved.
Resolved

return CarState(soc=float(batt['data']['attributes']['batteryLevel']),
range=float(batt['data']['attributes']['batteryAutonomy']))
range=float(batt['data']['attributes']['batteryAutonomy']),
odometer=float(cockpit['data']['attributes']['totalMileage']))
Comment thread
seaspotter marked this conversation as resolved.
Resolved
Comment on lines +84 to +98

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new cockpit request makes fetch_soc fail entirely if the cockpit endpoint is unavailable or returns an unexpected payload (e.g., missing data.attributes.totalMileage). Consider handling errors for this optional field (e.g., catch network/JSON/key errors and set odometer=None) so SOC/range can still be returned.

Copilot uses AI. Check for mistakes.
Loading