mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Add type hint to adguard service calls (#62893)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
e01b0a3625
commit
942f58593b
@ -18,7 +18,7 @@ from homeassistant.const import (
|
|||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
@ -72,31 +72,27 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
async def add_url(call) -> None:
|
async def add_url(call: ServiceCall) -> None:
|
||||||
"""Service call to add a new filter subscription to AdGuard Home."""
|
"""Service call to add a new filter subscription to AdGuard Home."""
|
||||||
await adguard.filtering.add_url(
|
await adguard.filtering.add_url(
|
||||||
allowlist=False, name=call.data.get(CONF_NAME), url=call.data.get(CONF_URL)
|
allowlist=False, name=call.data[CONF_NAME], url=call.data[CONF_URL]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def remove_url(call) -> None:
|
async def remove_url(call: ServiceCall) -> None:
|
||||||
"""Service call to remove a filter subscription from AdGuard Home."""
|
"""Service call to remove a filter subscription from AdGuard Home."""
|
||||||
await adguard.filtering.remove_url(allowlist=False, url=call.data.get(CONF_URL))
|
await adguard.filtering.remove_url(allowlist=False, url=call.data[CONF_URL])
|
||||||
|
|
||||||
async def enable_url(call) -> None:
|
async def enable_url(call: ServiceCall) -> None:
|
||||||
"""Service call to enable a filter subscription in AdGuard Home."""
|
"""Service call to enable a filter subscription in AdGuard Home."""
|
||||||
await adguard.filtering.enable_url(allowlist=False, url=call.data.get(CONF_URL))
|
await adguard.filtering.enable_url(allowlist=False, url=call.data[CONF_URL])
|
||||||
|
|
||||||
async def disable_url(call) -> None:
|
async def disable_url(call: ServiceCall) -> None:
|
||||||
"""Service call to disable a filter subscription in AdGuard Home."""
|
"""Service call to disable a filter subscription in AdGuard Home."""
|
||||||
await adguard.filtering.disable_url(
|
await adguard.filtering.disable_url(allowlist=False, url=call.data[CONF_URL])
|
||||||
allowlist=False, url=call.data.get(CONF_URL)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def refresh(call) -> None:
|
async def refresh(call: ServiceCall) -> None:
|
||||||
"""Service call to refresh the filter subscriptions in AdGuard Home."""
|
"""Service call to refresh the filter subscriptions in AdGuard Home."""
|
||||||
await adguard.filtering.refresh(
|
await adguard.filtering.refresh(allowlist=False, force=call.data[CONF_FORCE])
|
||||||
allowlist=False, force=call.data.get(CONF_FORCE)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN, SERVICE_ADD_URL, add_url, schema=SERVICE_ADD_URL_SCHEMA
|
DOMAIN, SERVICE_ADD_URL, add_url, schema=SERVICE_ADD_URL_SCHEMA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user