Normalize action parameter URL

For consistency with integration setup.
This commit is contained in:
Ville Skyttä 2025-05-04 14:21:49 +03:00
parent a159f357ae
commit 5156dd9c89
2 changed files with 4 additions and 3 deletions

View File

@ -21,6 +21,7 @@ from huawei_lte_api.exceptions import (
ResponseErrorNotSupportedException,
)
from requests.exceptions import Timeout
from url_normalize import url_normalize
import voluptuous as vol
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
@ -125,7 +126,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
SERVICE_SCHEMA = vol.Schema({vol.Optional(CONF_URL): cv.url})
SERVICE_SCHEMA = vol.Schema({vol.Optional(CONF_URL): cv.string})
PLATFORMS = [
Platform.BINARY_SENSOR,
@ -511,7 +512,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
because the latter is not available anywhere in the UI.
"""
routers = hass.data[DOMAIN].routers
if url := service.data.get(CONF_URL):
if url := url_normalize(service.data.get(CONF_URL), default_scheme="http"):
router = next(
(router for router in routers.values() if router.url == url), None
)

View File

@ -18,7 +18,7 @@ from . import magic_client
from tests.common import MockConfigEntry
MOCK_CONF_URL = "http://huawei-lte.example.com"
MOCK_CONF_URL = "http://192.168.1.1/"
@patch("homeassistant.components.huawei_lte.Connection", MagicMock())