mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 17:18:23 +00:00
Normalize action parameter URL
For consistency with integration setup.
This commit is contained in:
parent
a159f357ae
commit
5156dd9c89
@ -21,6 +21,7 @@ from huawei_lte_api.exceptions import (
|
|||||||
ResponseErrorNotSupportedException,
|
ResponseErrorNotSupportedException,
|
||||||
)
|
)
|
||||||
from requests.exceptions import Timeout
|
from requests.exceptions import Timeout
|
||||||
|
from url_normalize import url_normalize
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
||||||
@ -125,7 +126,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
extra=vol.ALLOW_EXTRA,
|
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 = [
|
PLATFORMS = [
|
||||||
Platform.BINARY_SENSOR,
|
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.
|
because the latter is not available anywhere in the UI.
|
||||||
"""
|
"""
|
||||||
routers = hass.data[DOMAIN].routers
|
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 = next(
|
||||||
(router for router in routers.values() if router.url == url), None
|
(router for router in routers.values() if router.url == url), None
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ from . import magic_client
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry
|
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())
|
@patch("homeassistant.components.huawei_lte.Connection", MagicMock())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user