Renault API

PyPI Python Version License

Read the documentation at https://renault-api.readthedocs.io/ Tests Codecov

pre-commit Black

Features

This Python package manages the communication with the private Renault API used by the official MyRenault application.

The client is able to read various vehicle attributes, such as:

  • mileage

  • GPS location

  • fuel autonomy (for fuel vehicles)

  • battery autonomy (for electric vehicles)

  • contracts associated to the vehicle (warranty and connected services)

For some vehicles, it is also possible to manage:

  • hvac/pre-conditionning of the vehicle

  • charge schedule

This package has been developed to be used with Home-Assistant, but it can be used in other contexts

Requirements

  • Python (>= 3.8)

API Usage

You can install Renault API via pip from PyPI:

$ pip install renault-api
import aiohttp
import asyncio

from renault_api.renault_client import RenaultClient

async def main():
   async with aiohttp.ClientSession() as websession:
      client = RenaultClient(websession=websession, locale="fr_FR")
      await client.session.login('email', 'password')
      print(f"Accounts: {await client.get_person()}") # List available accounts, make a note of kamereon account id

      account_id = "Your Kamereon account id"
      account = await client.get_api_account(account_id)
      print(f"Vehicles: {await account.get_vehicles()}") # List available vehicles, make a note of vehicle VIN

      vin = "Your vehicle VIN"
      vehicle = await account.get_api_vehicle(vin)
      print(f"Cockpit information: {await vehicle.get_cockpit()}")
      print(f"Battery status information: {await vehicle.get_battery_status()}")

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

CLI Usage

The renault-api is also available through a CLI, which requires additional dependencies. For the added dependencies, you can install Renault API via pip from PyPI:

$ pip install renault-api[cli]

Once installed, the following command prompts for credentials and settings, displays basic vehicle status information, and generates traces:

$ renault-api --log status
  • Credentials will automatically be stored in the user home directory (~/.credentials/renault-api.json)

  • Logs will automatically be generated in logs subfolder

Please see the Command-line Reference for full details.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, Renault API is free and open source software.

Disclaimer

This project is not affiliated with, endorsed by, or connected to Renault. I accept no responsibility for any consequences, intended or accidental, as a as a result of interacting with Renault’s API using this project.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @cjolowicz’s Hypermodern Python Cookiecutter template. This project was heavily based on @jamesremuscat’s PyZE python client for the Renault ZE API.

CLI Usage

Renault high-level API Reference

Session

Client

Account

Vehicle

Kamereon low-level API Reference

Core

Data models

Gigya low-level authentication API Reference

Core

Data models

Renault endpoints

This is a list of the endpoints available, and their characteristics.

Vehicle data endpoints

battery-status
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/battery-status

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "timestamp": "2020-01-12T21:40:16Z",
      "batteryLevel": 60,
      "batteryTemperature": 20,
      "batteryAutonomy": 141,
      "batteryCapacity": 0,
      "batteryAvailableEnergy": 31,
      "plugStatus": 1,
      "chargingStatus": 1.0,
      "chargingRemainingTime": 145,
      "chargingInstantaneousPower": 27.0
    }
  }
}

Note

  • batteryTemperature is not always present.

  • batteryCapacity appears to always return 0.

On Zoe40 (model code X101VE):
  • chargingInstantaneousPower gives value in watts.

  • chargingStatus uses only a subset of ChargeStatus_ enum (NOT_IN_CHARGE = 0.0, CHARGE_IN_PROGRESS = 1.0, CHARGE_ERROR = -1.0)

On Zoe50 (model code X102VE):
  • batteryTemperature appears completely wrong.

  • chargingInstantaneousPower seems to return values in kilowatts, but the values still appear completely wrong.

