Use zeroconf attributes (A-D) (#58835)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
26055e1f14
commit
e983370c27
11 changed files with 78 additions and 50 deletions
|
@ -10,7 +10,10 @@ from pydaikin.discovery import Discovery
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||
|
||||
from .const import CONF_UUID, DOMAIN, KEY_MAC, TIMEOUT
|
||||
|
||||
|
@ -123,18 +126,20 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
user_input.get(CONF_PASSWORD),
|
||||
)
|
||||
|
||||
async def async_step_zeroconf(self, discovery_info):
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: DiscoveryInfoType
|
||||
) -> FlowResult:
|
||||
"""Prepare configuration for a discovered Daikin device."""
|
||||
_LOGGER.debug("Zeroconf user_input: %s", discovery_info)
|
||||
devices = Discovery().poll(ip=discovery_info[CONF_HOST])
|
||||
devices = Discovery().poll(ip=discovery_info[zeroconf.ATTR_HOST])
|
||||
if not devices:
|
||||
_LOGGER.debug(
|
||||
"Could not find MAC-address for %s,"
|
||||
" make sure the required UDP ports are open (see integration documentation)",
|
||||
discovery_info[CONF_HOST],
|
||||
discovery_info[zeroconf.ATTR_HOST],
|
||||
)
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
await self.async_set_unique_id(next(iter(devices))[KEY_MAC])
|
||||
self._abort_if_unique_id_configured()
|
||||
self.host = discovery_info[CONF_HOST]
|
||||
self.host = discovery_info[zeroconf.ATTR_HOST]
|
||||
return await self.async_step_user()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue