mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
Improve typing in unifi services (#87072)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
"""UniFi Network services."""
|
||||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
|
||||
from aiounifi.models.client import ClientReconnectRequest, ClientRemoveRequest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import ATTR_DEVICE_ID
|
||||
from homeassistant.core import ServiceCall, callback
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
|
||||
@@ -25,7 +27,7 @@ SERVICE_TO_SCHEMA = {
|
||||
|
||||
|
||||
@callback
|
||||
def async_setup_services(hass) -> None:
|
||||
def async_setup_services(hass: HomeAssistant) -> None:
|
||||
"""Set up services for UniFi integration."""
|
||||
|
||||
services = {
|
||||
@@ -47,13 +49,13 @@ def async_setup_services(hass) -> None:
|
||||
|
||||
|
||||
@callback
|
||||
def async_unload_services(hass) -> None:
|
||||
def async_unload_services(hass: HomeAssistant) -> None:
|
||||
"""Unload UniFi Network services."""
|
||||
for service in SUPPORTED_SERVICES:
|
||||
hass.services.async_remove(UNIFI_DOMAIN, service)
|
||||
|
||||
|
||||
async def async_reconnect_client(hass, data) -> None:
|
||||
async def async_reconnect_client(hass: HomeAssistant, data: Mapping[str, Any]) -> None:
|
||||
"""Try to get wireless client to reconnect to Wi-Fi."""
|
||||
device_registry = dr.async_get(hass)
|
||||
device_entry = device_registry.async_get(data[ATTR_DEVICE_ID])
|
||||
@@ -81,7 +83,7 @@ async def async_reconnect_client(hass, data) -> None:
|
||||
await controller.api.request(ClientReconnectRequest.create(mac))
|
||||
|
||||
|
||||
async def async_remove_clients(hass, data) -> None:
|
||||
async def async_remove_clients(hass: HomeAssistant, data: Mapping[str, Any]) -> None:
|
||||
"""Remove select clients from controller.
|
||||
|
||||
Validates based on:
|
||||
|
Reference in New Issue
Block a user