Skip to content

Commit

Permalink
Fix HomeKit cover creation with tilt position, open/close, no set pos…
Browse files Browse the repository at this point in the history
…ition (#54727)
  • Loading branch information
bdraco authored and balloob committed Aug 18, 2021
1 parent be69191 commit cfc2c40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion homeassistant/components/homekit/accessories.py
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions tests/components/homekit/test_get_accessories.py
Expand Up @@ -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):
Expand Down

0 comments on commit cfc2c40

Please sign in to comment.