Skip to content

Commit b30667a

Browse files
Vaskivskyifrenck
authored andcommitted
Fix bug with the hardcoded configuration_url (asuswrt) (home-assistant#151858)
1 parent 8920c54 commit b30667a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

homeassistant/components/asuswrt/bridge.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,17 @@ def get_bridge(
120120

121121
def __init__(self, host: str) -> None:
122122
"""Initialize Bridge."""
123+
self._configuration_url = f"http://{host}"
123124
self._host = host
124125
self._firmware: str | None = None
125126
self._label_mac: str | None = None
126127
self._model: str | None = None
127128

129+
@property
130+
def configuration_url(self) -> str:
131+
"""Return configuration URL."""
132+
return self._configuration_url
133+
128134
@property
129135
def host(self) -> str:
130136
"""Return hostname."""
@@ -359,6 +365,7 @@ async def async_connect(self) -> None:
359365
# get main router properties
360366
if mac := _identity.mac:
361367
self._label_mac = format_mac(mac)
368+
self._configuration_url = self._api.webpanel
362369
self._firmware = str(_identity.firmware)
363370
self._model = _identity.model
364371

homeassistant/components/asuswrt/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ def update_options(self, new_options: Mapping[str, Any]) -> bool:
388388
def device_info(self) -> DeviceInfo:
389389
"""Return the device information."""
390390
info = DeviceInfo(
391+
configuration_url=self._api.configuration_url,
391392
identifiers={(DOMAIN, self._entry.unique_id or "AsusWRT")},
392393
name=self.host,
393394
model=self._api.model or "Asus Router",
394395
manufacturer="Asus",
395-
configuration_url=f"http://{self.host}",
396396
)
397397
if self._api.firmware:
398398
info["sw_version"] = self._api.firmware

tests/components/asuswrt/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from .common import (
1414
ASUSWRT_BASE,
15+
HOST,
1516
MOCK_MACS,
1617
PROTOCOL_HTTP,
1718
PROTOCOL_SSH,
@@ -155,6 +156,9 @@ def mock_controller_connect_http(mock_devices_http):
155156
# Simulate connection status
156157
instance.connected = True
157158

159+
# Set the webpanel address
160+
instance.webpanel = f"http://{HOST}:80"
161+
158162
# Identity
159163
instance.async_get_identity.return_value = AsusDevice(
160164
mac=ROUTER_MAC_ADDR,

0 commit comments

Comments
 (0)