fetch.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. import os
  3. import aiohttp
  4. import asyncio
  5. from pprint import pprint as pp
  6. from renault_api.renault_client import RenaultClient
  7. async def main():
  8. async with aiohttp.ClientSession() as websession:
  9. client = RenaultClient(websession=websession, locale="fr_FR")
  10. await client.session.login(os.environ.get('RENAULT_USERNAME'), os.environ.get('RENAULT_PASSWORD'))
  11. #print(f"Accounts: {await client.get_person()}") # List available accounts, make a note of kamereon account id
  12. account = await client.get_api_account(os.environ.get('RENAULT_ACCOUNT_ID'))
  13. #print(f"Vehicles: {await account.get_vehicles()}") # List available vehicles, make a note of vehicle VIN
  14. vehicle = await account.get_api_vehicle(os.environ.get('RENAULT_VIN'))
  15. info_cockpit = await vehicle.get_cockpit()
  16. info_battery = await vehicle.get_battery_status()
  17. pp(info_cockpit)
  18. pp(info_battery)
  19. loop = asyncio.new_event_loop()
  20. asyncio.set_event_loop(loop)
  21. try:
  22. asyncio.run(main())
  23. except KeyboardInterrupt:
  24. pass