Migrate HomeKit to use describe_event for logbook support (#34485)
This commit is contained in:
parent
95357dfc55
commit
19be31d13a
5 changed files with 87 additions and 101 deletions
54
tests/components/homekit/test_init.py
Normal file
54
tests/components/homekit/test_init.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
"""Test HomeKit initialization."""
|
||||
from asynctest import patch
|
||||
|
||||
from homeassistant import core as ha
|
||||
from homeassistant.components import logbook
|
||||
from homeassistant.components.homekit.const import (
|
||||
ATTR_DISPLAY_NAME,
|
||||
ATTR_VALUE,
|
||||
DOMAIN as DOMAIN_HOMEKIT,
|
||||
EVENT_HOMEKIT_CHANGED,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_SERVICE
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_humanify_homekit_changed_event(hass, hk_driver):
|
||||
"""Test humanifying HomeKit changed event."""
|
||||
with patch("homeassistant.components.homekit.HomeKit"):
|
||||
assert await async_setup_component(hass, "homekit", {"homekit": {}})
|
||||
|
||||
event1, event2 = list(
|
||||
logbook.humanify(
|
||||
hass,
|
||||
[
|
||||
ha.Event(
|
||||
EVENT_HOMEKIT_CHANGED,
|
||||
{
|
||||
ATTR_ENTITY_ID: "lock.front_door",
|
||||
ATTR_DISPLAY_NAME: "Front Door",
|
||||
ATTR_SERVICE: "lock",
|
||||
},
|
||||
),
|
||||
ha.Event(
|
||||
EVENT_HOMEKIT_CHANGED,
|
||||
{
|
||||
ATTR_ENTITY_ID: "cover.window",
|
||||
ATTR_DISPLAY_NAME: "Window",
|
||||
ATTR_SERVICE: "set_cover_position",
|
||||
ATTR_VALUE: 75,
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
assert event1["name"] == "HomeKit"
|
||||
assert event1["domain"] == DOMAIN_HOMEKIT
|
||||
assert event1["message"] == "send command lock for Front Door"
|
||||
assert event1["entity_id"] == "lock.front_door"
|
||||
|
||||
assert event2["name"] == "HomeKit"
|
||||
assert event2["domain"] == DOMAIN_HOMEKIT
|
||||
assert event2["message"] == "send command set_cover_position to 75 for Window"
|
||||
assert event2["entity_id"] == "cover.window"
|
Loading…
Add table
Add a link
Reference in a new issue