Ensure HomeKit connection is kept alive for devices that timeout too quickly (#123601)

This commit is contained in:
J. Nick Koston 2024-08-12 07:54:57 -05:00 committed by GitHub
parent f6e82ae0ba
commit b20623447e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 15 deletions

View file

@ -344,10 +344,10 @@ async def test_thread_provision_migration_failed(hass: HomeAssistant) -> None:
assert config_entry.data["Connection"] == "BLE"
async def test_skip_polling_all_watchable_accessory_mode(
async def test_poll_firmware_version_only_all_watchable_accessory_mode(
hass: HomeAssistant, get_next_aid: Callable[[], int]
) -> None:
"""Test that we skip polling if available and all chars are watchable accessory mode."""
"""Test that we only poll firmware if available and all chars are watchable accessory mode."""
def _create_accessory(accessory):
service = accessory.add_service(ServicesTypes.LIGHTBULB, name="TestDevice")
@ -370,7 +370,10 @@ async def test_skip_polling_all_watchable_accessory_mode(
# Initial state is that the light is off
state = await helper.poll_and_get_state()
assert state.state == STATE_OFF
assert mock_get_characteristics.call_count == 0
assert mock_get_characteristics.call_count == 2
# Verify only firmware version is polled
assert mock_get_characteristics.call_args_list[0][0][0] == {(1, 7)}
assert mock_get_characteristics.call_args_list[1][0][0] == {(1, 7)}
# Test device goes offline
helper.pairing.available = False
@ -382,16 +385,16 @@ async def test_skip_polling_all_watchable_accessory_mode(
state = await helper.poll_and_get_state()
assert state.state == STATE_UNAVAILABLE
# Tries twice before declaring unavailable
assert mock_get_characteristics.call_count == 2
assert mock_get_characteristics.call_count == 4
# Test device comes back online
helper.pairing.available = True
state = await helper.poll_and_get_state()
assert state.state == STATE_OFF
assert mock_get_characteristics.call_count == 3
assert mock_get_characteristics.call_count == 6
# Next poll should not happen because its a single
# accessory, available, and all chars are watchable
state = await helper.poll_and_get_state()
assert state.state == STATE_OFF
assert mock_get_characteristics.call_count == 3
assert mock_get_characteristics.call_count == 8