Fix HomeKit cover creation with tilt position, open/close, no set position (#54727)

This commit is contained in:
J. Nick Koston 2021-08-17 22:41:22 -05:00 committed by GitHub
parent d7c1e7c7dc
commit 87496ae75c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -134,10 +134,15 @@ def get_accessory(hass, driver, state, aid, config): # noqa: C901
and features & cover.SUPPORT_SET_POSITION
):
a_type = "Window"
elif features & (cover.SUPPORT_SET_POSITION | cover.SUPPORT_SET_TILT_POSITION):
elif features & cover.SUPPORT_SET_POSITION:
a_type = "WindowCovering"
elif features & (cover.SUPPORT_OPEN | cover.SUPPORT_CLOSE):
a_type = "WindowCoveringBasic"
elif features & cover.SUPPORT_SET_TILT_POSITION:
# WindowCovering and WindowCoveringBasic both support tilt
# only WindowCovering can handle the covers that are missing
# SUPPORT_SET_POSITION, SUPPORT_OPEN, and SUPPORT_CLOSE
a_type = "WindowCovering"
elif state.domain == "fan":
a_type = "Fan"

View File

@ -149,6 +149,18 @@ def test_types(type_name, entity_id, state, attrs, config):
"open",
{ATTR_SUPPORTED_FEATURES: (cover.SUPPORT_OPEN | cover.SUPPORT_CLOSE)},
),
(
"WindowCoveringBasic",
"cover.open_window",
"open",
{
ATTR_SUPPORTED_FEATURES: (
cover.SUPPORT_OPEN
| cover.SUPPORT_CLOSE
| cover.SUPPORT_SET_TILT_POSITION
)
},
),
],
)
def test_type_covers(type_name, entity_id, state, attrs):