fix: allow option to setup found devices or add a new device plus updated descriptions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import contextlib
|
||||
from dataclasses import dataclass
|
||||
import struct
|
||||
from typing import Any
|
||||
@@ -372,12 +373,23 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the user step — reuse existing key or collect one."""
|
||||
"""Handle the user step — reuse existing key or offer a menu."""
|
||||
LOGGER.debug("user step")
|
||||
existing = self._existing_home_key()
|
||||
if existing:
|
||||
self._home_key = existing
|
||||
return await self.async_step_select_device()
|
||||
self._hub_url = self._hub_url or self._existing_entry_value("hub_url")
|
||||
if self._hub_url and not self._hub_shades:
|
||||
with contextlib.suppress(
|
||||
TimeoutError, aiohttp.ClientError, ValueError
|
||||
):
|
||||
self._hub_shades = await _fetch_shades_from_hub(
|
||||
self.hass, self._hub_url
|
||||
)
|
||||
return self.async_show_menu(
|
||||
step_id="user",
|
||||
menu_options=["select_device", "manual"],
|
||||
)
|
||||
return await self.async_step_homekey()
|
||||
|
||||
def _build_selected_entries(
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
"config": {
|
||||
"flow_title": "Setup {name}",
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Add PowerView Shade",
|
||||
"menu_options": {
|
||||
"select_device": "Select from discovered shades",
|
||||
"manual": "Enter device details manually"
|
||||
},
|
||||
"menu_option_descriptions": {
|
||||
"select_device": "Choose from shades detected via Bluetooth nearby.",
|
||||
"manual": "Enter a Bluetooth MAC address and device name directly, for example if a shade is out of range of discovery."
|
||||
}
|
||||
},
|
||||
"bluetooth_confirm": {
|
||||
"description": "[%key:component::bluetooth::config::step::bluetooth_confirm::description%]"
|
||||
},
|
||||
@@ -43,7 +54,7 @@
|
||||
},
|
||||
"manual": {
|
||||
"title": "Enter Device Details",
|
||||
"description": "No PowerView shades were found via Bluetooth. Enter the device details manually.",
|
||||
"description": "Enter the device details manually.",
|
||||
"data": {
|
||||
"address": "Bluetooth MAC address (e.g. AA:BB:CC:DD:EE:FF)",
|
||||
"ble_name": "BLE device name (e.g. DUE:94ED)"
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
"config": {
|
||||
"flow_title": "Setup {name}",
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Add PowerView Shade",
|
||||
"menu_options": {
|
||||
"select_device": "Select from discovered shades",
|
||||
"manual": "Enter device details manually"
|
||||
},
|
||||
"menu_option_descriptions": {
|
||||
"select_device": "Choose from shades detected via Bluetooth nearby.",
|
||||
"manual": "Enter a Bluetooth MAC address and device name directly, for example if a shade is out of range of discovery."
|
||||
}
|
||||
},
|
||||
"bluetooth_confirm": {
|
||||
"description": "Do you want to set up {name}?"
|
||||
},
|
||||
@@ -40,7 +51,7 @@
|
||||
},
|
||||
"manual": {
|
||||
"title": "Enter Device Details",
|
||||
"description": "No PowerView shades were found via Bluetooth. Enter the device details manually.",
|
||||
"description": "Enter the device details manually.",
|
||||
"data": {
|
||||
"address": "Bluetooth MAC address (e.g. AA:BB:CC:DD:EE:FF)",
|
||||
"ble_name": "BLE device name (e.g. DUE:94ED)"
|
||||
|
||||
Reference in New Issue
Block a user