Fix Netgear used method version (#63686)
* Netgear fix used method version * add error message * fix imports * fix black * fix error mess * rename constpull/63732/head
parent
6c6607b5be
commit
1d24fb7ad9
|
@ -22,8 +22,8 @@ from .const import (
|
|||
DEFAULT_CONSIDER_HOME,
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
MODELS_V2,
|
||||
ORBI_PORT,
|
||||
MODELS_PORT_80,
|
||||
PORT_80,
|
||||
)
|
||||
from .errors import CannotLoginException
|
||||
from .router import get_api
|
||||
|
@ -141,13 +141,13 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self._abort_if_unique_id_configured(updates=updated_data)
|
||||
|
||||
updated_data[CONF_PORT] = DEFAULT_PORT
|
||||
for model in MODELS_V2:
|
||||
for model in MODELS_PORT_80:
|
||||
if discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NUMBER, "").startswith(
|
||||
model
|
||||
) or discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME, "").startswith(
|
||||
model
|
||||
):
|
||||
updated_data[CONF_PORT] = ORBI_PORT
|
||||
updated_data[CONF_PORT] = PORT_80
|
||||
|
||||
self.placeholders.update(updated_data)
|
||||
self.discovered = True
|
||||
|
|
|
@ -12,8 +12,8 @@ CONF_CONSIDER_HOME = "consider_home"
|
|||
DEFAULT_CONSIDER_HOME = timedelta(seconds=180)
|
||||
DEFAULT_NAME = "Netgear router"
|
||||
|
||||
# update method V2 models
|
||||
MODELS_V2 = [
|
||||
# models using port 80 instead of 5000
|
||||
MODELS_PORT_80 = [
|
||||
"Orbi",
|
||||
"RBK",
|
||||
"RBR",
|
||||
|
@ -31,7 +31,25 @@ MODELS_V2 = [
|
|||
"SXR",
|
||||
"SXS",
|
||||
]
|
||||
ORBI_PORT = 80
|
||||
PORT_80 = 80
|
||||
# update method V2 models
|
||||
MODELS_V2 = [
|
||||
"Orbi",
|
||||
"RBK",
|
||||
"RBR",
|
||||
"RBS",
|
||||
"RBW",
|
||||
"LBK",
|
||||
"LBR",
|
||||
"CBK",
|
||||
"CBR",
|
||||
"SRC",
|
||||
"SRK",
|
||||
"SRS",
|
||||
"SXK",
|
||||
"SXR",
|
||||
"SXS",
|
||||
]
|
||||
|
||||
# Icons
|
||||
DEVICE_ICONS = {
|
||||
|
|
|
@ -149,6 +149,14 @@ class NetgearRouter:
|
|||
if self.model.startswith(model):
|
||||
self.method_version = 2
|
||||
|
||||
if self.method_version == 2:
|
||||
if not self._api.get_attached_devices_2():
|
||||
_LOGGER.error(
|
||||
"Netgear Model '%s' in MODELS_V2 list, but failed to get attached devices using V2",
|
||||
self.model,
|
||||
)
|
||||
self.method_version = 1
|
||||
|
||||
async def async_setup(self) -> None:
|
||||
"""Set up a Netgear router."""
|
||||
await self.hass.async_add_executor_job(self._setup)
|
||||
|
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.netgear.const import CONF_CONSIDER_HOME, DOMAIN, ORBI_PORT
|
||||
from homeassistant.components.netgear.const import CONF_CONSIDER_HOME, DOMAIN, PORT_80
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -252,7 +252,7 @@ async def test_ssdp(hass, service):
|
|||
assert result["result"].unique_id == SERIAL
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"].get(CONF_HOST) == HOST
|
||||
assert result["data"].get(CONF_PORT) == ORBI_PORT
|
||||
assert result["data"].get(CONF_PORT) == PORT_80
|
||||
assert result["data"].get(CONF_SSL) == SSL
|
||||
assert result["data"].get(CONF_USERNAME) == DEFAULT_USER
|
||||
assert result["data"][CONF_PASSWORD] == PASSWORD
|
||||
|
|
Loading…
Reference in New Issue