Nikola Kotur 3 tygodni temu
commit
4e2e4f3b0d
4 zmienionych plików z 87 dodań i 0 usunięć
  1. 4 0
      .gitignore
  2. 33 0
      README.md
  3. 32 0
      fetch.py
  4. 18 0
      requirements.txt

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.env
+*~
+NOTES
+logs/*

+ 33 - 0
README.md

@@ -0,0 +1,33 @@
+# Renault API management
+
+## Environment
+
+RENAULT_USERNAME
+RENAULT_PASSWORD
+RENAULT_ACCOUNT_ID
+RENAULT_VIN
+
+## Getting info via CLI
+
+```
+$ renault-api --log status 
+Please select a locale [en_US]: fr_FR                                          
+Do you want to save the locale to the credential store? [y/N]: y                                                                                               
+                                       
+User: nikola.kotur@gmail.com                                                   
+Password:                                                                      
+
+    ID                                    Type         Vehicles
+--  ------------------------------------  ---------  ----------
+ 1                                        MYRENAULT           1
+
+Please select account [1]: 1
+Do you want to save the account ID to the credential store? [y/N]: y
+
+    Vin                Registration    Brand    Model
+--  -----------------  --------------  -------  ----------
+ 1                                     RENAULT  TWINGO III
+
+Please select vehicle [1]: 1
+Do you want to save the VIN to the credential store? [y/N]: y
+```

+ 32 - 0
fetch.py

@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+import os
+import aiohttp
+import asyncio
+from pprint import pprint as pp
+
+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(os.environ.get('RENAULT_USERNAME'), os.environ.get('RENAULT_PASSWORD'))
+        #print(f"Accounts: {await client.get_person()}") # List available accounts, make a note of kamereon account id
+
+        account = await client.get_api_account(os.environ.get('RENAULT_ACCOUNT_ID'))
+        #print(f"Vehicles: {await account.get_vehicles()}") # List available vehicles, make a note of vehicle VIN
+
+        vehicle = await account.get_api_vehicle(os.environ.get('RENAULT_VIN'))
+
+        info_cockpit = await vehicle.get_cockpit()
+        info_battery = await vehicle.get_battery_status()
+
+    pp(info_cockpit)
+    pp(info_battery)
+
+
+loop = asyncio.new_event_loop()
+asyncio.set_event_loop(loop)
+try:
+    asyncio.run(main())
+except KeyboardInterrupt:
+    pass

+ 18 - 0
requirements.txt

@@ -0,0 +1,18 @@
+aiohttp==3.9.5
+aiosignal==1.3.1
+attrs==23.2.0
+cffi==1.16.0
+cryptography==42.0.5
+frozenlist==1.4.1
+idna==3.7
+marshmallow==3.21.1
+marshmallow_dataclass==8.6.1
+multidict==6.0.5
+mypy-extensions==1.0.0
+packaging==24.0
+pycparser==2.22
+PyJWT==2.8.0
+renault-api==0.2.2
+typing-inspect==0.9.0
+typing_extensions==4.11.0
+yarl==1.9.4