Skip to content

Commit

Permalink
Update pySwitchbot to 0.46.0 to fix lock key retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed May 23, 2024
1 parent d1af40f commit ad4ab62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions homeassistant/components/switchbot/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .const import (
CONF_ENCRYPTION_KEY,
Expand Down Expand Up @@ -175,8 +176,8 @@ async def async_step_lock_auth(
description_placeholders = {}
if user_input is not None:
try:
key_details = await self.hass.async_add_executor_job(
SwitchbotLock.retrieve_encryption_key,
key_details = await SwitchbotLock.async_retrieve_encryption_key(
async_get_clientsession(self.hass),
self._discovered_adv.address,
user_input[CONF_USERNAME],
user_input[CONF_PASSWORD],
Expand Down
6 changes: 3 additions & 3 deletions tests/components/switchbot/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ async def test_user_setup_wolock_auth(hass: HomeAssistant) -> None:
assert result["errors"] == {}

with patch(

Check failure on line 489 in tests/components/switchbot/test_config_flow.py

View workflow job for this annotation

GitHub Actions / Run tests Python 3.12 (switchbot)

test_user_setup_wolock_auth AttributeError: <class 'switchbot.devices.lock.SwitchbotLock'> does not have the attribute 'async_retrieve_encryption_key'
"homeassistant.components.switchbot.config_flow.SwitchbotLock.retrieve_encryption_key",
"homeassistant.components.switchbot.config_flow.SwitchbotLock.async_retrieve_encryption_key",
side_effect=SwitchbotAuthenticationError("error from api"),
):
result = await hass.config_entries.flow.async_configure(
Expand All @@ -510,7 +510,7 @@ async def test_user_setup_wolock_auth(hass: HomeAssistant) -> None:
return_value=True,
),
patch(
"homeassistant.components.switchbot.config_flow.SwitchbotLock.retrieve_encryption_key",
"homeassistant.components.switchbot.config_flow.SwitchbotLock.async_retrieve_encryption_key",
return_value={
CONF_KEY_ID: "ff",
CONF_ENCRYPTION_KEY: "ffffffffffffffffffffffffffffffff",
Expand Down Expand Up @@ -560,7 +560,7 @@ async def test_user_setup_wolock_auth_switchbot_api_down(hass: HomeAssistant) ->
assert result["errors"] == {}

with patch(

Check failure on line 562 in tests/components/switchbot/test_config_flow.py

View workflow job for this annotation

GitHub Actions / Run tests Python 3.12 (switchbot)

test_user_setup_wolock_auth_switchbot_api_down AttributeError: <class 'switchbot.devices.lock.SwitchbotLock'> does not have the attribute 'async_retrieve_encryption_key'
"homeassistant.components.switchbot.config_flow.SwitchbotLock.retrieve_encryption_key",
"homeassistant.components.switchbot.config_flow.SwitchbotLock.async_retrieve_encryption_key",
side_effect=SwitchbotAccountConnectionError,
):
result = await hass.config_entries.flow.async_configure(
Expand Down

0 comments on commit ad4ab62

Please sign in to comment.