mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use the same server name for all HomeKit bridges (#55860)
This commit is contained in:
parent
459bc55e32
commit
eff59e8b00
@ -519,7 +519,7 @@ class HomeKit:
|
|||||||
self.bridge = None
|
self.bridge = None
|
||||||
self.driver = None
|
self.driver = None
|
||||||
|
|
||||||
def setup(self, async_zeroconf_instance):
|
def setup(self, async_zeroconf_instance, uuid):
|
||||||
"""Set up bridge and accessory driver."""
|
"""Set up bridge and accessory driver."""
|
||||||
persist_file = get_persist_fullpath_for_entry_id(self.hass, self._entry_id)
|
persist_file = get_persist_fullpath_for_entry_id(self.hass, self._entry_id)
|
||||||
|
|
||||||
@ -534,6 +534,7 @@ class HomeKit:
|
|||||||
persist_file=persist_file,
|
persist_file=persist_file,
|
||||||
advertised_address=self._advertise_ip,
|
advertised_address=self._advertise_ip,
|
||||||
async_zeroconf_instance=async_zeroconf_instance,
|
async_zeroconf_instance=async_zeroconf_instance,
|
||||||
|
zeroconf_server=f"{uuid}-hap.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# If we do not load the mac address will be wrong
|
# If we do not load the mac address will be wrong
|
||||||
@ -713,7 +714,8 @@ class HomeKit:
|
|||||||
return
|
return
|
||||||
self.status = STATUS_WAIT
|
self.status = STATUS_WAIT
|
||||||
async_zc_instance = await zeroconf.async_get_async_instance(self.hass)
|
async_zc_instance = await zeroconf.async_get_async_instance(self.hass)
|
||||||
await self.hass.async_add_executor_job(self.setup, async_zc_instance)
|
uuid = await self.hass.helpers.instance_id.async_get()
|
||||||
|
await self.hass.async_add_executor_job(self.setup, async_zc_instance, uuid)
|
||||||
self.aid_storage = AccessoryAidStorage(self.hass, self._entry_id)
|
self.aid_storage = AccessoryAidStorage(self.hass, self._entry_id)
|
||||||
await self.aid_storage.async_initialize()
|
await self.aid_storage.async_initialize()
|
||||||
if not await self._async_create_accessories():
|
if not await self._async_create_accessories():
|
||||||
|
@ -265,8 +265,9 @@ async def test_homekit_setup(hass, hk_driver, mock_zeroconf):
|
|||||||
hass.states.async_set("light.demo", "on")
|
hass.states.async_set("light.demo", "on")
|
||||||
hass.states.async_set("light.demo2", "on")
|
hass.states.async_set("light.demo2", "on")
|
||||||
zeroconf_mock = MagicMock()
|
zeroconf_mock = MagicMock()
|
||||||
|
uuid = await hass.helpers.instance_id.async_get()
|
||||||
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
||||||
await hass.async_add_executor_job(homekit.setup, zeroconf_mock)
|
await hass.async_add_executor_job(homekit.setup, zeroconf_mock, uuid)
|
||||||
|
|
||||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||||
mock_driver.assert_called_with(
|
mock_driver.assert_called_with(
|
||||||
@ -280,6 +281,7 @@ async def test_homekit_setup(hass, hk_driver, mock_zeroconf):
|
|||||||
persist_file=path,
|
persist_file=path,
|
||||||
advertised_address=None,
|
advertised_address=None,
|
||||||
async_zeroconf_instance=zeroconf_mock,
|
async_zeroconf_instance=zeroconf_mock,
|
||||||
|
zeroconf_server=f"{uuid}-hap.local.",
|
||||||
)
|
)
|
||||||
assert homekit.driver.safe_mode is False
|
assert homekit.driver.safe_mode is False
|
||||||
|
|
||||||
@ -307,8 +309,9 @@ async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf):
|
|||||||
|
|
||||||
mock_zeroconf = MagicMock()
|
mock_zeroconf = MagicMock()
|
||||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||||
|
uuid = await hass.helpers.instance_id.async_get()
|
||||||
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
||||||
await hass.async_add_executor_job(homekit.setup, mock_zeroconf)
|
await hass.async_add_executor_job(homekit.setup, mock_zeroconf, uuid)
|
||||||
mock_driver.assert_called_with(
|
mock_driver.assert_called_with(
|
||||||
hass,
|
hass,
|
||||||
entry.entry_id,
|
entry.entry_id,
|
||||||
@ -320,6 +323,7 @@ async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf):
|
|||||||
persist_file=path,
|
persist_file=path,
|
||||||
advertised_address=None,
|
advertised_address=None,
|
||||||
async_zeroconf_instance=mock_zeroconf,
|
async_zeroconf_instance=mock_zeroconf,
|
||||||
|
zeroconf_server=f"{uuid}-hap.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -346,8 +350,9 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf):
|
|||||||
|
|
||||||
async_zeroconf_instance = MagicMock()
|
async_zeroconf_instance = MagicMock()
|
||||||
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
path = get_persist_fullpath_for_entry_id(hass, entry.entry_id)
|
||||||
|
uuid = await hass.helpers.instance_id.async_get()
|
||||||
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver:
|
||||||
await hass.async_add_executor_job(homekit.setup, async_zeroconf_instance)
|
await hass.async_add_executor_job(homekit.setup, async_zeroconf_instance, uuid)
|
||||||
mock_driver.assert_called_with(
|
mock_driver.assert_called_with(
|
||||||
hass,
|
hass,
|
||||||
entry.entry_id,
|
entry.entry_id,
|
||||||
@ -359,6 +364,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf):
|
|||||||
persist_file=path,
|
persist_file=path,
|
||||||
advertised_address="192.168.1.100",
|
advertised_address="192.168.1.100",
|
||||||
async_zeroconf_instance=async_zeroconf_instance,
|
async_zeroconf_instance=async_zeroconf_instance,
|
||||||
|
zeroconf_server=f"{uuid}-hap.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user