Bump total_connect_client to 2021.11.2 (#58818)
* update total_connect_client to 2021.10 * update for total_connect_client changes * remove unused return value * bump total_connect_client to 2021.11.1 * bump total_connect_client to 2021.11.2 * Move to public ResultCode * load locations to prevent 'unknown error occurred' * add test for zero locations * Revert "load locations to prevent 'unknown error occurred'" This reverts commitpull/59397/head28b8984be5
. * Revert "add test for zero locations" This reverts commit77bf7908d5
.
parent
189677c713
commit
c150a296d2
|
@ -38,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
TotalConnectClient, username, password, usercodes
|
||||
)
|
||||
|
||||
if not client.is_valid_credentials():
|
||||
if not client.is_logged_in():
|
||||
raise ConfigEntryAuthFailed("TotalConnect authentication failed")
|
||||
|
||||
coordinator = TotalConnectDataUpdateCoordinator(hass, client)
|
||||
|
@ -88,5 +88,3 @@ class TotalConnectDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
raise UpdateFailed(exception) from exception
|
||||
except ValueError as exception:
|
||||
raise UpdateFailed("Unknown state from TotalConnect") from exception
|
||||
|
||||
return True
|
||||
|
|
|
@ -40,7 +40,7 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
TotalConnectClient, username, password, None
|
||||
)
|
||||
|
||||
if client.is_valid_credentials():
|
||||
if client.is_logged_in():
|
||||
# username/password valid so show user locations
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
@ -136,7 +136,7 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.usercodes,
|
||||
)
|
||||
|
||||
if not client.is_valid_credentials():
|
||||
if not client.is_logged_in():
|
||||
errors["base"] = "invalid_auth"
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "totalconnect",
|
||||
"name": "Total Connect",
|
||||
"documentation": "https://www.home-assistant.io/integrations/totalconnect",
|
||||
"requirements": ["total_connect_client==2021.8.3"],
|
||||
"requirements": ["total_connect_client==2021.11.2"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@austinmroczek"],
|
||||
"config_flow": true,
|
||||
|
|
|
@ -2314,7 +2314,7 @@ todoist-python==8.0.0
|
|||
toonapi==0.2.1
|
||||
|
||||
# homeassistant.components.totalconnect
|
||||
total_connect_client==2021.8.3
|
||||
total_connect_client==2021.11.2
|
||||
|
||||
# homeassistant.components.tplink_lte
|
||||
tp-connected==0.0.4
|
||||
|
|
|
@ -1330,7 +1330,7 @@ tesla-powerwall==0.3.12
|
|||
toonapi==0.2.1
|
||||
|
||||
# homeassistant.components.totalconnect
|
||||
total_connect_client==2021.8.3
|
||||
total_connect_client==2021.11.2
|
||||
|
||||
# homeassistant.components.transmission
|
||||
transmissionrpc==0.11
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
"""Common methods used across tests for TotalConnect."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from total_connect_client.client import TotalConnectClient
|
||||
from total_connect_client.const import ArmingState
|
||||
from total_connect_client.zone import ZoneStatus, ZoneType
|
||||
from total_connect_client import ArmingState, ResultCode, ZoneStatus, ZoneType
|
||||
|
||||
from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
|
@ -44,7 +42,7 @@ USER = {
|
|||
}
|
||||
|
||||
RESPONSE_AUTHENTICATE = {
|
||||
"ResultCode": TotalConnectClient.SUCCESS,
|
||||
"ResultCode": ResultCode.SUCCESS.value,
|
||||
"SessionID": 1,
|
||||
"Locations": LOCATIONS,
|
||||
"ModuleFlags": MODULE_FLAGS,
|
||||
|
@ -52,7 +50,7 @@ RESPONSE_AUTHENTICATE = {
|
|||
}
|
||||
|
||||
RESPONSE_AUTHENTICATE_FAILED = {
|
||||
"ResultCode": TotalConnectClient.BAD_USER_OR_PASSWORD,
|
||||
"ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value,
|
||||
"ResultData": "test bad authentication",
|
||||
}
|
||||
|
||||
|
@ -255,18 +253,18 @@ RESPONSE_UNKNOWN = {
|
|||
"ArmingState": ArmingState.DISARMED,
|
||||
}
|
||||
|
||||
RESPONSE_ARM_SUCCESS = {"ResultCode": TotalConnectClient.ARM_SUCCESS}
|
||||
RESPONSE_ARM_FAILURE = {"ResultCode": TotalConnectClient.COMMAND_FAILED}
|
||||
RESPONSE_DISARM_SUCCESS = {"ResultCode": TotalConnectClient.DISARM_SUCCESS}
|
||||
RESPONSE_ARM_SUCCESS = {"ResultCode": ResultCode.ARM_SUCCESS.value}
|
||||
RESPONSE_ARM_FAILURE = {"ResultCode": ResultCode.COMMAND_FAILED.value}
|
||||
RESPONSE_DISARM_SUCCESS = {"ResultCode": ResultCode.DISARM_SUCCESS.value}
|
||||
RESPONSE_DISARM_FAILURE = {
|
||||
"ResultCode": TotalConnectClient.COMMAND_FAILED,
|
||||
"ResultCode": ResultCode.COMMAND_FAILED.value,
|
||||
"ResultData": "Command Failed",
|
||||
}
|
||||
RESPONSE_USER_CODE_INVALID = {
|
||||
"ResultCode": TotalConnectClient.USER_CODE_INVALID,
|
||||
"ResultCode": ResultCode.USER_CODE_INVALID.value,
|
||||
"ResultData": "testing user code invalid",
|
||||
}
|
||||
RESPONSE_SUCCESS = {"ResultCode": TotalConnectClient.SUCCESS}
|
||||
RESPONSE_SUCCESS = {"ResultCode": ResultCode.SUCCESS.value}
|
||||
|
||||
USERNAME = "username@me.com"
|
||||
PASSWORD = "password"
|
||||
|
@ -292,7 +290,7 @@ PARTITION_DETAILS_2 = {
|
|||
|
||||
PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]}
|
||||
RESPONSE_PARTITION_DETAILS = {
|
||||
"ResultCode": TotalConnectClient.SUCCESS,
|
||||
"ResultCode": ResultCode.SUCCESS.value,
|
||||
"ResultData": "testing partition details",
|
||||
"PartitionsInfoList": PARTITION_DETAILS,
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ async def test_abort_if_already_setup(hass):
|
|||
with patch(
|
||||
"homeassistant.components.totalconnect.config_flow.TotalConnectClient"
|
||||
) as client_mock:
|
||||
client_mock.return_value.is_valid_credentials.return_value = True
|
||||
client_mock.return_value.is_logged_in.return_value = True
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
|
@ -111,7 +111,7 @@ async def test_login_failed(hass):
|
|||
with patch(
|
||||
"homeassistant.components.totalconnect.config_flow.TotalConnectClient"
|
||||
) as client_mock:
|
||||
client_mock.return_value.is_valid_credentials.return_value = False
|
||||
client_mock.return_value.is_logged_in.return_value = False
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
|
@ -143,7 +143,7 @@ async def test_reauth(hass):
|
|||
"homeassistant.components.totalconnect.async_setup_entry", return_value=True
|
||||
):
|
||||
# first test with an invalid password
|
||||
client_mock.return_value.is_valid_credentials.return_value = False
|
||||
client_mock.return_value.is_logged_in.return_value = False
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||
|
@ -153,7 +153,7 @@ async def test_reauth(hass):
|
|||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
# now test with the password valid
|
||||
client_mock.return_value.is_valid_credentials.return_value = True
|
||||
client_mock.return_value.is_logged_in.return_value = True
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||
|
|
|
@ -22,7 +22,7 @@ async def test_reauth_started(hass):
|
|||
"homeassistant.components.totalconnect.TotalConnectClient",
|
||||
autospec=True,
|
||||
) as mock_client:
|
||||
mock_client.return_value.is_valid_credentials.return_value = False
|
||||
mock_client.return_value.is_logged_in.return_value = False
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
|
Loading…
Reference in New Issue