mirror of
https://github.com/home-assistant/core
synced 2024-09-25 00:41:32 +02:00
Prepare homekit_controller for _hap._udp.local. (#74857)
* Prepare homekit_controller for _hap._udp.local.
This commit is contained in:
parent
c9aa3c112a
commit
59170d3c54
@ -8,6 +8,7 @@ from typing import Any
|
||||
import aiohomekit
|
||||
from aiohomekit.exceptions import AuthenticationError
|
||||
from aiohomekit.model import Accessories, CharacteristicsTypes, ServicesTypes
|
||||
from aiohomekit.utils import domain_supported, domain_to_name
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
@ -203,8 +204,12 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
hkid = properties[zeroconf.ATTR_PROPERTIES_ID]
|
||||
normalized_hkid = normalize_hkid(hkid)
|
||||
|
||||
# If this aiohomekit doesn't support this particular device, ignore it.
|
||||
if not domain_supported(discovery_info.name):
|
||||
return self.async_abort(reason="ignored_model")
|
||||
|
||||
model = properties["md"]
|
||||
name = discovery_info.name.replace("._hap._tcp.local.", "")
|
||||
name = domain_to_name(discovery_info.name)
|
||||
status_flags = int(properties["sf"])
|
||||
paired = not status_flags & 0x01
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
"name": "HomeKit Controller",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
|
||||
"requirements": ["aiohomekit==0.7.21"],
|
||||
"zeroconf": ["_hap._tcp.local."],
|
||||
"requirements": ["aiohomekit==0.7.22"],
|
||||
"zeroconf": ["_hap._tcp.local.", "_hap._udp.local."],
|
||||
"after_dependencies": ["zeroconf"],
|
||||
"codeowners": ["@Jc2k", "@bdraco"],
|
||||
"iot_class": "local_push",
|
||||
|
@ -167,6 +167,11 @@ ZEROCONF = {
|
||||
"name": "*z.wave-me*"
|
||||
}
|
||||
],
|
||||
"_hap._udp.local.": [
|
||||
{
|
||||
"domain": "homekit_controller"
|
||||
}
|
||||
],
|
||||
"_homekit._tcp.local.": [
|
||||
{
|
||||
"domain": "homekit"
|
||||
|
@ -168,7 +168,7 @@ aioguardian==2022.03.2
|
||||
aioharmony==0.2.9
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit==0.7.21
|
||||
aiohomekit==0.7.22
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
@ -152,7 +152,7 @@ aioguardian==2022.03.2
|
||||
aioharmony==0.2.9
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
aiohomekit==0.7.21
|
||||
aiohomekit==0.7.22
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
@ -224,7 +224,7 @@ async def device_config_changed(hass, accessories):
|
||||
host="127.0.0.1",
|
||||
addresses=["127.0.0.1"],
|
||||
hostname="mock_hostname",
|
||||
name="TestDevice",
|
||||
name="TestDevice._hap._tcp.local.",
|
||||
port=8080,
|
||||
properties={
|
||||
"md": "TestDevice",
|
||||
|
@ -141,7 +141,7 @@ def get_device_discovery_info(
|
||||
result = zeroconf.ZeroconfServiceInfo(
|
||||
host="127.0.0.1",
|
||||
hostname=device.description.name,
|
||||
name=device.description.name,
|
||||
name=device.description.name + "._hap._tcp.local.",
|
||||
addresses=["127.0.0.1"],
|
||||
port=8080,
|
||||
properties={
|
||||
@ -265,6 +265,23 @@ async def test_pair_already_paired_1(hass, controller):
|
||||
assert result["reason"] == "already_paired"
|
||||
|
||||
|
||||
async def test_unknown_domain_type(hass, controller):
|
||||
"""Test that aiohomekit can reject discoveries it doesn't support."""
|
||||
device = setup_mock_accessory(controller)
|
||||
# Flag device as already paired
|
||||
discovery_info = get_device_discovery_info(device)
|
||||
discovery_info.name = "TestDevice._music._tap.local."
|
||||
|
||||
# Device is discovered
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"homekit_controller",
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "ignored_model"
|
||||
|
||||
|
||||
async def test_id_missing(hass, controller):
|
||||
"""Test id is missing."""
|
||||
device = setup_mock_accessory(controller)
|
||||
|
Loading…
Reference in New Issue
Block a user