Use dataclass properties in directv discovery (#60692)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-01 11:08:36 +01:00 committed by GitHub
parent ad66522bce
commit 160e6febc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,6 @@ 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
@ -69,11 +68,13 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle SSDP discovery."""
host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
host = urlparse(discovery_info.ssdp_location).hostname
receiver_id = None
if discovery_info.get(ATTR_UPNP_SERIAL):
receiver_id = discovery_info[ATTR_UPNP_SERIAL][4:] # strips off RID-
if discovery_info.upnp.get(ssdp.ATTR_UPNP_SERIAL):
receiver_id = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL][
4:
] # strips off RID-
self.context.update({"title_placeholders": {"name": host}})