mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Handle software version being None when setting up HomeKit accessories (#54130)
* Convert all HomeKit service info to string prior to checking for max length * Added check for None software version * Added test case for numeric version number * Update tests/components/homekit/test_accessories.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fix style & none version test * Fix test * revert other change since it should be covered by the format_sw_version fix Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
d842fc288f
commit
483a4535c8
@ -238,9 +238,10 @@ class HomeAccessory(Accessory):
|
|||||||
model = self.config[ATTR_MODEL]
|
model = self.config[ATTR_MODEL]
|
||||||
else:
|
else:
|
||||||
model = domain.title()
|
model = domain.title()
|
||||||
|
sw_version = None
|
||||||
if self.config.get(ATTR_SW_VERSION) is not None:
|
if self.config.get(ATTR_SW_VERSION) is not None:
|
||||||
sw_version = format_sw_version(self.config[ATTR_SW_VERSION])
|
sw_version = format_sw_version(self.config[ATTR_SW_VERSION])
|
||||||
else:
|
if sw_version is None:
|
||||||
sw_version = __version__
|
sw_version = __version__
|
||||||
|
|
||||||
self.set_info_service(
|
self.set_info_service(
|
||||||
|
@ -133,6 +133,39 @@ async def test_home_accessory(hass, hk_driver):
|
|||||||
)
|
)
|
||||||
assert serv.get_characteristic(CHAR_FIRMWARE_REVISION).value == "0.4.3"
|
assert serv.get_characteristic(CHAR_FIRMWARE_REVISION).value == "0.4.3"
|
||||||
|
|
||||||
|
acc4 = HomeAccessory(
|
||||||
|
hass,
|
||||||
|
hk_driver,
|
||||||
|
"Home Accessory that exceeds the maximum maximum maximum maximum maximum maximum length",
|
||||||
|
entity_id2,
|
||||||
|
3,
|
||||||
|
{
|
||||||
|
ATTR_MODEL: "Awesome Model that exceeds the maximum maximum maximum maximum maximum maximum length",
|
||||||
|
ATTR_MANUFACTURER: "Lux Brands that exceeds the maximum maximum maximum maximum maximum maximum length",
|
||||||
|
ATTR_SW_VERSION: "will_not_match_regex",
|
||||||
|
ATTR_INTEGRATION: "luxe that exceeds the maximum maximum maximum maximum maximum maximum length",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert acc4.available is False
|
||||||
|
serv = acc4.services[0] # SERV_ACCESSORY_INFO
|
||||||
|
assert (
|
||||||
|
serv.get_characteristic(CHAR_NAME).value
|
||||||
|
== "Home Accessory that exceeds the maximum maximum maximum maximum "
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
serv.get_characteristic(CHAR_MANUFACTURER).value
|
||||||
|
== "Lux Brands that exceeds the maximum maximum maximum maximum maxi"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
serv.get_characteristic(CHAR_MODEL).value
|
||||||
|
== "Awesome Model that exceeds the maximum maximum maximum maximum m"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
serv.get_characteristic(CHAR_SERIAL_NUMBER).value
|
||||||
|
== "light.accessory_that_exceeds_the_maximum_maximum_maximum_maximum"
|
||||||
|
)
|
||||||
|
assert serv.get_characteristic(CHAR_FIRMWARE_REVISION).value == hass_version
|
||||||
|
|
||||||
hass.states.async_set(entity_id, "on")
|
hass.states.async_set(entity_id, "on")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
with patch(
|
with patch(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user