Add support for event entity motion sensors to HomeKit (#121123)

This commit is contained in:
J. Nick Koston
2024-07-04 04:50:50 -05:00
committed by GitHub
parent d429bcef16
commit 67a4c2c884
4 changed files with 145 additions and 16 deletions

View File

@@ -1939,12 +1939,21 @@ async def test_homekit_ignored_missing_devices(
)
@pytest.mark.parametrize(
("domain", "device_class"),
[
("binary_sensor", BinarySensorDeviceClass.MOTION),
("event", EventDeviceClass.MOTION),
],
)
@pytest.mark.usefixtures("mock_async_zeroconf")
async def test_homekit_finds_linked_motion_sensors(
hass: HomeAssistant,
hk_driver,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
domain: str,
device_class: EventDeviceClass | BinarySensorDeviceClass,
) -> None:
"""Test HomeKit start method."""
entry = await async_init_integration(hass)
@@ -1964,21 +1973,21 @@ async def test_homekit_finds_linked_motion_sensors(
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
binary_motion_sensor = entity_registry.async_get_or_create(
"binary_sensor",
entry = entity_registry.async_get_or_create(
domain,
"camera",
"motion_sensor",
device_id=device_entry.id,
original_device_class=BinarySensorDeviceClass.MOTION,
original_device_class=device_class,
)
camera = entity_registry.async_get_or_create(
"camera", "camera", "demo", device_id=device_entry.id
)
hass.states.async_set(
binary_motion_sensor.entity_id,
entry.entity_id,
STATE_ON,
{ATTR_DEVICE_CLASS: BinarySensorDeviceClass.MOTION},
{ATTR_DEVICE_CLASS: device_class},
)
hass.states.async_set(camera.entity_id, STATE_ON)
@@ -2001,7 +2010,7 @@ async def test_homekit_finds_linked_motion_sensors(
"model": "Camera Server",
"platform": "test",
"sw_version": "0.16.0",
"linked_motion_sensor": "binary_sensor.camera_motion_sensor",
"linked_motion_sensor": entry.entity_id,
},
)