mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Improve typing in unifi services (#87072)
This commit is contained in:
parent
ad87c4557d
commit
2b4796b9ac
@ -1,10 +1,12 @@
|
|||||||
"""UniFi Network services."""
|
"""UniFi Network services."""
|
||||||
|
from collections.abc import Mapping
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from aiounifi.models.client import ClientReconnectRequest, ClientRemoveRequest
|
from aiounifi.models.client import ClientReconnectRequest, ClientRemoveRequest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_DEVICE_ID
|
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 import device_registry as dr
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ SERVICE_TO_SCHEMA = {
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_setup_services(hass) -> None:
|
def async_setup_services(hass: HomeAssistant) -> None:
|
||||||
"""Set up services for UniFi integration."""
|
"""Set up services for UniFi integration."""
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
@ -47,13 +49,13 @@ def async_setup_services(hass) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_unload_services(hass) -> None:
|
def async_unload_services(hass: HomeAssistant) -> None:
|
||||||
"""Unload UniFi Network services."""
|
"""Unload UniFi Network services."""
|
||||||
for service in SUPPORTED_SERVICES:
|
for service in SUPPORTED_SERVICES:
|
||||||
hass.services.async_remove(UNIFI_DOMAIN, service)
|
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."""
|
"""Try to get wireless client to reconnect to Wi-Fi."""
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
device_entry = device_registry.async_get(data[ATTR_DEVICE_ID])
|
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))
|
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.
|
"""Remove select clients from controller.
|
||||||
|
|
||||||
Validates based on:
|
Validates based on:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user