Skip to content

Commit

Permalink
Strip trailing spaces from HomeKit names (home-assistant#131971)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored and balloob committed Dec 1, 2024
1 parent 0d155c4 commit e8ef990
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

NUMBERS_ONLY_RE = re.compile(r"[^\d.]+")
VERSION_RE = re.compile(r"([0-9]+)(\.[0-9]+)?(\.[0-9]+)?")
INVALID_END_CHARS = "-_"
INVALID_END_CHARS = "-_ "
MAX_VERSION_PART = 2**32 - 1


Expand Down
4 changes: 2 additions & 2 deletions tests/components/homekit/test_accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def test_home_accessory(hass: HomeAssistant, hk_driver) -> None:
serv = acc3.services[0] # SERV_ACCESSORY_INFO
assert (
serv.get_characteristic(CHAR_NAME).value
== "Home Accessory that exceeds the maximum maximum maximum maximum "
== "Home Accessory that exceeds the maximum maximum maximum maximum"
)
assert (
serv.get_characteristic(CHAR_MANUFACTURER).value
Expand Down Expand Up @@ -154,7 +154,7 @@ async def test_home_accessory(hass: HomeAssistant, hk_driver) -> None:
serv = acc4.services[0] # SERV_ACCESSORY_INFO
assert (
serv.get_characteristic(CHAR_NAME).value
== "Home Accessory that exceeds the maximum maximum maximum maximum "
== "Home Accessory that exceeds the maximum maximum maximum maximum"
)
assert (
serv.get_characteristic(CHAR_MANUFACTURER).value
Expand Down
1 change: 1 addition & 0 deletions tests/components/homekit/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def test_cleanup_name_for_homekit() -> None:
"""Ensure name sanitize works as expected."""

assert cleanup_name_for_homekit("abc") == "abc"
assert cleanup_name_for_homekit("abc ") == "abc"
assert cleanup_name_for_homekit("a b c") == "a b c"
assert cleanup_name_for_homekit("ab_c") == "ab c"
assert (
Expand Down

0 comments on commit e8ef990

Please sign in to comment.