Yeelight: Do not log errors when cannot connect (#50592)
This commit is contained in:
parent
122741b914
commit
aef24a807e
2 changed files with 15 additions and 1 deletions
|
@ -61,7 +61,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if progress.get("context", {}).get(CONF_HOST) == self._discovered_ip:
|
||||
return self.async_abort(reason="already_in_progress")
|
||||
|
||||
self._discovered_model = await self._async_try_connect(self._discovered_ip)
|
||||
try:
|
||||
self._discovered_model = await self._async_try_connect(self._discovered_ip)
|
||||
except CannotConnect:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
if not self.unique_id:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ from homeassistant.components.yeelight import (
|
|||
DOMAIN,
|
||||
NIGHTLIGHT_SWITCH_TYPE_LIGHT,
|
||||
)
|
||||
from homeassistant.components.yeelight.config_flow import CannotConnect
|
||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_ID, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import RESULT_TYPE_ABORT, RESULT_TYPE_FORM
|
||||
|
@ -323,6 +324,15 @@ async def test_discovered_by_homekit_and_dhcp(hass):
|
|||
assert result3["type"] == RESULT_TYPE_ABORT
|
||||
assert result3["reason"] == "already_in_progress"
|
||||
|
||||
with patch(f"{MODULE_CONFIG_FLOW}.yeelight.Bulb", side_effect=CannotConnect):
|
||||
result3 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data={"ip": "1.2.3.5", "macaddress": "00:00:00:00:00:01"},
|
||||
)
|
||||
assert result3["type"] == RESULT_TYPE_ABORT
|
||||
assert result3["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"source, data",
|
||||
|
|
Loading…
Add table
Reference in a new issue