diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index 44efc77d2225c7eb5be2ca52160f395467a59bfd..8160170265679ec8733095bfb75932a789dfc461 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -61,7 +61,7 @@ MAX_PROPERTY_VALUE_LEN = 230 # Dns label max length MAX_NAME_LEN = 63 -# Attributes for HaServiceInfo +# Attributes for ZeroconfServiceInfo ATTR_HOST: Final = "host" ATTR_HOSTNAME: Final = "hostname" ATTR_NAME: Final = "name" @@ -87,7 +87,7 @@ CONFIG_SCHEMA = vol.Schema( ) -class HaServiceInfo(TypedDict): +class ZeroconfServiceInfo(TypedDict): """Prepared info from mDNS entries.""" host: str @@ -466,7 +466,7 @@ def async_get_homekit_discovery_domain( return None -def info_from_service(service: AsyncServiceInfo) -> HaServiceInfo | None: +def info_from_service(service: AsyncServiceInfo) -> ZeroconfServiceInfo | None: """Return prepared info from mDNS entries.""" properties: dict[str, Any] = {"_raw": {}} @@ -493,7 +493,7 @@ def info_from_service(service: AsyncServiceInfo) -> HaServiceInfo | None: if (host := _first_non_link_local_or_v6_address(addresses)) is None: return None - return HaServiceInfo( + return ZeroconfServiceInfo( host=str(host), port=service.port, hostname=service.server, diff --git a/tests/components/apple_tv/test_config_flow.py b/tests/components/apple_tv/test_config_flow.py index ff772723cd2b515c79c42b6630093bc07c461a01..a2823ac2271064033850423fefa41f4153f5ddee 100644 --- a/tests/components/apple_tv/test_config_flow.py +++ b/tests/components/apple_tv/test_config_flow.py @@ -12,7 +12,7 @@ from homeassistant.components.apple_tv.const import CONF_START_OFF, DOMAIN from tests.common import MockConfigEntry -DMAP_SERVICE = zeroconf.HaServiceInfo( +DMAP_SERVICE = zeroconf.ZeroconfServiceInfo( type="_touch-able._tcp.local.", name="dmapid.something", properties={"CtlN": "Apple TV"}, @@ -400,7 +400,7 @@ async def test_zeroconf_unsupported_service_aborts(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( type="_dummy._tcp.local.", properties={}, ), @@ -414,7 +414,7 @@ async def test_zeroconf_add_mrp_device(hass, mrp_device, pairing): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( type="_mediaremotetv._tcp.local.", properties={"UniqueIdentifier": "mrpid", "Name": "Kitchen"}, ), diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 3ba1ceee9060e5d6eb4ae1e7e8e02249bfb721c1..2211936f44b77216016995d226dab0afa1138834 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -293,7 +293,7 @@ async def test_reauth_flow_update_configuration(hass): ), ( SOURCE_ZEROCONF, - zeroconf.HaServiceInfo( + zeroconf.ZeroconfServiceInfo( host=DEFAULT_HOST, port=80, hostname=f"axis-{MAC.lower()}.local.", @@ -363,7 +363,7 @@ async def test_discovery_flow(hass, source: str, discovery_info: dict): ), ( SOURCE_ZEROCONF, - zeroconf.HaServiceInfo( + zeroconf.ZeroconfServiceInfo( host=DEFAULT_HOST, port=80, name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.", @@ -411,7 +411,7 @@ async def test_discovered_device_already_configured( ), ( SOURCE_ZEROCONF, - zeroconf.HaServiceInfo( + zeroconf.ZeroconfServiceInfo( host="2.3.4.5", port=8080, name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.", @@ -479,7 +479,7 @@ async def test_discovery_flow_updated_configuration( ), ( SOURCE_ZEROCONF, - zeroconf.HaServiceInfo( + zeroconf.ZeroconfServiceInfo( host="", port=0, name="", @@ -517,7 +517,7 @@ async def test_discovery_flow_ignore_non_axis_device( ), ( SOURCE_ZEROCONF, - zeroconf.HaServiceInfo( + zeroconf.ZeroconfServiceInfo( host="169.254.3.4", port=80, name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.", diff --git a/tests/components/bond/test_config_flow.py b/tests/components/bond/test_config_flow.py index f815f0432c03eb0b76264f73b017bdbc9a786042..286e9fff9bf609d713429610f42cb56d7b49f4ca 100644 --- a/tests/components/bond/test_config_flow.py +++ b/tests/components/bond/test_config_flow.py @@ -197,7 +197,7 @@ async def test_zeroconf_form(hass: core.HomeAssistant): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="test-bond-id.some-other-tail-info", host="test-host" ), ) @@ -229,7 +229,7 @@ async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="test-bond-id.some-other-tail-info", host="test-host" ), ) @@ -264,7 +264,7 @@ async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="test-bond-id.some-other-tail-info", host="test-host" ), ) @@ -302,7 +302,7 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="already-registered-bond-id.some-other-tail-info", host="updated-host", ), @@ -343,7 +343,7 @@ async def test_zeroconf_already_configured_refresh_token(hass: core.HomeAssistan result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="already-registered-bond-id.some-other-tail-info", host="updated-host", ), @@ -376,7 +376,7 @@ async def test_zeroconf_already_configured_no_reload_same_host( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( name="already-registered-bond-id.some-other-tail-info", host="stored-host", ), @@ -393,7 +393,7 @@ async def test_zeroconf_form_unexpected_error(hass: core.HomeAssistant): await _help_test_form_unexpected_error( hass, source=config_entries.SOURCE_ZEROCONF, - initial_input=zeroconf.HaServiceInfo( + initial_input=zeroconf.ZeroconfServiceInfo( name="test-bond-id.some-other-tail-info", host="test-host", ), diff --git a/tests/components/bosch_shc/test_config_flow.py b/tests/components/bosch_shc/test_config_flow.py index 21892aed94e54c37549a3dd6a55edbfd78d37534..3e52772b30fcacc653aaa6e6cb0ef8c414e2ea21 100644 --- a/tests/components/bosch_shc/test_config_flow.py +++ b/tests/components/bosch_shc/test_config_flow.py @@ -20,7 +20,7 @@ MOCK_SETTINGS = { "name": "Test name", "device": {"mac": "test-mac", "hostname": "test-host"}, } -DISCOVERY_INFO = zeroconf.HaServiceInfo( +DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( host=["169.1.1.1", "1.1.1.1"], port=0, hostname="shc012345.local.", @@ -528,7 +528,7 @@ async def test_zeroconf_cannot_connect(hass, mock_zeroconf): async def test_zeroconf_link_local(hass, mock_zeroconf): """Test we get the form.""" - DISCOVERY_INFO_LINK_LOCAL = zeroconf.HaServiceInfo( + DISCOVERY_INFO_LINK_LOCAL = zeroconf.ZeroconfServiceInfo( host=["169.1.1.1"], port=0, hostname="shc012345.local.", @@ -552,7 +552,7 @@ async def test_zeroconf_not_bosch_shc(hass, mock_zeroconf): """Test we filter out non-bosch_shc devices.""" result = await hass.config_entries.flow.async_init( DOMAIN, - data=zeroconf.HaServiceInfo(host="1.1.1.1", name="notboschshc"), + data=zeroconf.ZeroconfServiceInfo(host="1.1.1.1", name="notboschshc"), context={"source": config_entries.SOURCE_ZEROCONF}, ) assert result["type"] == "abort" diff --git a/tests/components/brother/test_config_flow.py b/tests/components/brother/test_config_flow.py index 8a221a21c36355af8caf5135b4e85b846fa4ce40..314748e5cded2f7220a5780849f7bd93b32810c8 100644 --- a/tests/components/brother/test_config_flow.py +++ b/tests/components/brother/test_config_flow.py @@ -144,7 +144,7 @@ async def test_zeroconf_snmp_error(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( hostname="example.local.", name="Brother Printer" ), ) @@ -159,7 +159,7 @@ async def test_zeroconf_unsupported_model(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( hostname="example.local.", name="Brother Printer", properties={"product": "MFC-8660DN"}, @@ -184,7 +184,7 @@ async def test_zeroconf_device_exists_abort(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( hostname="example.local.", name="Brother Printer" ), ) @@ -201,7 +201,9 @@ async def test_zeroconf_no_probe_existing_device(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo(hostname="localhost", name="Brother Printer"), + data=zeroconf.ZeroconfServiceInfo( + hostname="localhost", name="Brother Printer" + ), ) await hass.async_block_till_done() @@ -220,7 +222,7 @@ async def test_zeroconf_confirm_create_entry(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( hostname="example.local.", name="Brother Printer" ), ) diff --git a/tests/components/daikin/test_config_flow.py b/tests/components/daikin/test_config_flow.py index d6ac4e12c561e476902720c31bc2c461a801cd4d..56463022597093edca48f3a70a7e1cd99fe65348 100644 --- a/tests/components/daikin/test_config_flow.py +++ b/tests/components/daikin/test_config_flow.py @@ -120,7 +120,7 @@ async def test_api_password_abort(hass): @pytest.mark.parametrize( "source, data, unique_id", [ - (SOURCE_ZEROCONF, zeroconf.HaServiceInfo(host=HOST), MAC), + (SOURCE_ZEROCONF, zeroconf.ZeroconfServiceInfo(host=HOST), MAC), ], ) async def test_discovery_zeroconf( diff --git a/tests/components/devolo_home_control/const.py b/tests/components/devolo_home_control/const.py index 761a249745f83e5978ff7bbf8eace628e23a41bb..819f1c3e0059464e5aa93d5f1b0927cbb3cda02a 100644 --- a/tests/components/devolo_home_control/const.py +++ b/tests/components/devolo_home_control/const.py @@ -2,7 +2,7 @@ from homeassistant.components import zeroconf -DISCOVERY_INFO = zeroconf.HaServiceInfo( +DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( host="192.168.0.1", port=14791, hostname="test.local.", @@ -19,6 +19,8 @@ DISCOVERY_INFO = zeroconf.HaServiceInfo( }, ) -DISCOVERY_INFO_WRONG_DEVOLO_DEVICE = zeroconf.HaServiceInfo(properties={"MT": "2700"}) +DISCOVERY_INFO_WRONG_DEVOLO_DEVICE = zeroconf.ZeroconfServiceInfo( + properties={"MT": "2700"} +) -DISCOVERY_INFO_WRONG_DEVICE = zeroconf.HaServiceInfo(properties={"Features": ""}) +DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(properties={"Features": ""}) diff --git a/tests/components/devolo_home_network/const.py b/tests/components/devolo_home_network/const.py index a26704c31317410851a746fc39dbd38271246fa0..44baab0e85c0b77b04965c70a733d8b3469b8ed6 100644 --- a/tests/components/devolo_home_network/const.py +++ b/tests/components/devolo_home_network/const.py @@ -16,7 +16,7 @@ CONNECTED_STATIONS = { ], } -DISCOVERY_INFO = zeroconf.HaServiceInfo( +DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( host=IP, port=14791, hostname="test.local.", @@ -36,7 +36,7 @@ DISCOVERY_INFO = zeroconf.HaServiceInfo( }, ) -DISCOVERY_INFO_WRONG_DEVICE = zeroconf.HaServiceInfo(properties={"MT": "2600"}) +DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(properties={"MT": "2600"}) NEIGHBOR_ACCESS_POINTS = { "neighbor_aps": [ diff --git a/tests/components/doorbird/test_config_flow.py b/tests/components/doorbird/test_config_flow.py index 2b5dc5e33460ca1c39bb57f1c1a99dffbcb31d23..9d579e4bbf5fae413d64283f3e500cd5e5d25a36 100644 --- a/tests/components/doorbird/test_config_flow.py +++ b/tests/components/doorbird/test_config_flow.py @@ -82,7 +82,7 @@ async def test_form_zeroconf_wrong_oui(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"macaddress": "notdoorbirdoui"}, host="192.168.1.8", name="Doorstation - abc123._axis-video._tcp.local.", @@ -98,7 +98,7 @@ async def test_form_zeroconf_link_local_ignored(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"macaddress": "1CCAE3DOORBIRD"}, host="169.254.103.61", name="Doorstation - abc123._axis-video._tcp.local.", @@ -121,7 +121,7 @@ async def test_form_zeroconf_correct_oui(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"macaddress": "1CCAE3DOORBIRD"}, name="Doorstation - abc123._axis-video._tcp.local.", host="192.168.1.5", @@ -180,7 +180,7 @@ async def test_form_zeroconf_correct_oui_wrong_device(hass, doorbell_state_side_ result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"macaddress": "1CCAE3DOORBIRD"}, name="Doorstation - abc123._axis-video._tcp.local.", host="192.168.1.5", diff --git a/tests/components/enphase_envoy/test_config_flow.py b/tests/components/enphase_envoy/test_config_flow.py index bbe8b014d13a83e653b7a1ef5ec5094421c92eb2..812ab87e848df4e12e76693e995d075262e4d4c7 100644 --- a/tests/components/enphase_envoy/test_config_flow.py +++ b/tests/components/enphase_envoy/test_config_flow.py @@ -158,7 +158,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"serialnum": "1234"}, host="1.1.1.1", ), @@ -254,7 +254,7 @@ async def test_zeroconf_serial_already_exists(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"serialnum": "1234"}, host="1.1.1.1", ), @@ -289,7 +289,7 @@ async def test_zeroconf_host_already_exists(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.HaServiceInfo( + data=zeroconf.ZeroconfServiceInfo( properties={"serialnum": "1234"}, host="1.1.1.1", ), diff --git a/tests/components/freebox/test_config_flow.py b/tests/components/freebox/test_config_flow.py index 73711c47c8a8993a281f256445c9acf154ef639b..3bffd213b7276afc2911e77f6129f51df3617ee3 100644 --- a/tests/components/freebox/test_config_flow.py +++ b/tests/components/freebox/test_config_flow.py @@ -18,7 +18,7 @@ from .const import MOCK_HOST, MOCK_PORT from tests.common import MockConfigEntry -MOCK_ZEROCONF_DATA = zeroconf.HaServiceInfo( +MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo( host="192.168.0.254", port=80, hostname="Freebox-Server.local.", diff --git a/tests/components/lookin/__init__.py b/tests/components/lookin/__init__.py index c2821fafab88da0d9edd21bd1aa234bf3436d52a..c55b5228b476b7d24ef2f2952b9d3d5f83b359f6 100644 --- a/tests/components/lookin/__init__.py +++ b/tests/components/lookin/__init__.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch from aiolookin import Climate, Device, Remote -from homeassistant.components.zeroconf import HaServiceInfo +from homeassistant.components.zeroconf import ZeroconfServiceInfo DEVICE_ID = "98F33163" MODULE = "homeassistant.components.lookin" @@ -17,7 +17,7 @@ DEFAULT_ENTRY_TITLE = DEVICE_NAME ZC_NAME = f"LOOKin_{DEVICE_ID}" ZC_TYPE = "_lookin._tcp." -ZEROCONF_DATA: HaServiceInfo = { +ZEROCONF_DATA: ZeroconfServiceInfo = { "host": IP_ADDRESS, "hostname": f"{ZC_NAME.lower()}.local.", "port": 80,