charge-history
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-history

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "chargeSummaries": [
        {
          "day": "20201208",
          "totalChargesNumber": 2,
          "totalChargesDuration": 495,
          "totalChargesErrors": 0
        },
        {
          "day": "20201205",
          "totalChargesNumber": 1,
          "totalChargesDuration": 657,
          "totalChargesErrors": 0
        }
      ]
    }
  }
}
charge-mode
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-mode

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": { "chargeMode": "always" }
  }
}

Note

On older vehicles, such as Zoe40 (model code X101VE):

The return values appear to be always_charging and schedule_mode. This matches the vehicle_action.charge-mode action attributes.

On newer vehicles, such as Zoe50 (model code X102VE):

The return values appear to be always and scheduled. This DOES NOT match the vehicle_action.charge-mode action attributes.

charges
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charges

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "charges": [
        {
          "chargeStartDate": "2020-11-11T00:31:03Z",
          "chargeEndDate": "2020-11-11T08:30:17Z",
          "chargeDuration": 479,
          "chargeStartBatteryLevel": 15,
          "chargeEndBatteryLevel": 74,
          "chargeBatteryLevelRecovered": 59,
          "chargePower": "slow",
          "chargeStartInstantaneousPower": 3100,
          "chargeEndStatus": "ok"
        }
      ]
    }
  }
}
charging-settings
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charging-settings

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "mode": "scheduled",
      "schedules": [
        {
          "id": 1,
          "activated": true,
          "monday": {
            "startTime": "T12:00Z",
            "duration": 15
          },
          "tuesday": {
            "startTime": "T04:30Z",
            "duration": 420
          },
          "wednesday": {
            "startTime": "T22:30Z",
            "duration": 420
          },
          "thursday": {
            "startTime": "T22:00Z",
            "duration": 420
          },
          "friday": {
            "startTime": "T12:15Z",
            "duration": 15
          },
          "saturday": {
            "startTime": "T12:30Z",
            "duration": 30
          },
          "sunday": {
            "startTime": "T12:45Z",
            "duration": 45
          }
        }
      ]
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "mode": "scheduled",
      "schedules": [
        {
          "id": 1,
          "activated": true,
          "monday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "tuesday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "wednesday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "thursday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "friday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "saturday": {
            "startTime": "T00:00Z",
            "duration": 450
          },
          "sunday": {
            "startTime": "T00:00Z",
            "duration": 450
          }
        },
        {
          "id": 2,
          "activated": true,
          "monday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "tuesday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "wednesday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "thursday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "friday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "saturday": {
            "startTime": "T23:30Z",
            "duration": 15
          },
          "sunday": {
            "startTime": "T23:30Z",
            "duration": 15
          }
        },
        {
          "id": 3,
          "activated": false
        },
        {
          "id": 4,
          "activated": false
        },
        {
          "id": 5,
          "activated": false
        }
      ]
    }
  }
}
cockpit
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/cockpit

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777123",
    "attributes": {
      "fuelAutonomy": 35.0,
      "fuelQuantity": 3.0,
      "totalMileage": 5566.78
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "totalMileage": 49114.27
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": { "totalMileage": 49114.27 }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "fuelAutonomy": 0,
      "fuelQuantity": 0,
      "totalMileage": 5785.75
    }
  }
}
hvac-history
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-history

Sample return:

Sample data is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

hvac-sessions
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-sessions

Sample return:

Sample data is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

hvac-status
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-status

