Skip to content

Commit

Permalink
fix: stop warning on home assistant startup (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
maruel authored Oct 28, 2024
1 parent 83842ae commit a46978d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 11 additions & 4 deletions hyundai_kia_connect_api/KiaUvoAPIUSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ def __init__(self, region: int, brand: int, language) -> None:

self.BASE_URL: str = "api.owners.kia.com"
self.API_URL: str = "https://" + self.BASE_URL + "/apigw/v1/"
self.session = requests.Session()
self.session.mount("https://", KiaSSLAdapter())
self._session = None

@property
def session(self):
if not self._session:
self._session = requests.Session()
self._session.mount("https://", KiaSSLAdapter())
return self._session

def api_headers(self) -> dict:
offset = time.localtime().tm_gmtoff / 60 / 60
Expand Down Expand Up @@ -653,8 +659,9 @@ def start_climate(
},
}

# Kia seems to now be checking if you can set the heated/vented seats at the car level
# only add to body if the option is not none for any of the seats
# Kia seems to now be checking if you can set the heated/vented seats at
# the car level only add to body if the option is not none for any of
# the seats
if (
options.front_left_seat is not None
or options.front_right_seat is not None
Expand Down
10 changes: 8 additions & 2 deletions hyundai_kia_connect_api/KiaUvoApiCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ def __init__(self, region: int, brand: int, language: str) -> None:
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
}
self.sessions = requests.Session()
self.sessions.mount("https://" + self.BASE_URL, cipherAdapter())
self._sessions = None

@property
def sessions(self):
if not self._sessions:
self._sessions = requests.Session()
self._sessions.mount("https://" + self.BASE_URL, cipherAdapter())
return self._sessions

def _check_response_for_errors(self, response: dict) -> None:
"""
Expand Down

0 comments on commit a46978d

Please sign in to comment.