-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexample.py
83 lines (67 loc) · 2.71 KB
/
example.py
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
"""Example."""
import asyncio
import logging
from aiohttp import ClientSession
import yaml
from audiconnectpy import AudiConnect, AudiException
# create console handler and set level to debug
logger = logging.getLogger()
logger.setLevel("DEBUG")
ch = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
# Fill out the secrets in secrets.yaml, you can find an example
# _secrets.yaml file, which has to be renamed after filling out the secrets.
with open("./secrets.yaml", encoding="UTF-8") as file:
secrets = yaml.safe_load(file)
USERNAME = secrets["USERNAME"]
PASSWORD = secrets["PASSWORD"]
COUNTRY = "FR"
SPIN = secrets["SPIN"]
async def main() -> None:
"""Run Main method."""
async with ClientSession() as session:
api = AudiConnect(session, USERNAME, PASSWORD, COUNTRY, SPIN)
try:
await api.async_login()
except AudiException as error:
logger.error(error)
while api.is_connected:
try:
for vehicle in api.vehicles:
logger.info(vehicle.vin)
logger.info(vehicle.infos)
logger.info(vehicle.fuel_status)
logger.info(vehicle.last_access)
logger.info(vehicle.position)
# logger.info(vehicle.location)
logger.info(vehicle.access)
logger.info(vehicle.charging)
logger.info(vehicle.climatisation)
logger.info(vehicle.climatisation_timers)
logger.info(vehicle.oil_level)
logger.info(vehicle.vehicle_lights)
logger.info(vehicle.vehicle_health_inspection)
logger.info(vehicle.measurements)
logger.info(vehicle.vehicle_health_warnings)
logger.info(vehicle.infos)
# Lock vehicle if spin
# --------------------
# await vehicle.async_set_lock(True)
# Refresh call remote vehicle
# --------------------
# await vehicle.async_refresh_vehicle_data()
# await vehicle.async_wakeup()
# Update Audi API
# --------------------
# await vehicle.async_update()
except AudiException as error:
logger.error(error)
finally:
await asyncio.sleep(600)
await api.async_close()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
asyncio.run(main())