Handle more fritzbox edge cases (#34802)
This commit is contained in:
1 parent
f47055a1b0
commit
996af94bb8
3 files changed
+51
-4
No files matched your search
@@ -2,6 +2,7 @@
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pyfritzhome import Fritzhome, LoginError
|
||||
from requests.exceptions import HTTPError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
@@ -32,6 +33,7 @@ DATA_SCHEMA_CONFIRM = vol.Schema(
|
||||
|
||||
RESULT_AUTH_FAILED = "auth_failed"
|
||||
RESULT_NOT_FOUND = "not_found"
|
||||
RESULT_NOT_SUPPORTED = "not_supported"
|
||||
RESULT_SUCCESS = "success"
|
||||
|
||||
|
||||
@@ -67,12 +69,15 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
try:
|
||||
fritzbox.login()
|
||||
fritzbox.get_device_elements()
|
||||
fritzbox.logout()
|
||||
return RESULT_SUCCESS
|
||||
except OSError:
|
||||
return RESULT_NOT_FOUND
|
||||
except LoginError:
|
||||
return RESULT_AUTH_FAILED
|
||||
except HTTPError:
|
||||
return RESULT_NOT_SUPPORTED
|
||||
except OSError:
|
||||
return RESULT_NOT_FOUND
|
||||
|
||||
async def async_step_import(self, user_input=None):
|
||||
"""Handle configuration by yaml file."""
|
||||
@@ -129,7 +134,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="already_configured")
|
||||
|
||||
self._host = host
|
||||
self._name = user_input[ATTR_UPNP_FRIENDLY_NAME]
|
||||
self._name = user_input.get(ATTR_UPNP_FRIENDLY_NAME) or host
|
||||
|
||||
self.context["title_placeholders"] = {"name": self._name}
|
||||
return await self.async_step_confirm()
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
"abort": {
|
||||
"already_in_progress": "AVM FRITZ!Box configuration is already in progress.",
|
||||
"already_configured": "This AVM FRITZ!Box is already configured.",
|
||||
"not_found": "No supported AVM FRITZ!Box found on the network."
|
||||
"not_found": "No supported AVM FRITZ!Box found on the network.",
|
||||
"not_supported": "Connected to AVM FRITZ!Box but it's unable to control Smart Home devices."
|
||||
},
|
||||
"error": {
|
||||
"auth_failed": "Username and/or password are incorrect."
|
||||
|
||||
Reference in new issue
Block a user