Sample return:
{
  "data": {
    "type": "Car",
    "id": "UU1AAAAA555777123",
    "attributes": {
      "socThreshold": 30.0,
      "hvacStatus": "off",
      "lastUpdateTime": "2020-12-03T00:00:00Z"
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": { "externalTemperature": 8.0, "hvacStatus": "off" }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": { "socThreshold": 40, "hvacStatus": "on" }
  }
}

Note

On Zoe40 (model code X101VE):

hvacStatus seems to always report off, even when preconditioning is in progress.

On Zoe50 (model code X102VE):

This endpoint seem to be unavailable and returns an error 'err.func.403': 'Operation not supported Operation not supported for this can (C1A)'.

hvac-settings
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-settings

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "dateTime": "2020-12-24T20:00:00.000Z",
      "mode": "scheduled",
      "schedules": [
        {
          "id": 1,
          "activated": false
        },
        {
          "id": 2,
          "activated": true,
          "wednesday": { "readyAtTime": "T15:15Z" },
          "friday": { "readyAtTime": "T15:15Z" }
        },
        {
          "id": 3,
          "activated": false
        },
        {
          "id": 4,
          "activated": false
        },
        {
          "id": 5,
          "activated": false
        }
      ]
    }
  }
}
location
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/location

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "gpsLatitude": 48.1234567,
      "gpsLongitude": 11.1234567,
      "lastUpdateTime": "2020-02-18T16:58:38Z"
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "gpsDirection": null,
      "gpsLatitude": 48.1234567,
      "gpsLongitude": 11.1234567,
      "lastUpdateTime": "2020-02-18T16:58:38Z"
    }
  }
}
lock-status
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/lock-status

Sample return:
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "lockStatus": "locked",
      "doorStatusRearLeft": "closed",
      "doorStatusRearRight": "closed",
      "doorStatusDriver": "closed",
      "doorStatusPassenger": "closed",
      "hatchStatus": "closed",
      "lastUpdateTime": "2022-02-02T13:51:13Z"
    }
  }
}
{
  "data": {
    "type": "Car",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "lockStatus": "unlocked",
      "doorStatusRearLeft": "closed",
      "doorStatusRearRight": "closed",
      "doorStatusDriver": "closed",
      "doorStatusPassenger": "closed",
      "hatchStatus": "closed",
      "lastUpdateTime": "2022-02-02T13:51:13Z"
    }
  }
}
notification-settings
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/notification-settings

Sample return:

Sample data is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

res-state
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/res-state

Sample return:
{
  "data": {
    "type": "ResState",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "details": "Stopped, ready for RES",
      "code": "10"
    }
  }
}
{
  "data": {
    "type": "ResState",
    "id": "VF1AAAAA555777999",
    "attributes": {
      "details": "Running",
      "code": "42"
    }
  }
}

Action endpoints

actions/charge-mode
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/actions/charge-mode

Sample payload:

Use instant charging:

{
   "data": {
      "type": "ChargeMode",
      "attributes": {"action": "always_charging"}
   }
}

Use scheduled charging:

{
   "data": {
      "type": "ChargeMode",
      "attributes": {"action": "schedule_mode"}
   }
}

Please check the Contributor Guide to provide extra samples.

Note

All vehicles seem to use always_charging and schedule_mode.

On older vehicles, such as Zoe40 (model code X101VE):

This matches the vehicle_data.charge-mode return values: always_charging and schedule_mode.

On newer vehicles, such as Zoe50 (model code X102VE):

This DOES NOT match the vehicle_data.charge-mode return values which are: always and scheduled.

actions/charge-schedule
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/actions/charge-schedule

Sample payload:

Sample payload is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

actions/charging-start
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/actions/charging-start

Sample payload:

Start charge:

{
   "data": {
      "type": "ChargingStart",
      "attributes": {"action": "start"}
   }
}

Stop charge:

{
   "data": {
      "type": "ChargingStart",
      "attributes": {"action": "stop"}
   }
}

Please check the Contributor Guide to provide extra samples.

actions/hvac-start
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/actions/hvac-start

Sample payload:

Sample payload is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

Note

On Zoe50 (model code X102VE):

Payload {'action': 'cancel'} to stop HVAC does not create errors but has no effect on the vehicle (Renault side limitation).

actions/hvac-schedule
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/actions/hvac-schedule

Sample payload:

Sample payload is not yet available for this endpoint.

Please check the Contributor Guide to provide a sample.

KCM Action endpoints

charge/pause-resume
Base url:

