Add names to homekit tasks to better track startup problems (#90802)
* Add names to homekit tasks to better track startup problems * fix test
This commit is contained in:
parent
3be3226aaa
commit
d442f2aedb
2 changed files with 10 additions and 9 deletions
|
@ -597,7 +597,9 @@ class HomeKit:
|
||||||
await self._async_shutdown_accessory(acc)
|
await self._async_shutdown_accessory(acc)
|
||||||
if new_acc := self._async_create_single_accessory([state]):
|
if new_acc := self._async_create_single_accessory([state]):
|
||||||
self.driver.accessory = new_acc
|
self.driver.accessory = new_acc
|
||||||
self.hass.async_add_job(new_acc.run)
|
self.hass.async_create_task(
|
||||||
|
new_acc.run(), f"HomeKit Bridge Accessory: {new_acc.entity_id}"
|
||||||
|
)
|
||||||
await self.async_config_changed()
|
await self.async_config_changed()
|
||||||
|
|
||||||
async def async_reset_accessories_in_bridge_mode(
|
async def async_reset_accessories_in_bridge_mode(
|
||||||
|
@ -637,7 +639,9 @@ class HomeKit:
|
||||||
await asyncio.sleep(_HOMEKIT_CONFIG_UPDATE_TIME)
|
await asyncio.sleep(_HOMEKIT_CONFIG_UPDATE_TIME)
|
||||||
for state in new:
|
for state in new:
|
||||||
if acc := self.add_bridge_accessory(state):
|
if acc := self.add_bridge_accessory(state):
|
||||||
self.hass.async_add_job(acc.run)
|
self.hass.async_create_task(
|
||||||
|
acc.run(), f"HomeKit Bridge Accessory: {acc.entity_id}"
|
||||||
|
)
|
||||||
await self.async_config_changed()
|
await self.async_config_changed()
|
||||||
|
|
||||||
async def async_config_changed(self) -> None:
|
async def async_config_changed(self) -> None:
|
||||||
|
|
|
@ -815,14 +815,10 @@ async def test_homekit_reset_accessories(
|
||||||
homekit = _mock_homekit(hass, entry, HOMEKIT_MODE_BRIDGE)
|
homekit = _mock_homekit(hass, entry, HOMEKIT_MODE_BRIDGE)
|
||||||
|
|
||||||
with patch(f"{PATH_HOMEKIT}.HomeKit", return_value=homekit), patch(
|
with patch(f"{PATH_HOMEKIT}.HomeKit", return_value=homekit), patch(
|
||||||
"pyhap.accessory.Bridge.add_accessory"
|
|
||||||
) as mock_add_accessory, patch(
|
|
||||||
"pyhap.accessory_driver.AccessoryDriver.config_changed"
|
"pyhap.accessory_driver.AccessoryDriver.config_changed"
|
||||||
), patch(
|
), patch("pyhap.accessory_driver.AccessoryDriver.async_start"), patch(
|
||||||
"pyhap.accessory_driver.AccessoryDriver.async_start"
|
|
||||||
), patch(
|
|
||||||
f"{PATH_HOMEKIT}.accessories.HomeAccessory.run"
|
f"{PATH_HOMEKIT}.accessories.HomeAccessory.run"
|
||||||
), patch.object(
|
) as mock_run_accessory, patch.object(
|
||||||
homekit_base, "_HOMEKIT_CONFIG_UPDATE_TIME", 0
|
homekit_base, "_HOMEKIT_CONFIG_UPDATE_TIME", 0
|
||||||
):
|
):
|
||||||
await async_init_entry(hass, entry)
|
await async_init_entry(hass, entry)
|
||||||
|
@ -837,8 +833,9 @@ async def test_homekit_reset_accessories(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert mock_add_accessory.called
|
assert mock_run_accessory.called
|
||||||
homekit.status = STATUS_READY
|
homekit.status = STATUS_READY
|
||||||
await homekit.async_stop()
|
await homekit.async_stop()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue