Strip trailing spaces from HomeKit names (#131971)

This commit is contained in:
J. Nick Koston 2024-11-30 14:47:40 -06:00 committed by Paulus Schoutsen
parent 0d155c416a
commit e8ef990e72
3 changed files with 4 additions and 3 deletions

View File

@ -114,7 +114,7 @@ _LOGGER = logging.getLogger(__name__)
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

View File

@ -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
@ -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

View File

@ -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 (