Improve typing in unifi services (#87072)

This commit is contained in:
epenet 2023-02-01 11:45:04 +01:00 committed by GitHub
parent ad87c4557d
commit 2b4796b9ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: