Fix bug when connection fails
This commit is contained in:
committed by
rospogrigio
parent
98fee92c83
commit
1d830552df
@@ -161,6 +161,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
detected_dps = {}
|
detected_dps = {}
|
||||||
|
|
||||||
|
interface = None
|
||||||
try:
|
try:
|
||||||
interface = await pytuya.connect(
|
interface = await pytuya.connect(
|
||||||
data[CONF_HOST],
|
data[CONF_HOST],
|
||||||
@@ -175,7 +176,8 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
raise InvalidAuth
|
raise InvalidAuth
|
||||||
finally:
|
finally:
|
||||||
interface.close()
|
if interface:
|
||||||
|
interface.close()
|
||||||
|
|
||||||
return dps_string_list(detected_dps)
|
return dps_string_list(detected_dps)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user