mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Ensure service calls are typed [k-n] (#62917)
* Ensure service calls are typed [k-n] * Ensure service calls are typed in mazda * Adjust mazda * Add mazda comment Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
1c7efe7047
commit
8cc0df7b72
@ -6,6 +6,7 @@ from keba_kecontact.connection import KebaKeContact
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ async def async_setup(hass, config):
|
|||||||
_LOGGER.warning("Could not set failsafe mode %s", ex)
|
_LOGGER.warning("Could not set failsafe mode %s", ex)
|
||||||
|
|
||||||
# Register services to hass
|
# Register services to hass
|
||||||
async def execute_service(call):
|
async def execute_service(call: ServiceCall) -> None:
|
||||||
"""Execute a service to KEBA charging station.
|
"""Execute a service to KEBA charging station.
|
||||||
|
|
||||||
This must be a member function as we need access to the keba
|
This must be a member function as we need access to the keba
|
||||||
|
@ -42,7 +42,7 @@ from homeassistant.const import (
|
|||||||
ATTR_SW_VERSION,
|
ATTR_SW_VERSION,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.helpers.device_registry as dr
|
import homeassistant.helpers.device_registry as dr
|
||||||
@ -298,7 +298,7 @@ class LIFXManager:
|
|||||||
def register_effects(self):
|
def register_effects(self):
|
||||||
"""Register the LIFX effects as hass service calls."""
|
"""Register the LIFX effects as hass service calls."""
|
||||||
|
|
||||||
async def service_handler(service):
|
async def service_handler(service: ServiceCall) -> None:
|
||||||
"""Apply a service, i.e. start an effect."""
|
"""Apply a service, i.e. start an effect."""
|
||||||
entities = await self.platform.async_extract_from_service(service)
|
entities = await self.platform.async_extract_from_service(service)
|
||||||
if entities:
|
if entities:
|
||||||
|
@ -34,7 +34,12 @@ from homeassistant.const import (
|
|||||||
EVENT_LOGBOOK_ENTRY,
|
EVENT_LOGBOOK_ENTRY,
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, callback, split_entity_id
|
from homeassistant.core import (
|
||||||
|
DOMAIN as HA_DOMAIN,
|
||||||
|
ServiceCall,
|
||||||
|
callback,
|
||||||
|
split_entity_id,
|
||||||
|
)
|
||||||
from homeassistant.exceptions import InvalidEntityFormatError
|
from homeassistant.exceptions import InvalidEntityFormatError
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entityfilter import (
|
from homeassistant.helpers.entityfilter import (
|
||||||
@ -130,7 +135,7 @@ async def async_setup(hass, config):
|
|||||||
hass.data[DOMAIN] = {}
|
hass.data[DOMAIN] = {}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def log_message(service):
|
def log_message(service: ServiceCall) -> None:
|
||||||
"""Handle sending notification message service calls."""
|
"""Handle sending notification message service calls."""
|
||||||
message = service.data[ATTR_MESSAGE]
|
message = service.data[ATTR_MESSAGE]
|
||||||
name = service.data[ATTR_NAME]
|
name = service.data[ATTR_NAME]
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
DOMAIN = "logger"
|
DOMAIN = "logger"
|
||||||
@ -78,7 +78,7 @@ async def async_setup(hass, config):
|
|||||||
_add_log_filter(logger, value)
|
_add_log_filter(logger, value)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_service_handler(service):
|
def async_service_handler(service: ServiceCall) -> None:
|
||||||
"""Handle logger services."""
|
"""Handle logger services."""
|
||||||
if service.service == SERVICE_SET_DEFAULT_LEVEL:
|
if service.service == SERVICE_SET_DEFAULT_LEVEL:
|
||||||
set_default_log_level(service.data.get(ATTR_LEVEL))
|
set_default_log_level(service.data.get(ATTR_LEVEL))
|
||||||
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
|
||||||
@ -184,7 +185,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
async def service_handler(service):
|
async def service_handler(service: ServiceCall) -> None:
|
||||||
"""Dispatch service calls to target entities."""
|
"""Dispatch service calls to target entities."""
|
||||||
params = dict(service.data)
|
params = dict(service.data)
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
"""The Mazda Connected Services integration."""
|
"""The Mazda Connected Services integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from pymazda import (
|
from pymazda import (
|
||||||
@ -15,7 +18,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_REGION, Platform
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_REGION, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import (
|
from homeassistant.exceptions import (
|
||||||
ConfigEntryAuthFailed,
|
ConfigEntryAuthFailed,
|
||||||
ConfigEntryNotReady,
|
ConfigEntryNotReady,
|
||||||
@ -67,12 +70,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
_LOGGER.error("Error occurred during Mazda login request: %s", ex)
|
_LOGGER.error("Error occurred during Mazda login request: %s", ex)
|
||||||
raise ConfigEntryNotReady from ex
|
raise ConfigEntryNotReady from ex
|
||||||
|
|
||||||
async def async_handle_service_call(service_call=None):
|
async def async_handle_service_call(service_call: ServiceCall) -> None:
|
||||||
"""Handle a service call."""
|
"""Handle a service call."""
|
||||||
# Get device entry from device registry
|
# Get device entry from device registry
|
||||||
dev_reg = device_registry.async_get(hass)
|
dev_reg = device_registry.async_get(hass)
|
||||||
device_id = service_call.data["device_id"]
|
device_id = service_call.data["device_id"]
|
||||||
device_entry = dev_reg.async_get(device_id)
|
device_entry = dev_reg.async_get(device_id)
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
# For mypy: it has already been checked in validate_mazda_device_id
|
||||||
|
assert device_entry
|
||||||
|
|
||||||
# Get vehicle VIN from device identifiers
|
# Get vehicle VIN from device identifiers
|
||||||
mazda_identifiers = (
|
mazda_identifiers = (
|
||||||
|
@ -9,6 +9,7 @@ import async_timeout
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_NAME, CONF_API_KEY, CONF_TIMEOUT, CONTENT_TYPE_JSON
|
from homeassistant.const import ATTR_NAME, CONF_API_KEY, CONF_TIMEOUT, CONTENT_TYPE_JSON
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -86,7 +87,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
hass.data[DATA_MICROSOFT_FACE] = face
|
hass.data[DATA_MICROSOFT_FACE] = face
|
||||||
|
|
||||||
async def async_create_group(service):
|
async def async_create_group(service: ServiceCall) -> None:
|
||||||
"""Create a new person group."""
|
"""Create a new person group."""
|
||||||
name = service.data[ATTR_NAME]
|
name = service.data[ATTR_NAME]
|
||||||
g_id = slugify(name)
|
g_id = slugify(name)
|
||||||
@ -104,7 +105,7 @@ async def async_setup(hass, config):
|
|||||||
DOMAIN, SERVICE_CREATE_GROUP, async_create_group, schema=SCHEMA_GROUP_SERVICE
|
DOMAIN, SERVICE_CREATE_GROUP, async_create_group, schema=SCHEMA_GROUP_SERVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_delete_group(service):
|
async def async_delete_group(service: ServiceCall) -> None:
|
||||||
"""Delete a person group."""
|
"""Delete a person group."""
|
||||||
g_id = slugify(service.data[ATTR_NAME])
|
g_id = slugify(service.data[ATTR_NAME])
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ async def async_setup(hass, config):
|
|||||||
DOMAIN, SERVICE_DELETE_GROUP, async_delete_group, schema=SCHEMA_GROUP_SERVICE
|
DOMAIN, SERVICE_DELETE_GROUP, async_delete_group, schema=SCHEMA_GROUP_SERVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_train_group(service):
|
async def async_train_group(service: ServiceCall) -> None:
|
||||||
"""Train a person group."""
|
"""Train a person group."""
|
||||||
g_id = service.data[ATTR_GROUP]
|
g_id = service.data[ATTR_GROUP]
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ async def async_setup(hass, config):
|
|||||||
DOMAIN, SERVICE_TRAIN_GROUP, async_train_group, schema=SCHEMA_TRAIN_SERVICE
|
DOMAIN, SERVICE_TRAIN_GROUP, async_train_group, schema=SCHEMA_TRAIN_SERVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_create_person(service):
|
async def async_create_person(service: ServiceCall) -> None:
|
||||||
"""Create a person in a group."""
|
"""Create a person in a group."""
|
||||||
name = service.data[ATTR_NAME]
|
name = service.data[ATTR_NAME]
|
||||||
g_id = service.data[ATTR_GROUP]
|
g_id = service.data[ATTR_GROUP]
|
||||||
@ -153,7 +154,7 @@ async def async_setup(hass, config):
|
|||||||
DOMAIN, SERVICE_CREATE_PERSON, async_create_person, schema=SCHEMA_PERSON_SERVICE
|
DOMAIN, SERVICE_CREATE_PERSON, async_create_person, schema=SCHEMA_PERSON_SERVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_delete_person(service):
|
async def async_delete_person(service: ServiceCall) -> None:
|
||||||
"""Delete a person in a group."""
|
"""Delete a person in a group."""
|
||||||
name = service.data[ATTR_NAME]
|
name = service.data[ATTR_NAME]
|
||||||
g_id = service.data[ATTR_GROUP]
|
g_id = service.data[ATTR_GROUP]
|
||||||
@ -171,7 +172,7 @@ async def async_setup(hass, config):
|
|||||||
DOMAIN, SERVICE_DELETE_PERSON, async_delete_person, schema=SCHEMA_PERSON_SERVICE
|
DOMAIN, SERVICE_DELETE_PERSON, async_delete_person, schema=SCHEMA_PERSON_SERVICE
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_face_person(service):
|
async def async_face_person(service: ServiceCall) -> None:
|
||||||
"""Add a new face picture to a person."""
|
"""Add a new face picture to a person."""
|
||||||
g_id = service.data[ATTR_GROUP]
|
g_id = service.data[ATTR_GROUP]
|
||||||
p_id = face.store[g_id].get(service.data[ATTR_PERSON])
|
p_id = face.store[g_id].get(service.data[ATTR_PERSON])
|
||||||
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
|||||||
PRECISION_WHOLE,
|
PRECISION_WHOLE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
@ -65,7 +65,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
]
|
]
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
async def set_room_temp(service):
|
async def set_room_temp(service: ServiceCall) -> None:
|
||||||
"""Set room temp."""
|
"""Set room temp."""
|
||||||
room_name = service.data.get(ATTR_ROOM_NAME)
|
room_name = service.data.get(ATTR_ROOM_NAME)
|
||||||
sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
|
sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
|
||||||
|
@ -93,7 +93,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
entity.restore()
|
entity.restore()
|
||||||
|
|
||||||
@service.verify_domain_control(hass, DOMAIN)
|
@service.verify_domain_control(hass, DOMAIN)
|
||||||
async def async_service_handle(service_call):
|
async def async_service_handle(service_call: core.ServiceCall) -> None:
|
||||||
"""Handle for services."""
|
"""Handle for services."""
|
||||||
entities = await platform.async_extract_from_service(service_call)
|
entities = await platform.async_extract_from_service(service_call)
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_stop_mqtt)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_stop_mqtt)
|
||||||
|
|
||||||
async def async_publish_service(call: ServiceCall):
|
async def async_publish_service(call: ServiceCall) -> None:
|
||||||
"""Handle MQTT publish service calls."""
|
"""Handle MQTT publish service calls."""
|
||||||
msg_topic = call.data.get(ATTR_TOPIC)
|
msg_topic = call.data.get(ATTR_TOPIC)
|
||||||
msg_topic_template = call.data.get(ATTR_TOPIC_TEMPLATE)
|
msg_topic_template = call.data.get(ATTR_TOPIC_TEMPLATE)
|
||||||
@ -594,7 +594,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
DOMAIN, SERVICE_PUBLISH, async_publish_service, schema=MQTT_PUBLISH_SCHEMA
|
DOMAIN, SERVICE_PUBLISH, async_publish_service, schema=MQTT_PUBLISH_SCHEMA
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_dump_service(call: ServiceCall):
|
async def async_dump_service(call: ServiceCall) -> None:
|
||||||
"""Handle MQTT dump service calls."""
|
"""Handle MQTT dump service calls."""
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
@ -132,10 +133,10 @@ async def async_setup(hass, config):
|
|||||||
hass.loop.create_task(client.keepalive())
|
hass.loop.create_task(client.keepalive())
|
||||||
hass.loop.create_task(client.update())
|
hass.loop.create_task(client.update())
|
||||||
|
|
||||||
async def handle_panic(call):
|
async def handle_panic(call: ServiceCall) -> None:
|
||||||
await client.panic(call.data[ATTR_CODE])
|
await client.panic(call.data[ATTR_CODE])
|
||||||
|
|
||||||
async def handle_aux(call):
|
async def handle_aux(call: ServiceCall) -> None:
|
||||||
await client.aux(call.data[ATTR_OUTPUT_ID], call.data[ATTR_STATE])
|
await client.aux(call.data[ATTR_OUTPUT_ID], call.data[ATTR_STATE])
|
||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -22,7 +22,7 @@ from homeassistant.const import (
|
|||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CoreState, HomeAssistant
|
from homeassistant.core import CoreState, HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
aiohttp_client,
|
aiohttp_client,
|
||||||
@ -146,7 +146,7 @@ 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 unregister_webhook(_: None) -> None:
|
async def unregister_webhook(call: ServiceCall | None) -> None:
|
||||||
if CONF_WEBHOOK_ID not in entry.data:
|
if CONF_WEBHOOK_ID not in entry.data:
|
||||||
return
|
return
|
||||||
_LOGGER.debug("Unregister Netatmo webhook (%s)", entry.data[CONF_WEBHOOK_ID])
|
_LOGGER.debug("Unregister Netatmo webhook (%s)", entry.data[CONF_WEBHOOK_ID])
|
||||||
@ -163,7 +163,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"No webhook to be dropped for %s", entry.data[CONF_WEBHOOK_ID]
|
"No webhook to be dropped for %s", entry.data[CONF_WEBHOOK_ID]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def register_webhook(_: None) -> None:
|
async def register_webhook(call: ServiceCall | None) -> None:
|
||||||
if CONF_WEBHOOK_ID not in entry.data:
|
if CONF_WEBHOOK_ID not in entry.data:
|
||||||
data = {**entry.data, CONF_WEBHOOK_ID: secrets.token_hex()}
|
data = {**entry.data, CONF_WEBHOOK_ID: secrets.token_hex()}
|
||||||
hass.config_entries.async_update_entry(entry, data=data)
|
hass.config_entries.async_update_entry(entry, data=data)
|
||||||
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
|||||||
CONF_RECIPIENT,
|
CONF_RECIPIENT,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
from homeassistant.helpers.dispatcher import (
|
from homeassistant.helpers.dispatcher import (
|
||||||
@ -179,7 +179,7 @@ async def async_setup(hass, config):
|
|||||||
)
|
)
|
||||||
hass.data[DATA_KEY] = LTEData(websession)
|
hass.data[DATA_KEY] = LTEData(websession)
|
||||||
|
|
||||||
async def service_handler(service):
|
async def service_handler(service: ServiceCall) -> None:
|
||||||
"""Apply a service."""
|
"""Apply a service."""
|
||||||
host = service.data.get(ATTR_HOST)
|
host = service.data.get(ATTR_HOST)
|
||||||
conf = {CONF_HOST: host}
|
conf = {CONF_HOST: host}
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
@ -130,15 +130,15 @@ def _async_register_services(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Register integration-level services."""
|
"""Register integration-level services."""
|
||||||
|
|
||||||
def pause(call) -> None:
|
def pause(call: ServiceCall) -> None:
|
||||||
"""Service call to pause downloads in NZBGet."""
|
"""Service call to pause downloads in NZBGet."""
|
||||||
coordinator.nzbget.pausedownload()
|
coordinator.nzbget.pausedownload()
|
||||||
|
|
||||||
def resume(call) -> None:
|
def resume(call: ServiceCall) -> None:
|
||||||
"""Service call to resume downloads in NZBGet."""
|
"""Service call to resume downloads in NZBGet."""
|
||||||
coordinator.nzbget.resumedownload()
|
coordinator.nzbget.resumedownload()
|
||||||
|
|
||||||
def set_speed(call) -> None:
|
def set_speed(call: ServiceCall) -> None:
|
||||||
"""Service call to rate limit speeds in NZBGet."""
|
"""Service call to rate limit speeds in NZBGet."""
|
||||||
coordinator.nzbget.rate(call.data[ATTR_SPEED])
|
coordinator.nzbget.rate(call.data[ATTR_SPEED])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user