Skip to content
4 changes: 2 additions & 2 deletions homeassistant/components/axis/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import dhcp, zeroconf
from homeassistant.components import dhcp, ssdp, zeroconf
from homeassistant.config_entries import SOURCE_IGNORE
from homeassistant.const import (
CONF_HOST,
Expand Down Expand Up @@ -163,7 +163,7 @@ async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowRes
}
)

async def async_step_ssdp(self, discovery_info: dict):
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo):
"""Prepare configuration for a SSDP discovered Axis device."""
url = urlsplit(discovery_info["presentationURL"])
return await self._process_discovered_device(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/directv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from directv import DIRECTV, DIRECTVError
import voluptuous as vol

from homeassistant.components import ssdp
from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_SERIAL
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import CONF_RECEIVER_ID, DOMAIN

Expand Down Expand Up @@ -67,7 +67,7 @@ async def async_step_user(

return self.async_create_entry(title=user_input[CONF_HOST], data=user_input)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle SSDP discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
receiver_id = None
Expand Down
13 changes: 6 additions & 7 deletions homeassistant/components/dlna_dmr/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import IntegrationError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import (
CONF_CALLBACK_URL_OVERRIDE,
Expand Down Expand Up @@ -57,7 +56,7 @@ class DlnaDmrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):

def __init__(self) -> None:
"""Initialize flow."""
self._discoveries: dict[str, Mapping[str, Any]] = {}
self._discoveries: dict[str, ssdp.SsdpServiceInfo] = {}
self._location: str | None = None
self._udn: str | None = None
self._device_type: str | None = None
Expand Down Expand Up @@ -205,7 +204,7 @@ async def async_step_import_turn_on(
self._set_confirm_only()
return self.async_show_form(step_id="import_turn_on", errors=errors)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a flow initialized by SSDP discovery."""
LOGGER.debug("async_step_ssdp: discovery_info %s", pformat(discovery_info))

Expand Down Expand Up @@ -330,7 +329,7 @@ def _create_entry(self) -> FlowResult:
return self.async_create_entry(title=title, data=data, options=self._options)

async def _async_set_info_from_discovery(
self, discovery_info: Mapping[str, Any], abort_if_configured: bool = True
self, discovery_info: ssdp.SsdpServiceInfo, abort_if_configured: bool = True
) -> None:
"""Set information required for a config entry from the SSDP discovery."""
LOGGER.debug(
Expand Down Expand Up @@ -361,12 +360,12 @@ async def _async_set_info_from_discovery(
or DEFAULT_NAME
)

async def _async_get_discoveries(self) -> list[Mapping[str, Any]]:
async def _async_get_discoveries(self) -> list[ssdp.SsdpServiceInfo]:
"""Get list of unconfigured DLNA devices discovered by SSDP."""
LOGGER.debug("_get_discoveries")

# Get all compatible devices from ssdp's cache
discoveries: list[Mapping[str, Any]] = []
discoveries: list[ssdp.SsdpServiceInfo] = []
for udn_st in DmrDevice.DEVICE_TYPES:
st_discoveries = await ssdp.async_get_discovery_info_by_st(
self.hass, udn_st
Expand Down Expand Up @@ -454,7 +453,7 @@ def _add_with_suggestion(key: str, validator: Callable) -> None:
)


def _is_ignored_device(discovery_info: Mapping[str, Any]) -> bool:
def _is_ignored_device(discovery_info: ssdp.SsdpServiceInfo) -> bool:
"""Return True if this device should be ignored for discovery.

These devices are supported better by other integrations, so don't bug
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dlna_dmr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import asyncio
from collections.abc import Mapping, Sequence
from collections.abc import Sequence
import contextlib
from datetime import datetime, timedelta
import functools
Expand Down Expand Up @@ -241,7 +241,7 @@ async def async_will_remove_from_hass(self) -> None:
await self._device_disconnect()

async def async_ssdp_callback(
self, info: Mapping[str, Any], change: ssdp.SsdpChange
self, info: ssdp.SsdpServiceInfo, change: ssdp.SsdpChange
) -> None:
"""Handle notification from SSDP of device state change."""
_LOGGER.debug(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fritz/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from fritzconnection.core.exceptions import FritzConnectionException, FritzSecurityError
import voluptuous as vol

from homeassistant.components import ssdp
from homeassistant.components.device_tracker.const import (
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
Expand All @@ -22,7 +23,6 @@
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .common import FritzBoxTools
from .const import (
Expand Down Expand Up @@ -115,7 +115,7 @@ def _async_create_entry(self) -> FlowResult:
},
)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a flow initialized by discovery."""
ssdp_location: ParseResult = urlparse(discovery_info[ATTR_SSDP_LOCATION])
self._host = ssdp_location.hostname
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fritzbox/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from requests.exceptions import HTTPError
import voluptuous as vol

from homeassistant.components import ssdp
from homeassistant.components.ssdp import (
ATTR_SSDP_LOCATION,
ATTR_UPNP_FRIENDLY_NAME,
Expand All @@ -16,7 +17,6 @@
from homeassistant.config_entries import ConfigEntry, ConfigFlow
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DEFAULT_HOST, DEFAULT_USERNAME, DOMAIN

Expand Down Expand Up @@ -119,7 +119,7 @@ async def async_step_user(
step_id="user", data_schema=DATA_SCHEMA_USER, errors=errors
)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a flow initialized by discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
assert isinstance(host, str)
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/huawei_lte/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
)
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import (
CONF_TRACK_WIRED_CLIENTS,
Expand Down Expand Up @@ -202,7 +201,7 @@ def get_device_info() -> tuple[GetResponseType, GetResponseType]:

return self.async_create_entry(title=title, data=user_input)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle SSDP initiated config flow."""
await self.async_set_unique_id(discovery_info[ssdp.ATTR_UPNP_UDN])
self._abort_if_unique_id_configured()
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/hue/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.helpers.typing import ConfigType

from .const import (
CONF_ALLOW_HUE_GROUPS,
Expand Down Expand Up @@ -186,7 +186,7 @@ async def async_step_link(self, user_input: ConfigType | None = None) -> FlowRes
},
)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a discovered Hue bridge.

This flow is triggered by the SSDP component. It will check if the
Expand All @@ -213,7 +213,7 @@ async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult
return self.async_abort(reason="not_hue_bridge")

host = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION]).hostname
bridge = await self._get_bridge(host, discovery_info[ssdp.ATTR_UPNP_SERIAL]) # type: ignore[arg-type]
bridge = await self._get_bridge(host, discovery_info[ssdp.ATTR_UPNP_SERIAL])

await self.async_set_unique_id(bridge.id)
self._abort_if_unique_id_configured(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/hyperion/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from hyperion import client, const
import voluptuous as vol

from homeassistant.components import ssdp
from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_SERIAL
from homeassistant.config_entries import (
SOURCE_REAUTH,
Expand Down Expand Up @@ -151,7 +152,7 @@ async def async_step_reauth(
return self.async_abort(reason="cannot_connect")
return await self._advance_to_auth_step_if_necessary(hyperion_client)

async def async_step_ssdp(self, discovery_info: dict[str, Any]) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a flow initiated by SSDP."""
# Sample data provided by SSDP: {
# 'ssdp_location': 'http://192.168.0.1:8090/description.xml',
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/nanoleaf/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components import ssdp, zeroconf
from homeassistant.const import CONF_HOST, CONF_TOKEN
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType
from homeassistant.util.json import load_json, save_json

from .const import DOMAIN
Expand Down Expand Up @@ -114,7 +113,7 @@ async def _async_homekit_zeroconf_discovery_handler(
discovery_info[zeroconf.ATTR_PROPERTIES][zeroconf.ATTR_PROPERTIES_ID],
)

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle Nanoleaf SSDP discovery."""
_LOGGER.debug("SSDP discovered: %s", discovery_info)
return await self._async_discovery_handler(
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/roku/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rokuecp import Roku, RokuError
import voluptuous as vol

from homeassistant.components import zeroconf
from homeassistant.components import ssdp, zeroconf
from homeassistant.components.ssdp import (
ATTR_SSDP_LOCATION,
ATTR_UPNP_FRIENDLY_NAME,
Expand All @@ -18,7 +18,6 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import DiscoveryInfoType

from .const import DOMAIN

Expand Down Expand Up @@ -115,7 +114,7 @@ async def async_step_homekit(

return await self.async_step_discovery_confirm()

async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a flow initialized by discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
name = discovery_info[ATTR_UPNP_FRIENDLY_NAME]
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/samsungtv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import voluptuous as vol

from homeassistant import config_entries, data_entry_flow
from homeassistant.components import dhcp, zeroconf
from homeassistant.components import dhcp, ssdp, zeroconf
from homeassistant.components.ssdp import (
ATTR_SSDP_LOCATION,
ATTR_UPNP_MANUFACTURER,
Expand All @@ -28,7 +28,6 @@
)
from homeassistant.core import callback
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.typing import DiscoveryInfoType

from .bridge import (
SamsungTVBridge,
Expand Down Expand Up @@ -266,7 +265,7 @@ def _abort_if_manufacturer_is_not_samsung(self) -> None:
raise data_entry_flow.AbortFlow(RESULT_NOT_SUPPORTED)

async def async_step_ssdp(
self, discovery_info: DiscoveryInfoType
self, discovery_info: ssdp.SsdpServiceInfo
) -> data_entry_flow.FlowResult:
"""Handle a flow initialized by ssdp discovery."""
LOGGER.debug("Samsung device found via SSDP: %s", discovery_info)
Expand Down
Loading