mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Use zeroconf attributes in freebox (#58967)
* Use zeroconf attributes in freebox * Use zeroconf.HaServiceInfo in tests
This commit is contained in:
parent
9eaf8bd21b
commit
cf22bd8807
@ -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})
|
||||
|
@ -8,6 +8,7 @@ from freebox_api.exceptions import (
|
||||
)
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.freebox.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
@ -17,13 +18,13 @@ from .const import MOCK_HOST, MOCK_PORT
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
MOCK_ZEROCONF_DATA = {
|
||||
"host": "192.168.0.254",
|
||||
"port": 80,
|
||||
"hostname": "Freebox-Server.local.",
|
||||
"type": "_fbx-api._tcp.local.",
|
||||
"name": "Freebox Server._fbx-api._tcp.local.",
|
||||
"properties": {
|
||||
MOCK_ZEROCONF_DATA = zeroconf.HaServiceInfo(
|
||||
host="192.168.0.254",
|
||||
port=80,
|
||||
hostname="Freebox-Server.local.",
|
||||
type="_fbx-api._tcp.local.",
|
||||
name="Freebox Server._fbx-api._tcp.local.",
|
||||
properties={
|
||||
"api_version": "8.0",
|
||||
"device_type": "FreeboxServer1,2",
|
||||
"api_base_url": "/api/",
|
||||
@ -34,7 +35,7 @@ MOCK_ZEROCONF_DATA = {
|
||||
"box_model_name": "Freebox Server (r2)",
|
||||
"api_domain": MOCK_HOST,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def test_user(hass: HomeAssistant):
|
||||
|
Loading…
x
Reference in New Issue
Block a user