Download Historic Charges from Renault API
I already track the money I pay for charging via hledger. But I wanted a way to get the exact date when charging and a second way to get the kWh charged. For my (electric Renault) car there is an API. I already use this API in Homeassistant to get data from the car and track its position. The library used in Homeassistant is renault-api. And this library supports fetching the charging history too.
A small script gives me all charges of the car to correlate with my ledger data:
import asyncio, json, aiohttp from datetime import datetime, timedelta from renault_api.renault_client import RenaultClient EMAIL = "your@email.com" PASSWORD = "your-password" async def main(): async with aiohttp.ClientSession() as s: client = RenaultClient(websession=s, locale="fr_FR") await client.session.login(EMAIL, PASSWORD) account = (await client.get_api_accounts())[0] vin = (await account.get_vehicles()).vehicleLinks[0].vin vehicle = await account.get_api_vehicle(vin) charges = await vehicle.get_charges( start=datetime.now() - timedelta(days=365), end=datetime.now() ) print(json.dumps(charges.raw_data, indent=2, default=str)) asyncio.run(main())
The Python script downloads the full history of charges from the last 365 days for the first car in the Renault account.
One dataset looks like this:
{ "chargeStartDate": "2025-12-30T08:05:11Z", "chargeEndDate": "2025-12-30T08:43:57Z", "chargeEndStatus": "ok", "chargeStartBatteryLevel": 14, "chargeEndBatteryLevel": 81, "chargeEnergyRecovered": 34.800003, "chargeDuration": 38 },
Not only the recovered energy (kWh) and the time needed to charge, but most important the exact time of charge. My not so exact date of ledger transactions could be back dated to the correct date with this.
For the example above my ledger entry is this one:
So €12.60 with €0.39/kWh is 32.3kWh.
Close but not identical.
So there are some tolerances and probably transfer losses (for the kWh) involved.
This is a good second data source to correlate my finance data against. I will probably not run this automatically, but once I need the data I will update the already downloaded json file.