2020-04-29 21:24:57 +00:00
|
|
|
"""Config flow for Hunter Douglas PowerView integration."""
|
2024-03-08 13:52:48 +00:00
|
|
|
|
2021-05-03 09:41:20 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2020-04-29 21:24:57 +00:00
|
|
|
import logging
|
2024-02-15 14:27:11 +00:00
|
|
|
from typing import TYPE_CHECKING, Any
|
2020-04-29 21:24:57 +00:00
|
|
|
|
|
|
|
from aiopvapi.helpers.aiorequest import AioRequest
|
2024-02-15 14:27:11 +00:00
|
|
|
from aiopvapi.hub import Hub
|
2020-04-29 21:24:57 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2021-11-19 14:12:31 +00:00
|
|
|
from homeassistant.components import dhcp, zeroconf
|
2024-02-29 19:07:36 +00:00
|
|
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
2024-02-15 14:27:11 +00:00
|
|
|
from homeassistant.const import CONF_API_VERSION, CONF_HOST, CONF_NAME
|
2024-02-29 19:07:36 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.exceptions import HomeAssistantError
|
2020-04-29 21:24:57 +00:00
|
|
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
|
|
|
|
|
|
from . import async_get_device_info
|
2022-06-21 16:12:11 +00:00
|
|
|
from .const import DOMAIN, HUB_EXCEPTIONS
|
2020-04-29 21:24:57 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
HAP_SUFFIX = "._hap._tcp.local."
|
2024-02-15 14:27:11 +00:00
|
|
|
POWERVIEW_G2_SUFFIX = "._powerview._tcp.local."
|
|
|
|
POWERVIEW_G3_SUFFIX = "._powerview-g3._tcp.local."
|
2020-04-29 21:24:57 +00:00
|
|
|
|
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
async def validate_input(hass: HomeAssistant, hub_address: str) -> dict[str, str]:
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Validate the user input allows us to connect.
|
|
|
|
|
|
|
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
|
|
|
"""
|
|
|
|
|
|
|
|
websession = async_get_clientsession(hass)
|
|
|
|
|
|
|
|
pv_request = AioRequest(hub_address, loop=hass.loop, websession=websession)
|
|
|
|
|
|
|
|
try:
|
2024-03-22 23:38:33 +00:00
|
|
|
hub = Hub(pv_request)
|
|
|
|
await hub.query_firmware()
|
|
|
|
device_info = await async_get_device_info(hub)
|
2020-08-28 11:50:32 +00:00
|
|
|
except HUB_EXCEPTIONS as err:
|
|
|
|
raise CannotConnect from err
|
2020-04-29 21:24:57 +00:00
|
|
|
|
2024-02-15 14:27:11 +00:00
|
|
|
if hub.role != "Primary":
|
|
|
|
raise UnsupportedDevice(
|
|
|
|
f"{hub.name} ({hub.hub_address}) is the {hub.role} Hub. "
|
|
|
|
"Only the Primary can manage shades"
|
|
|
|
)
|
|
|
|
|
|
|
|
_LOGGER.debug("Connection made using api version: %s", hub.api_version)
|
|
|
|
|
2020-04-29 21:24:57 +00:00
|
|
|
# Return info that you want to store in the config entry.
|
|
|
|
return {
|
2022-06-21 16:12:11 +00:00
|
|
|
"title": device_info.name,
|
|
|
|
"unique_id": device_info.serial_number,
|
2024-02-15 14:27:11 +00:00
|
|
|
CONF_API_VERSION: hub.api_version,
|
2020-04-29 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
class PowerviewConfigFlow(ConfigFlow, domain=DOMAIN):
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Handle a config flow for Hunter Douglas PowerView."""
|
|
|
|
|
|
|
|
VERSION = 1
|
|
|
|
|
2024-01-08 09:08:52 +00:00
|
|
|
def __init__(self) -> None:
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Initialize the powerview config flow."""
|
2024-02-15 14:27:11 +00:00
|
|
|
self.powerview_config: dict = {}
|
2024-01-08 09:08:52 +00:00
|
|
|
self.discovered_ip: str | None = None
|
|
|
|
self.discovered_name: str | None = None
|
2024-02-15 14:27:11 +00:00
|
|
|
self.data_schema: dict = {vol.Required(CONF_HOST): str}
|
2020-04-29 21:24:57 +00:00
|
|
|
|
2024-01-08 09:08:52 +00:00
|
|
|
async def async_step_user(
|
|
|
|
self, user_input: dict[str, Any] | None = None
|
2024-02-29 19:07:36 +00:00
|
|
|
) -> ConfigFlowResult:
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Handle the initial step."""
|
2024-02-15 14:27:11 +00:00
|
|
|
errors: dict[str, str] = {}
|
|
|
|
|
2020-04-29 21:24:57 +00:00
|
|
|
if user_input is not None:
|
2021-05-03 09:41:20 +00:00
|
|
|
info, error = await self._async_validate_or_error(user_input[CONF_HOST])
|
2024-02-15 14:27:11 +00:00
|
|
|
|
2024-01-08 09:08:52 +00:00
|
|
|
if info and not error:
|
2024-02-15 14:27:11 +00:00
|
|
|
self.powerview_config = {
|
|
|
|
CONF_HOST: user_input[CONF_HOST],
|
|
|
|
CONF_NAME: info["title"],
|
|
|
|
CONF_API_VERSION: info[CONF_API_VERSION],
|
|
|
|
}
|
2020-04-29 21:24:57 +00:00
|
|
|
await self.async_set_unique_id(info["unique_id"])
|
|
|
|
return self.async_create_entry(
|
2024-02-15 14:27:11 +00:00
|
|
|
title=self.powerview_config[CONF_NAME],
|
|
|
|
data={
|
|
|
|
CONF_HOST: self.powerview_config[CONF_HOST],
|
|
|
|
CONF_API_VERSION: self.powerview_config[CONF_API_VERSION],
|
|
|
|
},
|
2020-04-29 21:24:57 +00:00
|
|
|
)
|
2024-02-15 14:27:11 +00:00
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
assert error is not None
|
2021-05-03 09:41:20 +00:00
|
|
|
errors["base"] = error
|
2020-04-29 21:24:57 +00:00
|
|
|
|
|
|
|
return self.async_show_form(
|
2024-02-15 14:27:11 +00:00
|
|
|
step_id="user", data_schema=vol.Schema(self.data_schema), errors=errors
|
2020-04-29 21:24:57 +00:00
|
|
|
)
|
|
|
|
|
2024-01-08 09:08:52 +00:00
|
|
|
async def _async_validate_or_error(
|
|
|
|
self, host: str
|
|
|
|
) -> tuple[dict[str, str], None] | tuple[None, str]:
|
2021-05-11 20:00:12 +00:00
|
|
|
self._async_abort_entries_match({CONF_HOST: host})
|
2021-05-03 09:41:20 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
info = await validate_input(self.hass, host)
|
|
|
|
except CannotConnect:
|
|
|
|
return None, "cannot_connect"
|
2024-02-15 14:27:11 +00:00
|
|
|
except UnsupportedDevice:
|
|
|
|
return None, "unsupported_device"
|
2021-05-03 09:41:20 +00:00
|
|
|
except Exception: # pylint: disable=broad-except
|
|
|
|
_LOGGER.exception("Unexpected exception")
|
|
|
|
return None, "unknown"
|
|
|
|
|
|
|
|
return info, None
|
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
async def async_step_dhcp(
|
|
|
|
self, discovery_info: dhcp.DhcpServiceInfo
|
|
|
|
) -> ConfigFlowResult:
|
2021-05-03 09:41:20 +00:00
|
|
|
"""Handle DHCP discovery."""
|
2021-11-30 15:16:30 +00:00
|
|
|
self.discovered_ip = discovery_info.ip
|
|
|
|
self.discovered_name = discovery_info.hostname
|
2021-05-03 09:41:20 +00:00
|
|
|
return await self.async_step_discovery_confirm()
|
|
|
|
|
2021-11-19 14:12:31 +00:00
|
|
|
async def async_step_zeroconf(
|
|
|
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
2024-02-29 19:07:36 +00:00
|
|
|
) -> ConfigFlowResult:
|
2021-05-09 09:41:27 +00:00
|
|
|
"""Handle zeroconf discovery."""
|
2021-11-30 15:16:30 +00:00
|
|
|
self.discovered_ip = discovery_info.host
|
2024-02-15 14:27:11 +00:00
|
|
|
name = discovery_info.name.removesuffix(POWERVIEW_G2_SUFFIX)
|
|
|
|
name = name.removesuffix(POWERVIEW_G3_SUFFIX)
|
2021-05-09 09:41:27 +00:00
|
|
|
self.discovered_name = name
|
|
|
|
return await self.async_step_discovery_confirm()
|
|
|
|
|
2021-11-19 14:12:31 +00:00
|
|
|
async def async_step_homekit(
|
|
|
|
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
2024-02-29 19:07:36 +00:00
|
|
|
) -> ConfigFlowResult:
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Handle HomeKit discovery."""
|
2021-11-30 15:16:30 +00:00
|
|
|
self.discovered_ip = discovery_info.host
|
2023-01-13 11:19:38 +00:00
|
|
|
name = discovery_info.name.removesuffix(HAP_SUFFIX)
|
2021-05-03 09:41:20 +00:00
|
|
|
self.discovered_name = name
|
|
|
|
return await self.async_step_discovery_confirm()
|
2020-04-29 21:24:57 +00:00
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
async def async_step_discovery_confirm(self) -> ConfigFlowResult:
|
2021-05-03 09:41:20 +00:00
|
|
|
"""Confirm dhcp or homekit discovery."""
|
2020-04-29 21:24:57 +00:00
|
|
|
# If we already have the host configured do
|
|
|
|
# not open connections to it if we can avoid it.
|
Handle empty name in powerview config flow (#110969)
fixes
```
2024-02-19 13:51:58.128 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved: File "/Users/bdraco/home-assistant/venv/bin/hass", line 8, in <module>
sys.exit(main())
File "/Users/bdraco/home-assistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/Users/bdraco/home-assistant/homeassistant/runner.py", line 188, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 673, in run_until_complete
self.run_forever()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 640, in run_forever
self._run_once()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1965, in _run_once
handle._run()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 610, in async_add_entities
await add_func(coros, entities, timeout)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 561, in _async_add_entities
await coro
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 652, in _async_add_entity
entity.add_to_platform_start(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 356, in add_to_platform_start
_async_connected_device_registered(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 94, in _async_connected_device_registered
async_dispatcher_send(
File "/Users/bdraco/home-assistant/homeassistant/helpers/dispatcher.py", line 227, in async_dispatcher_send
hass.async_run_hass_job(job, *args)
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 701, in async_run_hass_job
hassjob.target(*args)
File "/Users/bdraco/home-assistant/homeassistant/util/logging.py", line 133, in _callback_wrapper
func(*args)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 392, in _async_process_device_data
self.async_process_client(ip_address, hostname, mac_address)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 268, in async_process_client
discovery_flow.async_create_flow(
File "/Users/bdraco/home-assistant/homeassistant/helpers/discovery_flow.py", line 32, in async_create_flow
hass.async_create_task(init_coro, f"discovery flow {domain} {context}")
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 634, in async_create_task
task = self.loop.create_task(target, name=name)
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1017, in async_init
flow, result = await self._async_init(flow_id, handler, context, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1047, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 127, in async_step_dhcp
return await self.async_step_discovery_confirm()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 152, in async_step_discovery_confirm
assert self.discovered_ip and self.discovered_name
AssertionError
```
2024-02-20 09:41:38 +00:00
|
|
|
assert self.discovered_ip and self.discovered_name is not None
|
2021-05-21 05:40:55 +00:00
|
|
|
self.context[CONF_HOST] = self.discovered_ip
|
2021-05-03 09:41:20 +00:00
|
|
|
for progress in self._async_in_progress():
|
|
|
|
if progress.get("context", {}).get(CONF_HOST) == self.discovered_ip:
|
|
|
|
return self.async_abort(reason="already_in_progress")
|
|
|
|
|
2021-05-11 20:00:12 +00:00
|
|
|
self._async_abort_entries_match({CONF_HOST: self.discovered_ip})
|
2021-05-03 09:41:20 +00:00
|
|
|
info, error = await self._async_validate_or_error(self.discovered_ip)
|
|
|
|
if error:
|
|
|
|
return self.async_abort(reason=error)
|
2024-01-08 09:08:52 +00:00
|
|
|
assert info is not None
|
Handle empty name in powerview config flow (#110969)
fixes
```
2024-02-19 13:51:58.128 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved: File "/Users/bdraco/home-assistant/venv/bin/hass", line 8, in <module>
sys.exit(main())
File "/Users/bdraco/home-assistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/Users/bdraco/home-assistant/homeassistant/runner.py", line 188, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 673, in run_until_complete
self.run_forever()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 640, in run_forever
self._run_once()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1965, in _run_once
handle._run()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 610, in async_add_entities
await add_func(coros, entities, timeout)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 561, in _async_add_entities
await coro
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 652, in _async_add_entity
entity.add_to_platform_start(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 356, in add_to_platform_start
_async_connected_device_registered(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 94, in _async_connected_device_registered
async_dispatcher_send(
File "/Users/bdraco/home-assistant/homeassistant/helpers/dispatcher.py", line 227, in async_dispatcher_send
hass.async_run_hass_job(job, *args)
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 701, in async_run_hass_job
hassjob.target(*args)
File "/Users/bdraco/home-assistant/homeassistant/util/logging.py", line 133, in _callback_wrapper
func(*args)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 392, in _async_process_device_data
self.async_process_client(ip_address, hostname, mac_address)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 268, in async_process_client
discovery_flow.async_create_flow(
File "/Users/bdraco/home-assistant/homeassistant/helpers/discovery_flow.py", line 32, in async_create_flow
hass.async_create_task(init_coro, f"discovery flow {domain} {context}")
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 634, in async_create_task
task = self.loop.create_task(target, name=name)
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1017, in async_init
flow, result = await self._async_init(flow_id, handler, context, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1047, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 127, in async_step_dhcp
return await self.async_step_discovery_confirm()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 152, in async_step_discovery_confirm
assert self.discovered_ip and self.discovered_name
AssertionError
```
2024-02-20 09:41:38 +00:00
|
|
|
|
|
|
|
api_version = info[CONF_API_VERSION]
|
|
|
|
if not self.discovered_name:
|
|
|
|
self.discovered_name = f"Powerview Generation {api_version}"
|
|
|
|
|
2020-04-29 21:24:57 +00:00
|
|
|
await self.async_set_unique_id(info["unique_id"], raise_on_progress=False)
|
2021-05-03 09:41:20 +00:00
|
|
|
self._abort_if_unique_id_configured({CONF_HOST: self.discovered_ip})
|
2020-04-29 21:24:57 +00:00
|
|
|
|
|
|
|
self.powerview_config = {
|
2021-05-03 09:41:20 +00:00
|
|
|
CONF_HOST: self.discovered_ip,
|
|
|
|
CONF_NAME: self.discovered_name,
|
Handle empty name in powerview config flow (#110969)
fixes
```
2024-02-19 13:51:58.128 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved: File "/Users/bdraco/home-assistant/venv/bin/hass", line 8, in <module>
sys.exit(main())
File "/Users/bdraco/home-assistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/Users/bdraco/home-assistant/homeassistant/runner.py", line 188, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 673, in run_until_complete
self.run_forever()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 640, in run_forever
self._run_once()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1965, in _run_once
handle._run()
File "/opt/homebrew/Cellar/python@3.12/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 610, in async_add_entities
await add_func(coros, entities, timeout)
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 561, in _async_add_entities
await coro
File "/Users/bdraco/home-assistant/homeassistant/helpers/entity_platform.py", line 652, in _async_add_entity
entity.add_to_platform_start(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 356, in add_to_platform_start
_async_connected_device_registered(
File "/Users/bdraco/home-assistant/homeassistant/components/device_tracker/config_entry.py", line 94, in _async_connected_device_registered
async_dispatcher_send(
File "/Users/bdraco/home-assistant/homeassistant/helpers/dispatcher.py", line 227, in async_dispatcher_send
hass.async_run_hass_job(job, *args)
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 701, in async_run_hass_job
hassjob.target(*args)
File "/Users/bdraco/home-assistant/homeassistant/util/logging.py", line 133, in _callback_wrapper
func(*args)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 392, in _async_process_device_data
self.async_process_client(ip_address, hostname, mac_address)
File "/Users/bdraco/home-assistant/homeassistant/components/dhcp/__init__.py", line 268, in async_process_client
discovery_flow.async_create_flow(
File "/Users/bdraco/home-assistant/homeassistant/helpers/discovery_flow.py", line 32, in async_create_flow
hass.async_create_task(init_coro, f"discovery flow {domain} {context}")
File "/Users/bdraco/home-assistant/homeassistant/core.py", line 634, in async_create_task
task = self.loop.create_task(target, name=name)
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1017, in async_init
flow, result = await self._async_init(flow_id, handler, context, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 1047, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 127, in async_step_dhcp
return await self.async_step_discovery_confirm()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bdraco/home-assistant/homeassistant/components/hunterdouglas_powerview/config_flow.py", line 152, in async_step_discovery_confirm
assert self.discovered_ip and self.discovered_name
AssertionError
```
2024-02-20 09:41:38 +00:00
|
|
|
CONF_API_VERSION: api_version,
|
2020-04-29 21:24:57 +00:00
|
|
|
}
|
|
|
|
return await self.async_step_link()
|
|
|
|
|
2024-01-08 09:08:52 +00:00
|
|
|
async def async_step_link(
|
|
|
|
self, user_input: dict[str, Any] | None = None
|
2024-02-29 19:07:36 +00:00
|
|
|
) -> ConfigFlowResult:
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Attempt to link with Powerview."""
|
|
|
|
if user_input is not None:
|
|
|
|
return self.async_create_entry(
|
|
|
|
title=self.powerview_config[CONF_NAME],
|
2024-02-15 14:27:11 +00:00
|
|
|
data={
|
|
|
|
CONF_HOST: self.powerview_config[CONF_HOST],
|
|
|
|
CONF_API_VERSION: self.powerview_config[CONF_API_VERSION],
|
|
|
|
},
|
2020-04-29 21:24:57 +00:00
|
|
|
)
|
|
|
|
|
2021-05-03 09:41:20 +00:00
|
|
|
self._set_confirm_only()
|
2021-05-21 05:40:55 +00:00
|
|
|
self.context["title_placeholders"] = self.powerview_config
|
2020-04-29 21:24:57 +00:00
|
|
|
return self.async_show_form(
|
|
|
|
step_id="link", description_placeholders=self.powerview_config
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
class CannotConnect(HomeAssistantError):
|
2020-04-29 21:24:57 +00:00
|
|
|
"""Error to indicate we cannot connect."""
|
2024-02-15 14:27:11 +00:00
|
|
|
|
|
|
|
|
2024-02-29 19:07:36 +00:00
|
|
|
class UnsupportedDevice(HomeAssistantError):
|
2024-02-15 14:27:11 +00:00
|
|
|
"""Error to indicate the device is not supported."""
|