Skip to content

Commit

Permalink
Merge pull request #197 from zabuldon/dev
Browse files Browse the repository at this point in the history
2021-04-28
  • Loading branch information
alandtse committed May 1, 2021
2 parents e5f93d1 + a34da72 commit 024d4ec
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 31 deletions.
45 changes: 29 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ aiohttp = "^3.7.4"
backoff = "^1.10.0"
beautifulsoup4 = "^4.9.3"
wrapt = "^1.12.1"
authcaptureproxy = "~=1.0.0"
httpx = "^0.17.1"
authcaptureproxy = "^1.0.1"
httpx = ">=0.17.1, <1.0"

[tool.poetry.dev-dependencies]
flake8 = "^3.9.0"
Expand Down
12 changes: 6 additions & 6 deletions teslajsonpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ async def get_authorization_code(
return
url = self.get_authorization_code_link(new=True)
resp = await self.websession.get(str(url.update_query({"login_hint": email})))
html = await resp.text()
html = resp.text
if resp.history:
for item in resp.history:
if (
Expand All @@ -427,7 +427,7 @@ async def get_authorization_code(
resp = await self.websession.post(str(url), data=data)
_process_resp(resp)
if not resp.history:
html = await resp.text()
html = resp.text
if "/mfa/verify" in html:
_LOGGER.debug("Detected MFA request")
mfa_resp = await self.websession.get(
Expand Down Expand Up @@ -600,11 +600,11 @@ def _process_resp(resp) -> Text:
if resp.history:
for item in resp.history:
_LOGGER.debug("%s: redirected from\n%s", item.method, item.url)
url = str(resp.request_info.url)
method = resp.request_info.method
url = str(resp.request.url)
method = resp.request.method
status = resp.status_code
reason = resp.reason
headers = resp.request_info.headers
reason = resp.reason_phrase
headers = resp.request.headers
_LOGGER.debug(
"%s: \n%s with\n%s\n returned %s:%s with response %s",
method,
Expand Down
14 changes: 8 additions & 6 deletions teslajsonpy/homeassistant/heated_seats.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, data, controller, seat_name):
"""
super().__init__(data, controller)
self.__manual_update_time = 0
self.__seat_heat_level = data['climate_state'][f'seat_heater_{seat_name}']
self.__seat_heat_level = None
self.__seat_name = seat_name

self.type = f"heated seat {seat_name}"
Expand All @@ -69,15 +69,17 @@ def refresh(self) -> None:
last_update = self._controller.get_last_update_time(self._id)
if last_update >= self.__manual_update_time:
data = self._controller.get_climate_params(self._id)
self.__seat_heat_level = data[f'seat_heater_{self.__seat_name}'] if data else None
self.__seat_heat_level = (
data[f"seat_heater_{self.__seat_name}"] if data else None
)

async def set_seat_heat_level(self, level):
"""Set heated seat level."""
data = await self._controller.command(
self._id, "remote_seat_heater_request", data={
'heater': seat_id_map[self.__seat_name],
'level': level
}, wake_if_asleep=True
self._id,
"remote_seat_heater_request",
data={"heater": seat_id_map[self.__seat_name], "level": level},
wake_if_asleep=True,
)
if data and data["response"]["result"]:
self.__seat_heat_level = level
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/homeassistant/test_heated_seat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_get_seat_heat_level_on_init(monkeypatch):
_seat = HeatedSeatSwitch(_data, _controller, 'left')

assert not _seat is None
assert _seat.get_seat_heat_level() == 3 # 3 is mocked initial level for left seat from tesla_mock.py
assert not _seat.get_seat_heat_level()


@pytest.mark.asyncio
Expand Down

0 comments on commit 024d4ec

Please sign in to comment.