Skip to content

Commit

Permalink
Bump total-connect-client to 2025.1.4 (#136793)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinmroczek authored Jan 31, 2025
1 parent fc979cd commit 270108e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 26 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/totalconnect/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def __init__(
) -> None:
"""Initialize the TotalConnect status."""
super().__init__(coordinator, location)
self._partition_id = partition_id
self._partition_id = int(partition_id)
self._partition = self._location.partitions[partition_id]

"""
Set unique_id to location_id for partition 1 to avoid breaking change
for most users with new support for partitions.
Add _# for partition 2 and beyond.
"""
if partition_id == 1:
if int(partition_id) == 1:
self._attr_name = None
self._attr_unique_id = str(location.location_id)
else:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/totalconnect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/totalconnect",
"iot_class": "cloud_polling",
"loggers": ["total_connect_client"],
"requirements": ["total-connect-client==2024.12"]
"requirements": ["total-connect-client==2025.1.4"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt

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

2 changes: 1 addition & 1 deletion requirements_test_all.txt

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

39 changes: 23 additions & 16 deletions tests/components/totalconnect/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,15 @@
"UserFeatureList": "Master=0,User Administration=0,Configuration Administration=0",
}

RESPONSE_AUTHENTICATE = {
RESPONSE_SESSION_DETAILS = {
"ResultCode": ResultCode.SUCCESS.value,
"SessionID": 1,
"ResultData": "Success",
"SessionID": "12345",
"Locations": LOCATIONS,
"ModuleFlags": MODULE_FLAGS,
"UserInfo": USER,
}

RESPONSE_AUTHENTICATE_FAILED = {
"ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value,
"ResultData": "test bad authentication",
}


PARTITION_DISARMED = {
"PartitionID": "1",
"ArmingState": ArmingState.DISARMED,
Expand Down Expand Up @@ -359,13 +354,13 @@
OPTIONS_DATA_CODE_REQUIRED = {AUTO_BYPASS: False, CODE_REQUIRED: True}

PARTITION_DETAILS_1 = {
"PartitionID": 1,
"PartitionID": "1",
"ArmingState": ArmingState.DISARMED.value,
"PartitionName": "Test1",
}

PARTITION_DETAILS_2 = {
"PartitionID": 2,
"PartitionID": "2",
"ArmingState": ArmingState.DISARMED.value,
"PartitionName": "Test2",
}
Expand Down Expand Up @@ -402,6 +397,12 @@
TOTALCONNECT_REQUEST = (
"homeassistant.components.totalconnect.TotalConnectClient.request"
)
TOTALCONNECT_GET_CONFIG = (
"homeassistant.components.totalconnect.TotalConnectClient._get_configuration"
)
TOTALCONNECT_REQUEST_TOKEN = (
"homeassistant.components.totalconnect.TotalConnectClient._request_token"
)


async def setup_platform(
Expand All @@ -420,7 +421,7 @@ async def setup_platform(
mock_entry.add_to_hass(hass)

responses = [
RESPONSE_AUTHENTICATE,
RESPONSE_SESSION_DETAILS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_DISARMED,
Expand All @@ -433,6 +434,8 @@ async def setup_platform(
TOTALCONNECT_REQUEST,
side_effect=responses,
) as mock_request,
patch(TOTALCONNECT_GET_CONFIG, side_effect=None),
patch(TOTALCONNECT_REQUEST_TOKEN, side_effect=None),
):
assert await async_setup_component(hass, DOMAIN, {})
assert mock_request.call_count == 5
Expand All @@ -448,17 +451,21 @@ async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
mock_entry.add_to_hass(hass)

responses = [
RESPONSE_AUTHENTICATE,
RESPONSE_SESSION_DETAILS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_DISARMED,
RESPONSE_DISARMED,
]

with patch(
TOTALCONNECT_REQUEST,
side_effect=responses,
) as mock_request:
with (
patch(
TOTALCONNECT_REQUEST,
side_effect=responses,
) as mock_request,
patch(TOTALCONNECT_GET_CONFIG, side_effect=None),
patch(TOTALCONNECT_REQUEST_TOKEN, side_effect=None),
):
await hass.config_entries.async_setup(mock_entry.entry_id)
assert mock_request.call_count == 5
await hass.async_block_till_done()
Expand Down
20 changes: 15 additions & 5 deletions tests/components/totalconnect/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
from .common import (
CONFIG_DATA,
CONFIG_DATA_NO_USERCODES,
RESPONSE_AUTHENTICATE,
RESPONSE_DISARMED,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_SESSION_DETAILS,
RESPONSE_SUCCESS,
RESPONSE_USER_CODE_INVALID,
TOTALCONNECT_GET_CONFIG,
TOTALCONNECT_REQUEST,
TOTALCONNECT_REQUEST_TOKEN,
USERNAME,
)

Expand All @@ -48,7 +50,7 @@ async def test_user_show_locations(hass: HomeAssistant) -> None:
"""Test user locations form."""
# user/pass provided, so check if valid then ask for usercodes on locations form
responses = [
RESPONSE_AUTHENTICATE,
RESPONSE_SESSION_DETAILS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_DISARMED,
Expand All @@ -61,6 +63,8 @@ async def test_user_show_locations(hass: HomeAssistant) -> None:
TOTALCONNECT_REQUEST,
side_effect=responses,
) as mock_request,
patch(TOTALCONNECT_GET_CONFIG, side_effect=None),
patch(TOTALCONNECT_REQUEST_TOKEN, side_effect=None),
patch(
"homeassistant.components.totalconnect.async_setup_entry", return_value=True
),
Expand Down Expand Up @@ -180,7 +184,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
async def test_no_locations(hass: HomeAssistant) -> None:
"""Test with no user locations."""
responses = [
RESPONSE_AUTHENTICATE,
RESPONSE_SESSION_DETAILS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_DISARMED,
Expand All @@ -191,6 +195,8 @@ async def test_no_locations(hass: HomeAssistant) -> None:
TOTALCONNECT_REQUEST,
side_effect=responses,
) as mock_request,
patch(TOTALCONNECT_GET_CONFIG, side_effect=None),
patch(TOTALCONNECT_REQUEST_TOKEN, side_effect=None),
patch(
"homeassistant.components.totalconnect.async_setup_entry", return_value=True
),
Expand Down Expand Up @@ -221,15 +227,19 @@ async def test_options_flow(hass: HomeAssistant) -> None:
config_entry.add_to_hass(hass)

responses = [
RESPONSE_AUTHENTICATE,
RESPONSE_SESSION_DETAILS,
RESPONSE_PARTITION_DETAILS,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
RESPONSE_DISARMED,
RESPONSE_DISARMED,
RESPONSE_DISARMED,
]

with patch(TOTALCONNECT_REQUEST, side_effect=responses):
with (
patch(TOTALCONNECT_REQUEST, side_effect=responses),
patch(TOTALCONNECT_GET_CONFIG, side_effect=None),
patch(TOTALCONNECT_REQUEST_TOKEN, side_effect=None),
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()

Expand Down

0 comments on commit 270108e

Please sign in to comment.