Use the shared zeroconf instance for homekit_controller (#37691)
* Use the shared zeroconf instance for homekit_controller * bump version * Update for upstream changes. Thank you @Jc2k ! * naming * bump version * empty commit to reset CI as re-run is not working
This commit is contained in:
parent
e61da2fff3
commit
52939865fa
4 changed files with 20 additions and 5 deletions
|
@ -6,6 +6,7 @@ import aiohomekit
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from .connection import get_accessory_name, get_bridge_information
|
from .connection import get_accessory_name, get_bridge_information
|
||||||
|
@ -59,9 +60,14 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||||
self.model = None
|
self.model = None
|
||||||
self.hkid = None
|
self.hkid = None
|
||||||
self.devices = {}
|
self.devices = {}
|
||||||
self.controller = aiohomekit.Controller()
|
self.controller = None
|
||||||
self.finish_pairing = None
|
self.finish_pairing = None
|
||||||
|
|
||||||
|
async def _async_setup_controller(self):
|
||||||
|
"""Create the controller."""
|
||||||
|
zeroconf_instance = await zeroconf.async_get_instance(self.hass)
|
||||||
|
self.controller = aiohomekit.Controller(zeroconf_instance=zeroconf_instance)
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle a flow start."""
|
"""Handle a flow start."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
@ -75,6 +81,9 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||||
)
|
)
|
||||||
return await self.async_step_pair()
|
return await self.async_step_pair()
|
||||||
|
|
||||||
|
if self.controller is None:
|
||||||
|
await self._async_setup_controller()
|
||||||
|
|
||||||
all_hosts = await self.controller.discover_ip()
|
all_hosts = await self.controller.discover_ip()
|
||||||
|
|
||||||
self.devices = {}
|
self.devices = {}
|
||||||
|
@ -101,7 +110,10 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||||
unique_id = user_input["unique_id"]
|
unique_id = user_input["unique_id"]
|
||||||
await self.async_set_unique_id(unique_id)
|
await self.async_set_unique_id(unique_id)
|
||||||
|
|
||||||
devices = await self.controller.discover_ip(5)
|
if self.controller is None:
|
||||||
|
await self._async_setup_controller()
|
||||||
|
|
||||||
|
devices = await self.controller.discover_ip(max_seconds=5)
|
||||||
for device in devices:
|
for device in devices:
|
||||||
if normalize_hkid(device.device_id) != unique_id:
|
if normalize_hkid(device.device_id) != unique_id:
|
||||||
continue
|
continue
|
||||||
|
@ -226,6 +238,8 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||||
# in.
|
# in.
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
|
if self.controller is None:
|
||||||
|
await self._async_setup_controller()
|
||||||
|
|
||||||
if pair_info:
|
if pair_info:
|
||||||
code = pair_info["pairing_code"]
|
code = pair_info["pairing_code"]
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"name": "HomeKit Controller",
|
"name": "HomeKit Controller",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
|
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
|
||||||
"requirements": ["aiohomekit[IP]==0.2.41"],
|
"requirements": ["aiohomekit[IP]==0.2.45"],
|
||||||
"zeroconf": ["_hap._tcp.local."],
|
"zeroconf": ["_hap._tcp.local."],
|
||||||
|
"after_dependencies": ["zeroconf"],
|
||||||
"codeowners": ["@Jc2k"]
|
"codeowners": ["@Jc2k"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ aioguardian==1.0.1
|
||||||
aioharmony==0.2.5
|
aioharmony==0.2.5
|
||||||
|
|
||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit[IP]==0.2.41
|
aiohomekit[IP]==0.2.45
|
||||||
|
|
||||||
# homeassistant.components.emulated_hue
|
# homeassistant.components.emulated_hue
|
||||||
# homeassistant.components.http
|
# homeassistant.components.http
|
||||||
|
|
|
@ -91,7 +91,7 @@ aioguardian==1.0.1
|
||||||
aioharmony==0.2.5
|
aioharmony==0.2.5
|
||||||
|
|
||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit[IP]==0.2.41
|
aiohomekit[IP]==0.2.45
|
||||||
|
|
||||||
# homeassistant.components.emulated_hue
|
# homeassistant.components.emulated_hue
|
||||||
# homeassistant.components.http
|
# homeassistant.components.http
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue