mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Fix HomeWizard reconfigure flow throwing error for v2-API devices (#137337)
Fix reconfigure flow not working for v2
This commit is contained in:
parent
37f0832c8b
commit
0463b90d36
@ -272,9 +272,14 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reconfiguration of the integration."""
|
"""Handle reconfiguration of the integration."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
reconfigure_entry = self._get_reconfigure_entry()
|
||||||
|
|
||||||
if user_input:
|
if user_input:
|
||||||
try:
|
try:
|
||||||
device_info = await async_try_connect(user_input[CONF_IP_ADDRESS])
|
device_info = await async_try_connect(
|
||||||
|
user_input[CONF_IP_ADDRESS],
|
||||||
|
token=reconfigure_entry.data.get(CONF_TOKEN),
|
||||||
|
)
|
||||||
|
|
||||||
except RecoverableError as ex:
|
except RecoverableError as ex:
|
||||||
LOGGER.error(ex)
|
LOGGER.error(ex)
|
||||||
@ -288,7 +293,6 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self._get_reconfigure_entry(),
|
self._get_reconfigure_entry(),
|
||||||
data_updates=user_input,
|
data_updates=user_input,
|
||||||
)
|
)
|
||||||
reconfigure_entry = self._get_reconfigure_entry()
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reconfigure",
|
step_id="reconfigure",
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
@ -306,7 +310,7 @@ class HomeWizardConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_try_connect(ip_address: str) -> Device:
|
async def async_try_connect(ip_address: str, token: str | None = None) -> Device:
|
||||||
"""Try to connect.
|
"""Try to connect.
|
||||||
|
|
||||||
Make connection with device to test the connection
|
Make connection with device to test the connection
|
||||||
@ -317,7 +321,7 @@ async def async_try_connect(ip_address: str) -> Device:
|
|||||||
|
|
||||||
# Determine if device is v1 or v2 capable
|
# Determine if device is v1 or v2 capable
|
||||||
if await has_v2_api(ip_address):
|
if await has_v2_api(ip_address):
|
||||||
energy_api = HomeWizardEnergyV2(ip_address)
|
energy_api = HomeWizardEnergyV2(ip_address, token=token)
|
||||||
else:
|
else:
|
||||||
energy_api = HomeWizardEnergyV1(ip_address)
|
energy_api = HomeWizardEnergyV1(ip_address)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user