Ensure service calls are typed [v-z] (#62923)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
a19c95e4bd
commit
05ac2d4c3a
6 changed files with 17 additions and 13 deletions
|
@ -5,7 +5,7 @@ from pyvlx import PyVLX, PyVLXException
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import ServiceCall, callback
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -60,7 +60,7 @@ class VeluxModule:
|
|||
_LOGGER.debug("Velux interface terminated")
|
||||
await self.pyvlx.disconnect()
|
||||
|
||||
async def async_reboot_gateway(service_call):
|
||||
async def async_reboot_gateway(service_call: ServiceCall) -> None:
|
||||
await self.pyvlx.reboot_gateway()
|
||||
|
||||
self._hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
|
||||
|
|
|
@ -4,6 +4,7 @@ import logging
|
|||
from pyvesync import VeSync
|
||||
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import ServiceCall
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
|
@ -66,7 +67,7 @@ async def async_setup_entry(hass, config_entry):
|
|||
lights.extend(device_dict[VS_LIGHTS])
|
||||
hass.async_create_task(forward_setup(config_entry, Platform.LIGHT))
|
||||
|
||||
async def async_new_device_discovery(service):
|
||||
async def async_new_device_discovery(service: ServiceCall) -> None:
|
||||
"""Discover if new devices should be added."""
|
||||
manager = hass.data[DOMAIN][VS_MANAGER]
|
||||
switches = hass.data[DOMAIN][VS_SWITCHES]
|
||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
|||
import wakeonlan
|
||||
|
||||
from homeassistant.const import CONF_BROADCAST_ADDRESS, CONF_BROADCAST_PORT, CONF_MAC
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
|
@ -28,7 +28,7 @@ WAKE_ON_LAN_SEND_MAGIC_PACKET_SCHEMA = vol.Schema(
|
|||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the wake on LAN component."""
|
||||
|
||||
async def send_magic_packet(call):
|
||||
async def send_magic_packet(call: ServiceCall) -> None:
|
||||
"""Send magic packet to wake up a device."""
|
||||
mac_address = call.data.get(CONF_MAC)
|
||||
broadcast_address = call.data.get(CONF_BROADCAST_ADDRESS)
|
||||
|
|
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||
CONF_NAME,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
from homeassistant.core import ServiceCall
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
|
@ -86,8 +87,8 @@ async def async_setup(hass, config):
|
|||
"""Set up the LG WebOS TV platform."""
|
||||
hass.data[DOMAIN] = {}
|
||||
|
||||
async def async_service_handler(service):
|
||||
method = SERVICE_TO_METHOD.get(service.service)
|
||||
async def async_service_handler(service: ServiceCall) -> None:
|
||||
method = SERVICE_TO_METHOD[service.service]
|
||||
data = service.data.copy()
|
||||
data["method"] = method["method"]
|
||||
async_dispatcher_send(hass, DOMAIN, data)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Support for Z-Wave."""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import copy
|
||||
from importlib import import_module
|
||||
|
@ -17,7 +19,7 @@ from homeassistant.const import (
|
|||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import CoreState, HomeAssistant, callback
|
||||
from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.device_registry import (
|
||||
|
@ -876,7 +878,7 @@ async def async_setup_entry( # noqa: C901
|
|||
_LOGGER.info("Sending %s test-messages to node %s", messages, node_id)
|
||||
node.test(messages)
|
||||
|
||||
def start_zwave(_service_or_event):
|
||||
def start_zwave(_service_or_event: ServiceCall | Event) -> None:
|
||||
"""Startup Z-Wave network."""
|
||||
_LOGGER.info("Starting Z-Wave network")
|
||||
network.start()
|
||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.lock import DOMAIN, LockEntity
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import ServiceCall, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -169,7 +169,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
|
||||
network = hass.data[const.DATA_NETWORK]
|
||||
|
||||
def set_usercode(service):
|
||||
def set_usercode(service: ServiceCall) -> None:
|
||||
"""Set the usercode to index X on the lock."""
|
||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||
lock_node = network.nodes[node_id]
|
||||
|
@ -193,7 +193,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
value.data = str(usercode)
|
||||
break
|
||||
|
||||
def get_usercode(service):
|
||||
def get_usercode(service: ServiceCall) -> None:
|
||||
"""Get a usercode at index X on the lock."""
|
||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||
lock_node = network.nodes[node_id]
|
||||
|
@ -207,7 +207,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
_LOGGER.info("Usercode at slot %s is: %s", value.index, value.data)
|
||||
break
|
||||
|
||||
def clear_usercode(service):
|
||||
def clear_usercode(service: ServiceCall) -> None:
|
||||
"""Set usercode to slot X on the lock."""
|
||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||
lock_node = network.nodes[node_id]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue