mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ignore Shelly IPv6 address in zeroconf (#123081)
This commit is contained in:
parent
34b561b211
commit
8687c32c15
@ -279,6 +279,8 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, discovery_info: ZeroconfServiceInfo
|
self, discovery_info: ZeroconfServiceInfo
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
|
if discovery_info.ip_address.version == 6:
|
||||||
|
return self.async_abort(reason="ipv6_not_supported")
|
||||||
host = discovery_info.host
|
host = discovery_info.host
|
||||||
# First try to get the mac address from the name
|
# First try to get the mac address from the name
|
||||||
# so we can avoid making another connection to the
|
# so we can avoid making another connection to the
|
||||||
|
@ -52,7 +52,8 @@
|
|||||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||||
"reauth_unsuccessful": "Re-authentication was unsuccessful, please remove the integration and set it up again.",
|
"reauth_unsuccessful": "Re-authentication was unsuccessful, please remove the integration and set it up again.",
|
||||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
||||||
"another_device": "Re-configuration was unsuccessful, the IP address/hostname of another Shelly device was used."
|
"another_device": "Re-configuration was unsuccessful, the IP address/hostname of another Shelly device was used.",
|
||||||
|
"ipv6_not_supported": "IPv6 is not supported."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"device_automation": {
|
"device_automation": {
|
||||||
|
@ -1305,3 +1305,22 @@ async def test_reconfigure_with_exception(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["errors"] == {"base": base_error}
|
assert result["errors"] == {"base": base_error}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_zeroconf_rejects_ipv6(hass: HomeAssistant) -> None:
|
||||||
|
"""Test zeroconf discovery rejects ipv6."""
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
ip_address=ip_address("fd00::b27c:63bb:cc85:4ea0"),
|
||||||
|
ip_addresses=[ip_address("fd00::b27c:63bb:cc85:4ea0")],
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="shelly1pm-12345",
|
||||||
|
port=None,
|
||||||
|
properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-12345"},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
assert result["reason"] == "ipv6_not_supported"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user