Ensure service calls are typed [o-r] (#62920)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-28 13:10:17 +01:00 committed by GitHub
parent f6c1266af6
commit a19c95e4bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 44 additions and 41 deletions

View file

@ -22,6 +22,7 @@ from homeassistant.const import (
PRECISION_WHOLE, PRECISION_WHOLE,
Platform, Platform,
) )
from homeassistant.core import ServiceCall
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import ( from homeassistant.helpers.device_registry import (
async_get_registry as async_get_dev_reg, async_get_registry as async_get_dev_reg,
@ -246,7 +247,7 @@ def register_services(hass):
} }
) )
async def reset_gateway(call): async def reset_gateway(call: ServiceCall) -> None:
"""Reset the OpenTherm Gateway.""" """Reset the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
mode_rst = gw_vars.OTGW_MODE_RESET mode_rst = gw_vars.OTGW_MODE_RESET
@ -258,7 +259,7 @@ def register_services(hass):
DOMAIN, SERVICE_RESET_GATEWAY, reset_gateway, service_reset_schema DOMAIN, SERVICE_RESET_GATEWAY, reset_gateway, service_reset_schema
) )
async def set_ch_ovrd(call): async def set_ch_ovrd(call: ServiceCall) -> None:
"""Set the central heating override on the OpenTherm Gateway.""" """Set the central heating override on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
await gw_dev.gateway.set_ch_enable_bit(1 if call.data[ATTR_CH_OVRD] else 0) await gw_dev.gateway.set_ch_enable_bit(1 if call.data[ATTR_CH_OVRD] else 0)
@ -270,7 +271,7 @@ def register_services(hass):
service_set_central_heating_ovrd_schema, service_set_central_heating_ovrd_schema,
) )
async def set_control_setpoint(call): async def set_control_setpoint(call: ServiceCall) -> None:
"""Set the control setpoint on the OpenTherm Gateway.""" """Set the control setpoint on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.DATA_CONTROL_SETPOINT gw_var = gw_vars.DATA_CONTROL_SETPOINT
@ -285,7 +286,7 @@ def register_services(hass):
service_set_control_setpoint_schema, service_set_control_setpoint_schema,
) )
async def set_dhw_ovrd(call): async def set_dhw_ovrd(call: ServiceCall) -> None:
"""Set the domestic hot water override on the OpenTherm Gateway.""" """Set the domestic hot water override on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.OTGW_DHW_OVRD gw_var = gw_vars.OTGW_DHW_OVRD
@ -300,7 +301,7 @@ def register_services(hass):
service_set_hot_water_ovrd_schema, service_set_hot_water_ovrd_schema,
) )
async def set_dhw_setpoint(call): async def set_dhw_setpoint(call: ServiceCall) -> None:
"""Set the domestic hot water setpoint on the OpenTherm Gateway.""" """Set the domestic hot water setpoint on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.DATA_DHW_SETPOINT gw_var = gw_vars.DATA_DHW_SETPOINT
@ -315,7 +316,7 @@ def register_services(hass):
service_set_hot_water_setpoint_schema, service_set_hot_water_setpoint_schema,
) )
async def set_device_clock(call): async def set_device_clock(call: ServiceCall) -> None:
"""Set the clock on the OpenTherm Gateway.""" """Set the clock on the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
attr_date = call.data[ATTR_DATE] attr_date = call.data[ATTR_DATE]
@ -326,7 +327,7 @@ def register_services(hass):
DOMAIN, SERVICE_SET_CLOCK, set_device_clock, service_set_clock_schema DOMAIN, SERVICE_SET_CLOCK, set_device_clock, service_set_clock_schema
) )
async def set_gpio_mode(call): async def set_gpio_mode(call: ServiceCall) -> None:
"""Set the OpenTherm Gateway GPIO modes.""" """Set the OpenTherm Gateway GPIO modes."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gpio_id = call.data[ATTR_ID] gpio_id = call.data[ATTR_ID]
@ -340,7 +341,7 @@ def register_services(hass):
DOMAIN, SERVICE_SET_GPIO_MODE, set_gpio_mode, service_set_gpio_mode_schema DOMAIN, SERVICE_SET_GPIO_MODE, set_gpio_mode, service_set_gpio_mode_schema
) )
async def set_led_mode(call): async def set_led_mode(call: ServiceCall) -> None:
"""Set the OpenTherm Gateway LED modes.""" """Set the OpenTherm Gateway LED modes."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
led_id = call.data[ATTR_ID] led_id = call.data[ATTR_ID]
@ -354,7 +355,7 @@ def register_services(hass):
DOMAIN, SERVICE_SET_LED_MODE, set_led_mode, service_set_led_mode_schema DOMAIN, SERVICE_SET_LED_MODE, set_led_mode, service_set_led_mode_schema
) )
async def set_max_mod(call): async def set_max_mod(call: ServiceCall) -> None:
"""Set the max modulation level.""" """Set the max modulation level."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.DATA_SLAVE_MAX_RELATIVE_MOD gw_var = gw_vars.DATA_SLAVE_MAX_RELATIVE_MOD
@ -370,7 +371,7 @@ def register_services(hass):
DOMAIN, SERVICE_SET_MAX_MOD, set_max_mod, service_set_max_mod_schema DOMAIN, SERVICE_SET_MAX_MOD, set_max_mod, service_set_max_mod_schema
) )
async def set_outside_temp(call): async def set_outside_temp(call: ServiceCall) -> None:
"""Provide the outside temperature to the OpenTherm Gateway.""" """Provide the outside temperature to the OpenTherm Gateway."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.DATA_OUTSIDE_TEMP gw_var = gw_vars.DATA_OUTSIDE_TEMP
@ -382,7 +383,7 @@ def register_services(hass):
DOMAIN, SERVICE_SET_OAT, set_outside_temp, service_set_oat_schema DOMAIN, SERVICE_SET_OAT, set_outside_temp, service_set_oat_schema
) )
async def set_setback_temp(call): async def set_setback_temp(call: ServiceCall) -> None:
"""Set the OpenTherm Gateway SetBack temperature.""" """Set the OpenTherm Gateway SetBack temperature."""
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]] gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][call.data[ATTR_GW_ID]]
gw_var = gw_vars.OTGW_SB_TEMP gw_var = gw_vars.OTGW_SB_TEMP