/commerce/v1/accounts/{account_id}/kamereon/kcm/v1/vehicles/{vin}/charge/pause-resume

Sample return:
{
  "data": {
    "type": "ChargePauseResume",
    "id": "guid",
    "attributes": { "action": "resume" }
  }
}
{
  "data": {
    "type": "ChargePauseResume",
    "id": "guid",
    "attributes": { "action": "pause" }
  }
}

Contributor Guide

Thank you for your interest in improving this project. This project is open-source under the MIT license and welcomes contributions in the form of bug reports, feature requests, and pull requests.

Here is a list of important resources for contributors:

How to report a bug

Report bugs on the Issue Tracker.

When filing an issue, make sure to answer these questions:

  • Which operating system and Python version are you using?

  • Which version of this project are you using?

  • What did you do?

  • What did you expect to see?

  • What did you see instead?

The best way to get your bug fixed is to provide a test case, and/or steps to reproduce the issue.

How to request a feature

Request features on the Issue Tracker.

Providing samples

Providing samples for more vehicles helps us improve the library. If you have a vehicle for which we do not have the specifications yet, or if you have found a new feature for an existing vehicle, then please send us the samples.

  • Generate a trace.

  • Add the json file to the correct test/fixtures/kamereon subfolder.

  • Ensure that vin starts with VF1AAAA _(we do not want the real VIN)_

  • Ensure that vehicleDetails.vin also starts with VF1AAAA _(we do not want the real VIN)_

  • Ensure that vehicleDetails.registrationNumber starts with REG- _(we do not want the real registration number)_

  • Ensure that vehicleDetails.radioCode is equal to 1234 _(we do not want the real radio code)_

  • Ensure that the json file passes pre-commit (can be parsed online via https://codebeautify.org/jsonviewer)

  • Create a pull request

How to set up your development environment

You need Python 3.8+ and the following tools:

WARNING: due to an open issue with Poetry, we recommand that you use the 1.0.10 version. You can install it with the commmand:

$ pipx install poetry==1.0.10

Install the package with development requirements:

$ poetry install --extras "cli"

You can now run an interactive Python session, or the command-line interface:

$ poetry run python
$ poetry run renault-api

How to test the project

Run the full test suite:

$ nox

List the available Nox sessions:

$ nox --list-sessions

You can also run a specific Nox session. For example, invoke the unit test suite like this:

$ nox --session=tests

Unit tests are located in the tests directory, and are written using the pytest testing framework.

How to submit changes

Open a pull request to submit changes to this project.

Your pull request needs to meet the following guidelines for acceptance:

  • The Nox test suite must pass without errors and warnings.

  • Include unit tests. This project maintains 100% code coverage.

  • If your changes add functionality, update the documentation accordingly.

Feel free to submit early, though—we can always iterate on this.

To run linting and code formatting checks before commiting your change, you can install pre-commit as a Git hook by running the following command:

$ nox --session=pre-commit -- install

It is recommended to open an issue before starting work on anything. This will allow a chance to talk it over with the owners and validate your approach.

Contributor Covenant Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

Our Standards

Examples of behavior that contributes to a positive environment for our community include:

  • Demonstrating empathy and kindness toward other people

  • Being respectful of differing opinions, viewpoints, and experiences

  • Giving and gracefully accepting constructive feedback

  • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience

  • Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

  • The use of sexualized language or imagery, and sexual attention or advances of any kind

  • Trolling, insulting or derogatory comments, and personal or political attacks

  • Public or private harassment

  • Publishing others’ private information, such as a physical or email address, without their explicit permission

  • Other conduct which could reasonably be considered inappropriate in a professional setting

Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at mail@tbd.com. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. Correction

Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

2. Warning

Community Impact: A violation through a single incident or series of actions.

Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

3. Temporary Ban

Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

4. Permanent Ban

Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

Consequence: A permanent ban from any sort of public interaction within the community.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

MIT License

Copyright © 2020 epenet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.