Skip to content

Commit

Permalink
Merge pull request #265 from Kolbi/master
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja authored Mar 7, 2024
2 parents f4bf375 + d0336c7 commit 77e36ba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion custom_components/audiconnect/audi_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async def refresh_vehicle_data(self, service):
async def _refresh_vehicle_data(self, vin):
res = await self.connection.refresh_vehicle_data(vin)

if res == True:
if res is True:
await self.update(utcnow())

self.hass.bus.fire(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/audiconnect/audi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def __get_headers(self):
"X-App-Name": "myAudi",
"User-Agent": self.HDR_USER_AGENT,
}
if self.__token != None:
if self.__token is not None:
data["Authorization"] = "Bearer " + self.__token.get("access_token")
if self.__xclientid != None:
if self.__xclientid is not None:
data["X-Client-ID"] = self.__xclientid

return data
Expand Down
16 changes: 8 additions & 8 deletions custom_components/audiconnect/audi_connect_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

from abc import ABC, abstractmethod

from .audi_services import AudiService
from .audi_api import AudiAPI
from .util import log_exception, get_attr, parse_int, parse_float

_LOGGER = logging.getLogger(__name__)

MAX_RESPONSE_ATTEMPTS = 10
REQUEST_STATUS_SLEEP = 5

from .audi_services import AudiService
from .audi_api import AudiAPI
from .util import log_exception, get_attr, parse_int, parse_float

ACTION_LOCK = "lock"
ACTION_CLIMATISATION = "climatisation"
ACTION_CHARGER = "charger"
Expand Down Expand Up @@ -400,10 +400,10 @@ async def update(self):
self._no_error = True
info = "statusreport"
await self.call_update(self.update_vehicle_statusreport, 3)
#info = "shortterm"
#await self.call_update(self.update_vehicle_shortterm, 3)
#info = "longterm"
#await self.call_update(self.update_vehicle_longterm, 3)
# info = "shortterm"
# await self.call_update(self.update_vehicle_shortterm, 3)
# info = "longterm"
# await self.call_update(self.update_vehicle_longterm, 3)
info = "position"
await self.call_update(self.update_vehicle_position, 3)
info = "climater"
Expand Down
18 changes: 9 additions & 9 deletions custom_components/audiconnect/audi_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ async def _fill_home_region(self, vin: str):
)
)
if (
res != None
and res.get("homeRegion") != None
and res["homeRegion"].get("baseUri") != None
and res["homeRegion"]["baseUri"].get("content") != None
res is not None
and res.get("homeRegion") is not None
and res["homeRegion"].get("baseUri") is not None
and res["homeRegion"]["baseUri"].get("content") is not None
):
uri = res["homeRegion"]["baseUri"]["content"]
if uri != "https://mal-1a.prd.ece.vwg-connect.com/api":
Expand All @@ -378,15 +378,15 @@ async def _fill_home_region(self, vin: str):
pass

async def _get_home_region(self, vin: str):
if self._homeRegion.get(vin) != None:
if self._homeRegion.get(vin) is not None:
return self._homeRegion[vin]

await self._fill_home_region(vin)

return self._homeRegion[vin]

async def _get_home_region_setter(self, vin: str):
if self._homeRegionSetter.get(vin) != None:
if self._homeRegionSetter.get(vin) is not None:
return self._homeRegionSetter[vin]

await self._fill_home_region(vin)
Expand Down Expand Up @@ -461,7 +461,7 @@ def _get_vehicle_action_header(self, content_type: str, security_token: str):
"Accept": "application/json, application/vnd.vwg.mbb.ChargerAction_v1_0_0+xml,application/vnd.volkswagenag.com-error-v1+xml,application/vnd.vwg.mbb.genericError_v1_0_2+xml, application/vnd.vwg.mbb.RemoteStandheizung_v2_0_0+xml, application/vnd.vwg.mbb.genericError_v1_0_2+xml,application/vnd.vwg.mbb.RemoteLockUnlock_v1_0_0+xml,*/*",
}

if security_token != None:
if security_token is not None:
headers["x-mbbSecToken"] = security_token

return headers
Expand Down Expand Up @@ -663,7 +663,7 @@ async def check_request_succeeded(

# TR/2022-12-20: New secrect for X_QMAuth
def _calculate_X_QMAuth(self):
# Calcualte X-QMAuth value
# Calculate X-QMAuth value
gmtime_100sec = int(
(datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() / 100
)
Expand Down Expand Up @@ -713,7 +713,7 @@ def _calculate_X_QMAuth(self):
return "v1:01da27b0:" + xqmauth_val

# TR/2021-12-01: Refresh token before it expires
# returns True when refresh was required and succesful, otherwise False
# returns True when refresh was required and successful, otherwise False
async def refresh_token_if_necessary(self, elapsed_sec: int) -> bool:
if self.mbboauthToken is None:
return False
Expand Down
4 changes: 2 additions & 2 deletions custom_components/audiconnect/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def str_state(self):
@property
def state(self):
val = super().state
if val and self._unit and "mi" in self._unit and self._convert == True:
if val and self._unit and "mi" in self._unit and self._convert is True:
return round(val / 1.609344)
elif val and self._unit and "km" in self._unit and self._convert == True:
elif val and self._unit and "km" in self._unit and self._convert is True:
return round(val * 1.609344)
else:
return val
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

[![hacs][hacsbadge]](hacs)

## Notice

Due to API changes it might be that currently not all functionality is given. Please open a issue to report the topics you are missing.

## Maintainers Wanted

Due to time limitations this project is not actively maintained anymore. It will continue to work as long as Audi does not change the API again.
Expand Down

0 comments on commit 77e36ba

Please sign in to comment.