mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Cleanup deprecated ssdp aliases (#161747)
This commit is contained in:
@@ -8,30 +8,7 @@ from typing import Any
|
||||
|
||||
from homeassistant.core import HassJob, HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.deprecation import (
|
||||
DeprecatedConstant,
|
||||
all_with_deprecated_constants,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_NT as _ATTR_NT,
|
||||
ATTR_ST as _ATTR_ST,
|
||||
ATTR_UPNP_DEVICE_TYPE as _ATTR_UPNP_DEVICE_TYPE,
|
||||
ATTR_UPNP_FRIENDLY_NAME as _ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_MANUFACTURER as _ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_MANUFACTURER_URL as _ATTR_UPNP_MANUFACTURER_URL,
|
||||
ATTR_UPNP_MODEL_DESCRIPTION as _ATTR_UPNP_MODEL_DESCRIPTION,
|
||||
ATTR_UPNP_MODEL_NAME as _ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_MODEL_NUMBER as _ATTR_UPNP_MODEL_NUMBER,
|
||||
ATTR_UPNP_MODEL_URL as _ATTR_UPNP_MODEL_URL,
|
||||
ATTR_UPNP_PRESENTATION_URL as _ATTR_UPNP_PRESENTATION_URL,
|
||||
ATTR_UPNP_SERIAL as _ATTR_UPNP_SERIAL,
|
||||
ATTR_UPNP_SERVICE_LIST as _ATTR_UPNP_SERVICE_LIST,
|
||||
ATTR_UPNP_UDN as _ATTR_UPNP_UDN,
|
||||
ATTR_UPNP_UPC as _ATTR_UPNP_UPC,
|
||||
SsdpServiceInfo as _SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo as _SsdpServiceInfo
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import async_get_ssdp, bind_hass
|
||||
from homeassistant.util.logging import catch_log_exception
|
||||
@@ -56,93 +33,12 @@ ATTR_SSDP_EXT = "ssdp_ext"
|
||||
ATTR_SSDP_SERVER = "ssdp_server"
|
||||
ATTR_SSDP_BOOTID = "BOOTID.UPNP.ORG"
|
||||
ATTR_SSDP_NEXTBOOTID = "NEXTBOOTID.UPNP.ORG"
|
||||
# Attributes for accessing info from retrieved UPnP device description
|
||||
_DEPRECATED_ATTR_ST = DeprecatedConstant(
|
||||
_ATTR_ST,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_ST",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_NT = DeprecatedConstant(
|
||||
_ATTR_NT,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_NT",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_DEVICE_TYPE = DeprecatedConstant(
|
||||
_ATTR_UPNP_DEVICE_TYPE,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_DEVICE_TYPE",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_FRIENDLY_NAME = DeprecatedConstant(
|
||||
_ATTR_UPNP_FRIENDLY_NAME,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_FRIENDLY_NAME",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MANUFACTURER = DeprecatedConstant(
|
||||
_ATTR_UPNP_MANUFACTURER,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MANUFACTURER",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MANUFACTURER_URL = DeprecatedConstant(
|
||||
_ATTR_UPNP_MANUFACTURER_URL,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MANUFACTURER_URL",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MODEL_DESCRIPTION = DeprecatedConstant(
|
||||
_ATTR_UPNP_MODEL_DESCRIPTION,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_DESCRIPTION",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MODEL_NAME = DeprecatedConstant(
|
||||
_ATTR_UPNP_MODEL_NAME,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_NAME",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MODEL_NUMBER = DeprecatedConstant(
|
||||
_ATTR_UPNP_MODEL_NUMBER,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_NUMBER",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_MODEL_URL = DeprecatedConstant(
|
||||
_ATTR_UPNP_MODEL_URL,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_URL",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_SERIAL = DeprecatedConstant(
|
||||
_ATTR_UPNP_SERIAL,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_SERIAL",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_SERVICE_LIST = DeprecatedConstant(
|
||||
_ATTR_UPNP_SERVICE_LIST,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_SERVICE_LIST",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_UDN = DeprecatedConstant(
|
||||
_ATTR_UPNP_UDN,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_UDN",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_UPC = DeprecatedConstant(
|
||||
_ATTR_UPNP_UPC,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_UPC",
|
||||
"2026.2",
|
||||
)
|
||||
_DEPRECATED_ATTR_UPNP_PRESENTATION_URL = DeprecatedConstant(
|
||||
_ATTR_UPNP_PRESENTATION_URL,
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_PRESENTATION_URL",
|
||||
"2026.2",
|
||||
)
|
||||
|
||||
# Attributes for accessing info added by Home Assistant
|
||||
ATTR_HA_MATCHING_DOMAINS = "x_homeassistant_matching_domains"
|
||||
|
||||
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
||||
|
||||
_DEPRECATED_SsdpServiceInfo = DeprecatedConstant(
|
||||
_SsdpServiceInfo,
|
||||
"homeassistant.helpers.service_info.ssdp.SsdpServiceInfo",
|
||||
"2026.2",
|
||||
)
|
||||
|
||||
|
||||
def _format_err(name: str, *args: Any) -> str:
|
||||
"""Format error message."""
|
||||
@@ -217,11 +113,3 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
websocket_api.async_setup(hass)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
# These can be removed if no deprecated constant are in this module anymore
|
||||
__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
|
||||
__dir__ = partial(
|
||||
dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
|
||||
)
|
||||
__all__ = all_with_deprecated_constants(globals())
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Test the SSDP integration."""
|
||||
|
||||
from ipaddress import IPv4Address
|
||||
from typing import Any
|
||||
from unittest.mock import ANY, AsyncMock, patch
|
||||
|
||||
from async_upnp_client.server import UpnpServer
|
||||
@@ -19,21 +18,9 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.discovery_flow import DiscoveryKey
|
||||
from homeassistant.helpers.service_info.ssdp import (
|
||||
ATTR_NT,
|
||||
ATTR_ST,
|
||||
ATTR_UPNP_DEVICE_TYPE,
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
ATTR_UPNP_MANUFACTURER_URL,
|
||||
ATTR_UPNP_MODEL_DESCRIPTION,
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
ATTR_UPNP_MODEL_NUMBER,
|
||||
ATTR_UPNP_MODEL_URL,
|
||||
ATTR_UPNP_PRESENTATION_URL,
|
||||
ATTR_UPNP_SERIAL,
|
||||
ATTR_UPNP_SERVICE_LIST,
|
||||
ATTR_UPNP_UDN,
|
||||
ATTR_UPNP_UPC,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -44,7 +31,6 @@ from tests.common import (
|
||||
MockConfigEntry,
|
||||
MockModule,
|
||||
async_fire_time_changed,
|
||||
import_and_test_deprecated_constant,
|
||||
mock_integration,
|
||||
)
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
@@ -1100,105 +1086,3 @@ async def test_ssdp_rediscover_no_match(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_flow_init.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("constant_name", "replacement_name", "replacement"),
|
||||
[
|
||||
(
|
||||
"SsdpServiceInfo",
|
||||
"homeassistant.helpers.service_info.ssdp.SsdpServiceInfo",
|
||||
SsdpServiceInfo,
|
||||
),
|
||||
(
|
||||
"ATTR_ST",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_ST",
|
||||
ATTR_ST,
|
||||
),
|
||||
(
|
||||
"ATTR_NT",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_NT",
|
||||
ATTR_NT,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_DEVICE_TYPE",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_DEVICE_TYPE",
|
||||
ATTR_UPNP_DEVICE_TYPE,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_FRIENDLY_NAME",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_FRIENDLY_NAME",
|
||||
ATTR_UPNP_FRIENDLY_NAME,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MANUFACTURER",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MANUFACTURER",
|
||||
ATTR_UPNP_MANUFACTURER,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MANUFACTURER_URL",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MANUFACTURER_URL",
|
||||
ATTR_UPNP_MANUFACTURER_URL,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MODEL_DESCRIPTION",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_DESCRIPTION",
|
||||
ATTR_UPNP_MODEL_DESCRIPTION,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MODEL_NAME",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_NAME",
|
||||
ATTR_UPNP_MODEL_NAME,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MODEL_NUMBER",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_NUMBER",
|
||||
ATTR_UPNP_MODEL_NUMBER,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_MODEL_URL",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_MODEL_URL",
|
||||
ATTR_UPNP_MODEL_URL,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_SERIAL",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_SERIAL",
|
||||
ATTR_UPNP_SERIAL,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_SERVICE_LIST",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_SERVICE_LIST",
|
||||
ATTR_UPNP_SERVICE_LIST,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_UDN",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_UDN",
|
||||
ATTR_UPNP_UDN,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_UPC",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_UPC",
|
||||
ATTR_UPNP_UPC,
|
||||
),
|
||||
(
|
||||
"ATTR_UPNP_PRESENTATION_URL",
|
||||
"homeassistant.helpers.service_info.ssdp.ATTR_UPNP_PRESENTATION_URL",
|
||||
ATTR_UPNP_PRESENTATION_URL,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_deprecated_constants(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
constant_name: str,
|
||||
replacement_name: str,
|
||||
replacement: Any,
|
||||
) -> None:
|
||||
"""Test deprecated automation constants."""
|
||||
import_and_test_deprecated_constant(
|
||||
caplog,
|
||||
ssdp,
|
||||
constant_name,
|
||||
replacement_name,
|
||||
replacement,
|
||||
"2026.2",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user