View file

@ -5,7 +5,7 @@ from openzwavemqtt.const import ATTR_LABEL, ATTR_POSITION, ATTR_VALUE
from openzwavemqtt.util.node import get_node_from_manager, set_config_parameter from openzwavemqtt.util.node import get_node_from_manager, set_config_parameter
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
from . import const from . import const
@ -86,7 +86,7 @@ class ZWaveServices:
) )
@callback @callback
def async_set_config_parameter(self, service): def async_set_config_parameter(self, service: ServiceCall) -> None:
"""Set a config parameter to a node.""" """Set a config parameter to a node."""
instance_id = service.data[const.ATTR_INSTANCE_ID] instance_id = service.data[const.ATTR_INSTANCE_ID]
node_id = service.data[const.ATTR_NODE_ID] node_id = service.data[const.ATTR_NODE_ID]
@ -106,7 +106,7 @@ class ZWaveServices:
) )
@callback @callback
def async_add_node(self, service): def async_add_node(self, service: ServiceCall) -> None:
"""Enter inclusion mode on the controller.""" """Enter inclusion mode on the controller."""
instance_id = service.data[const.ATTR_INSTANCE_ID] instance_id = service.data[const.ATTR_INSTANCE_ID]
secure = service.data[const.ATTR_SECURE] secure = service.data[const.ATTR_SECURE]
@ -116,7 +116,7 @@ class ZWaveServices:
instance.add_node(secure) instance.add_node(secure)
@callback @callback
def async_remove_node(self, service): def async_remove_node(self, service: ServiceCall) -> None:
"""Enter exclusion mode on the controller.""" """Enter exclusion mode on the controller."""
instance_id = service.data[const.ATTR_INSTANCE_ID] instance_id = service.data[const.ATTR_INSTANCE_ID]
instance = self._manager.get_instance(instance_id) instance = self._manager.get_instance(instance_id)
@ -125,7 +125,7 @@ class ZWaveServices:
instance.remove_node() instance.remove_node()
@callback @callback
def async_cancel_command(self, service): def async_cancel_command(self, service: ServiceCall) -> None:
"""Tell the controller to cancel an add or remove command.""" """Tell the controller to cancel an add or remove command."""
instance_id = service.data[const.ATTR_INSTANCE_ID] instance_id = service.data[const.ATTR_INSTANCE_ID]
instance = self._manager.get_instance(instance_id) instance = self._manager.get_instance(instance_id)

