diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py index e4011f6a4a6..ca8e95f70ce 100644 --- a/homeassistant/components/deconz/config_flow.py +++ b/homeassistant/components/deconz/config_flow.py @@ -203,18 +203,18 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): return await self.async_step_link() - async def async_step_ssdp(self, discovery_info: dict[str, str]) -> FlowResult: + async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: """Handle a discovered deCONZ bridge.""" if ( - discovery_info.get(ssdp.ATTR_UPNP_MANUFACTURER_URL) + discovery_info.upnp.get(ssdp.ATTR_UPNP_MANUFACTURER_URL) != DECONZ_MANUFACTURERURL ): return self.async_abort(reason="not_deconz_bridge") LOGGER.debug("deCONZ SSDP discovery %s", pformat(discovery_info)) - self.bridge_id = normalize_bridge_id(discovery_info[ssdp.ATTR_UPNP_SERIAL]) - parsed_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION]) + self.bridge_id = normalize_bridge_id(discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]) + parsed_url = urlparse(discovery_info.ssdp_location) entry = await self.async_set_unique_id(self.bridge_id) if entry and entry.source == config_entries.SOURCE_HASSIO: diff --git a/tests/components/deconz/test_gateway.py b/tests/components/deconz/test_gateway.py index 9457c2e988b..30473814f26 100644 --- a/tests/components/deconz/test_gateway.py +++ b/tests/components/deconz/test_gateway.py @@ -7,6 +7,7 @@ import pydeconz from pydeconz.websocket import STATE_RETRYING, STATE_RUNNING import pytest +from homeassistant.components import ssdp from homeassistant.components.alarm_control_panel import ( DOMAIN as ALARM_CONTROL_PANEL_DOMAIN, ) @@ -28,7 +29,6 @@ from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.siren import DOMAIN as SIREN_DOMAIN from homeassistant.components.ssdp import ( - ATTR_SSDP_LOCATION, ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL, ATTR_UPNP_UDN, @@ -262,12 +262,16 @@ async def test_update_address(hass, aioclient_mock): ) as mock_setup_entry: await hass.config_entries.flow.async_init( DECONZ_DOMAIN, - data={ - ATTR_SSDP_LOCATION: "http://2.3.4.5:80/", - ATTR_UPNP_MANUFACTURER_URL: DECONZ_MANUFACTURERURL, - ATTR_UPNP_SERIAL: BRIDGEID, - ATTR_UPNP_UDN: "uuid:456DEF", - }, + data=ssdp.SsdpServiceInfo( + ssdp_st="mock_st", + ssdp_usn="mock_usn", + ssdp_location="http://2.3.4.5:80/", + upnp={ + ATTR_UPNP_MANUFACTURER_URL: DECONZ_MANUFACTURERURL, + ATTR_UPNP_SERIAL: BRIDGEID, + ATTR_UPNP_UDN: "uuid:456DEF", + }, + ), context={"source": SOURCE_SSDP}, ) await hass.async_block_till_done()