Skip poll of HKC accessory if reachable and chars are watchable (#116200)

This commit is contained in:
J. Nick Koston
2024-07-18 01:36:45 -05:00
committed by GitHub
parent 0927dd9090
commit e4ef4b81ba
4 changed files with 96 additions and 4 deletions

View File

@@ -1,9 +1,11 @@
"""Basic checks for HomeKitSwitch."""
from collections.abc import Callable
from unittest import mock
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from aiohomekit.testing import FakeController
from homeassistant.components.homekit_controller.const import KNOWN_DEVICES
from homeassistant.components.light import (
@@ -372,7 +374,12 @@ async def test_light_becomes_unavailable_but_recovers(
# Test device goes offline
helper.pairing.available = False
state = await helper.poll_and_get_state()
with mock.patch.object(
FakeController,
"async_reachable",
return_value=False,
):
state = await helper.poll_and_get_state()
assert state.state == "unavailable"
# Simulate that someone switched on the device in the real world not via HA