View file

@ -5,6 +5,7 @@ import logging
from plexapi.exceptions import BadRequest, NotFound from plexapi.exceptions import BadRequest, NotFound
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -26,10 +27,10 @@ _LOGGER = logging.getLogger(__package__)
async def async_setup_services(hass): async def async_setup_services(hass):
"""Set up services for the Plex component.""" """Set up services for the Plex component."""
async def async_refresh_library_service(service_call): async def async_refresh_library_service(service_call: ServiceCall) -> None:
await hass.async_add_executor_job(refresh_library, hass, service_call) await hass.async_add_executor_job(refresh_library, hass, service_call)
async def async_scan_clients_service(_): async def async_scan_clients_service(_: ServiceCall) -> None:
_LOGGER.debug("Scanning for new Plex clients") _LOGGER.debug("Scanning for new Plex clients")
for server_id in hass.data[DOMAIN][SERVERS]: for server_id in hass.data[DOMAIN][SERVERS]:
async_dispatcher_send(hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id)) async_dispatcher_send(hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id))
@ -47,7 +48,7 @@ async def async_setup_services(hass):
return True return True
def refresh_library(hass, service_call): def refresh_library(hass: HomeAssistant, service_call: ServiceCall) -> None:
"""Scan a Plex library for new and updated media.""" """Scan a Plex library for new and updated media."""
plex_server_name = service_call.data.get("server_name") plex_server_name = service_call.data.get("server_name")
library_name = service_call.data["library_name"] library_name = service_call.data["library_name"]

View file

