mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Fix Netgear used method version (#63686)
* Netgear fix used method version * add error message * fix imports * fix black * fix error mess * rename const
This commit is contained in:
parent
6c6607b5be
commit
1d24fb7ad9
@ -22,8 +22,8 @@ from .const import (
|
|||||||
DEFAULT_CONSIDER_HOME,
|
DEFAULT_CONSIDER_HOME,
|
||||||
DEFAULT_NAME,
|
DEFAULT_NAME,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
MODELS_V2,
|
MODELS_PORT_80,
|
||||||
ORBI_PORT,
|
PORT_80,
|
||||||
)
|
)
|
||||||
from .errors import CannotLoginException
|
from .errors import CannotLoginException
|
||||||
from .router import get_api
|
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)
|
self._abort_if_unique_id_configured(updates=updated_data)
|
||||||
|
|
||||||
updated_data[CONF_PORT] = DEFAULT_PORT
|
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(
|
if discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NUMBER, "").startswith(
|
||||||
model
|
model
|
||||||
) or discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME, "").startswith(
|
) or discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME, "").startswith(
|
||||||
model
|
model
|
||||||
):
|
):
|
||||||
updated_data[CONF_PORT] = ORBI_PORT
|
updated_data[CONF_PORT] = PORT_80
|
||||||
|
|
||||||
self.placeholders.update(updated_data)
|
self.placeholders.update(updated_data)
|
||||||
self.discovered = True
|
self.discovered = True
|
||||||
|
@ -12,8 +12,8 @@ CONF_CONSIDER_HOME = "consider_home"
|
|||||||
DEFAULT_CONSIDER_HOME = timedelta(seconds=180)
|
DEFAULT_CONSIDER_HOME = timedelta(seconds=180)
|
||||||
DEFAULT_NAME = "Netgear router"
|
DEFAULT_NAME = "Netgear router"
|
||||||
|
|
||||||
# update method V2 models
|
# models using port 80 instead of 5000
|
||||||
MODELS_V2 = [
|
MODELS_PORT_80 = [
|
||||||
"Orbi",
|
"Orbi",
|
||||||
"RBK",
|
"RBK",
|
||||||
"RBR",
|
"RBR",
|
||||||
@ -31,7 +31,25 @@ MODELS_V2 = [
|
|||||||
"SXR",
|
"SXR",
|
||||||
"SXS",
|
"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
|
# Icons
|
||||||
DEVICE_ICONS = {
|
DEVICE_ICONS = {
|
||||||
|
@ -149,6 +149,14 @@ class NetgearRouter:
|
|||||||
if self.model.startswith(model):
|
if self.model.startswith(model):
|
||||||
self.method_version = 2
|
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:
|
async def async_setup(self) -> None:
|
||||||
"""Set up a Netgear router."""
|
"""Set up a Netgear router."""
|
||||||
await self.hass.async_add_executor_job(self._setup)
|
await self.hass.async_add_executor_job(self._setup)
|
||||||
|
@ -6,7 +6,7 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components import ssdp
|
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.config_entries import SOURCE_IMPORT, SOURCE_SSDP, SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
@ -252,7 +252,7 @@ async def test_ssdp(hass, service):
|
|||||||
assert result["result"].unique_id == SERIAL
|
assert result["result"].unique_id == SERIAL
|
||||||
assert result["title"] == TITLE
|
assert result["title"] == TITLE
|
||||||
assert result["data"].get(CONF_HOST) == HOST
|
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_SSL) == SSL
|
||||||
assert result["data"].get(CONF_USERNAME) == DEFAULT_USER
|
assert result["data"].get(CONF_USERNAME) == DEFAULT_USER
|
||||||
assert result["data"][CONF_PASSWORD] == PASSWORD
|
assert result["data"][CONF_PASSWORD] == PASSWORD
|
||||||
|
Loading…
x
Reference in New Issue
Block a user