Use zeroconf attributes in freebox (#58967)

* Use zeroconf attributes in freebox

* Use zeroconf.HaServiceInfo in tests
This commit is contained in:
epenet 2021-11-09 00:27:36 +01:00 committed by GitHub
parent 9eaf8bd21b
commit cf22bd8807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View file

@ -5,7 +5,10 @@ from freebox_api.exceptions import AuthorizationError, HttpRequestError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import DiscoveryInfoType
from .const import DOMAIN
from .router import get_api
@ -105,8 +108,10 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Import a config entry."""
return await self.async_step_user(user_input)
async def async_step_zeroconf(self, discovery_info: dict):
async def async_step_zeroconf(
self, discovery_info: DiscoveryInfoType
) -> FlowResult:
"""Initialize flow from zeroconf."""
host = discovery_info["properties"]["api_domain"]
port = discovery_info["properties"]["https_port"]
host = discovery_info[zeroconf.ATTR_PROPERTIES]["api_domain"]
port = discovery_info[zeroconf.ATTR_PROPERTIES]["https_port"]
return await self.async_step_user({CONF_HOST: host, CONF_PORT: port})