@ -19,7 +19,7 @@ from homeassistant.const import (
CONF_TOKEN, CONF_TOKEN,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant, split_entity_id from homeassistant.core import HomeAssistant, ServiceCall, split_entity_id
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry
from homeassistant.util import location from homeassistant.util import location
@ -217,7 +217,7 @@ def _reformat_data(hass: HomeAssistant, games: dict, unique_id: str) -> dict:
def service_handle(hass: HomeAssistant): def service_handle(hass: HomeAssistant):
"""Handle for services.""" """Handle for services."""
async def async_service_command(call): async def async_service_command(call: ServiceCall) -> None:
"""Service for sending commands.""" """Service for sending commands."""
entity_ids = call.data[ATTR_ENTITY_ID] entity_ids = call.data[ATTR_ENTITY_ID]
command = call.data[ATTR_COMMAND] command = call.data[ATTR_COMMAND]

View file

@ -7,6 +7,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import 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 .const import ( from .const import (
@ -73,7 +74,7 @@ class RachioPerson:
all_devices = [rachio_iro.name for rachio_iro in self._controllers] all_devices = [rachio_iro.name for rachio_iro in self._controllers]
def pause_water(service): def pause_water(service: ServiceCall) -> None:
"""Service to pause watering on all or specific controllers.""" """Service to pause watering on all or specific controllers."""
duration = service.data[ATTR_DURATION] duration = service.data[ATTR_DURATION]
devices = service.data.get(ATTR_DEVICES, all_devices) devices = service.data.get(ATTR_DEVICES, all_devices)
@ -81,14 +82,14 @@ class RachioPerson:
if iro.name in devices: if iro.name in devices:
iro.pause_watering(duration) iro.pause_watering(duration)
def resume_water(service): def resume_water(service: ServiceCall) -> None:
"""Service to resume watering on all or specific controllers.""" """Service to resume watering on all or specific controllers."""
devices = service.data.get(ATTR_DEVICES, all_devices) devices = service.data.get(ATTR_DEVICES, all_devices)
for iro in self._controllers: for iro in self._controllers:
if iro.name in devices: if iro.name in devices:
iro.resume_watering() iro.resume_watering()
def stop_water(service): def stop_water(service: ServiceCall) -> None:
"""Service to stop watering on all or specific controllers.""" """Service to stop watering on all or specific controllers."""
devices = service.data.get(ATTR_DEVICES, all_devices) devices = service.data.get(ATTR_DEVICES, all_devices)
for iro in self._controllers: for iro in self._controllers:

View file

@ -8,7 +8,7 @@ import voluptuous as vol
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.const import ATTR_ENTITY_ID, ATTR_ID from homeassistant.const import ATTR_ENTITY_ID, ATTR_ID
from homeassistant.core import callback from homeassistant.core import ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -102,7 +102,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
_LOGGER.info("%d Rachio switch(es) added", len(entities)) _LOGGER.info("%d Rachio switch(es) added", len(entities))
def start_multiple(service): def start_multiple(service: ServiceCall) -> None:
"""Service to start multiple zones in sequence.""" """Service to start multiple zones in sequence."""
zones_list = [] zones_list = []
person = hass.data[DOMAIN_RACHIO][config_entry.entry_id] person = hass.data[DOMAIN_RACHIO][config_entry.entry_id]

View file

@ -32,7 +32,7 @@ from homeassistant.const import (
EVENT_TIME_CHANGED, EVENT_TIME_CHANGED,
MATCH_ALL, MATCH_ALL,
) )
from homeassistant.core import CoreState, HomeAssistant, callback from homeassistant.core import CoreState, HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import ( from homeassistant.helpers.entityfilter import (
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA, INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
@ -284,7 +284,7 @@ async def _process_recorder_platform(hass, domain, platform):
def _async_register_services(hass, instance): def _async_register_services(hass, instance):
"""Register recorder services.""" """Register recorder services."""
async def async_handle_purge_service(service): async def async_handle_purge_service(service: ServiceCall) -> None:
"""Handle calls to the purge service.""" """Handle calls to the purge service."""
instance.do_adhoc_purge(**service.data) instance.do_adhoc_purge(**service.data)
@ -292,7 +292,7 @@ def _async_register_services(hass, instance):
DOMAIN, SERVICE_PURGE, async_handle_purge_service, schema=SERVICE_PURGE_SCHEMA DOMAIN, SERVICE_PURGE, async_handle_purge_service, schema=SERVICE_PURGE_SCHEMA
) )
async def async_handle_purge_entities_service(service): async def async_handle_purge_entities_service(service: ServiceCall) -> None:
"""Handle calls to the purge entities service.""" """Handle calls to the purge entities service."""
entity_ids = await async_extract_entity_ids(hass, service) entity_ids = await async_extract_entity_ids(hass, service)
domains = service.data.get(ATTR_DOMAINS, []) domains = service.data.get(ATTR_DOMAINS, [])
@ -307,7 +307,7 @@ def _async_register_services(hass, instance):
schema=SERVICE_PURGE_ENTITIES_SCHEMA, schema=SERVICE_PURGE_ENTITIES_SCHEMA,
) )
async def async_handle_enable_service(service): async def async_handle_enable_service(service: ServiceCall) -> None:
instance.set_enable(True) instance.set_enable(True)
hass.services.async_register( hass.services.async_register(
@ -317,7 +317,7 @@ def _async_register_services(hass, instance):
schema=SERVICE_ENABLE_SCHEMA, schema=SERVICE_ENABLE_SCHEMA,
) )
async def async_handle_disable_service(service): async def async_handle_disable_service(service: ServiceCall) -> None:
instance.set_enable(False) instance.set_enable(False)
hass.services.async_register( hass.services.async_register(

View file

@ -24,7 +24,7 @@ from homeassistant.const import (
HTTP_DIGEST_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION,
SERVICE_RELOAD, SERVICE_RELOAD,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import discovery, template from homeassistant.helpers import discovery, template
from homeassistant.helpers.entity_component import ( from homeassistant.helpers.entity_component import (
DEFAULT_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
@ -49,7 +49,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component = EntityComponent(_LOGGER, DOMAIN, hass) component = EntityComponent(_LOGGER, DOMAIN, hass)
_async_setup_shared_data(hass) _async_setup_shared_data(hass)
async def reload_service_handler(service): async def reload_service_handler(service: ServiceCall) -> None:
"""Remove all user-defined groups and load new ones from config.""" """Remove all user-defined groups and load new ones from config."""
if (conf := await component.async_prepare_reload()) is None: if (conf := await component.async_prepare_reload()) is None:
return return

View file

@ -17,7 +17,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
from homeassistant.core import callback from homeassistant.core import ServiceCall, callback
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
@ -88,7 +88,7 @@ async def async_setup(hass, config):
if CONF_CONTENT_TYPE in command_config: if CONF_CONTENT_TYPE in command_config:
content_type = command_config[CONF_CONTENT_TYPE] content_type = command_config[CONF_CONTENT_TYPE]
async def async_service_handler(service): async def async_service_handler(service: ServiceCall) -> None:
"""Execute a shell command service.""" """Execute a shell command service."""
payload = None payload = None
if template_payload: if template_payload:

View file

@ -18,7 +18,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
STATE_ON, STATE_ON,
) )
from homeassistant.core import CoreState, callback from homeassistant.core import CoreState, ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
@ -134,7 +134,7 @@ async def async_setup(hass, config):
# Allow platform to specify function to register new unknown devices # Allow platform to specify function to register new unknown devices
hass.data[DATA_DEVICE_REGISTER] = {} hass.data[DATA_DEVICE_REGISTER] = {}
async def async_send_command(call): async def async_send_command(call: ServiceCall) -> None:
"""Send Rflink command.""" """Send Rflink command."""
_LOGGER.debug("Rflink command for %s", str(call.data)) _LOGGER.debug("Rflink command for %s", str(call.data))
if not ( if not (

View file

@ -24,7 +24,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.device_registry import DeviceRegistry
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity
@ -234,7 +234,7 @@ async def async_setup_internal(hass, entry: config_entries.ConfigEntry):
rfx_object.event_callback = lambda event: hass.add_job(async_handle_receive, event) rfx_object.event_callback = lambda event: hass.add_job(async_handle_receive, event)
def send(call): def send(call: ServiceCall) -> None:
event = call.data[ATTR_EVENT] event = call.data[ATTR_EVENT]
rfx_object.transport.send(event) rfx_object.transport.send(event)

View file

@ -12,7 +12,7 @@ import requests
from ring_doorbell import Auth, Ring from ring_doorbell import Auth, Ring
from homeassistant.const import Platform, __version__ from homeassistant.const import Platform, __version__
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.util.async_ import run_callback_threadsafe from homeassistant.util.async_ import run_callback_threadsafe
@ -111,7 +111,7 @@ async def async_setup_entry(hass, entry):
if hass.services.has_service(DOMAIN, "update"): if hass.services.has_service(DOMAIN, "update"):
return True return True
async def async_refresh_all(_): async def async_refresh_all(_: ServiceCall) -> None:
"""Refresh all ring data.""" """Refresh all ring data."""
for info in hass.data[DOMAIN].values(): for info in hass.data[DOMAIN].values():
await info["device_data"].async_refresh_all() await info["device_data"].async_refresh_all()