File: README.rst

package info (click to toggle)
python-renault-api 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,696 kB
  • sloc: python: 7,804; makefile: 2
file content (174 lines) | stat: -rw-r--r-- 5,847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Renault API
===========

|PyPI| |Python Version| |License|

|Read the Docs| |Tests| |Codecov|

|pre-commit| |Ruff|

.. |PyPI| image:: https://img.shields.io/pypi/v/renault-api.svg
   :target: https://pypi.org/project/renault-api/
   :alt: PyPI
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/renault-api
   :target: https://pypi.org/project/renault-api
   :alt: Python Version
.. |License| image:: https://img.shields.io/pypi/l/renault-api
   :target: https://opensource.org/licenses/MIT
   :alt: License
.. |Read the Docs| image:: https://img.shields.io/readthedocs/renault-api/latest.svg?label=Read%20the%20Docs
   :target: https://renault-api.readthedocs.io/
   :alt: Read the documentation at https://renault-api.readthedocs.io/
.. |Tests| image:: https://github.com/hacf-fr/renault-api/workflows/Tests/badge.svg
   :target: https://github.com/hacf-fr/renault-api/actions?workflow=Tests
   :alt: Tests
.. |Codecov| image:: https://codecov.io/gh/hacf-fr/renault-api/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/hacf-fr/renault-api
   :alt: Codecov
.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
   :target: https://github.com/pre-commit/pre-commit
   :alt: pre-commit
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
    :target: https://github.com/astral-sh/ruff
    :alt: Ruff


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.10)

API Usage
---------

You can install *Renault API* via pip_ from PyPI_:

.. code:: console

   $ pip install renault-api

.. code:: python

   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_:

.. code:: console

   $ pip install renault-api[cli]

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

.. code:: console

   $ 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

It is also possible to use raw http GET/POST commands, for example to get odometer and others data on a Windows machine:

.. code:: console

  C:> renault-api http get /commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/cockpit

Or to request a battery status refresh on a Windows Machine (internal quotes escaped, whole payload enclosed in un-escaped quotes):

.. code:: console

  C:> renault-api http post /commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/actions/refresh-battery-status "{\\"data\\": {\\"type\\": \\"RefreshBatteryStatus\\"}}"

Please see the `Command-line Reference <Usage_>`_ 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.


.. _@cjolowicz: https://github.com/cjolowicz
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _@jamesremuscat: https://github.com/jamesremuscat
.. _PyZE: https://github.com/jamesremuscat/pyze
.. _MIT: http://opensource.org/licenses/MIT
.. _PyPI: https://pypi.org/
.. _Hypermodern Python Cookiecutter: https://github.com/cjolowicz/cookiecutter-hypermodern-python
.. _file an issue: https://github.com/hacf-fr/renault-api/issues
.. _pip: https://pip.pypa.io/
.. github-only
.. _Contributor Guide: CONTRIBUTING.rst
.. _Usage: https://renault-api.readthedocs.io/en/latest/usage.html