Add missing type hints to homekit_controller (#65368)

This commit is contained in:
Jc2k 2022-02-01 19:30:37 +00:00 committed by GitHub
parent aef6f49eff
commit 9f5d77e0df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 389 additions and 312 deletions

View file

@ -13,8 +13,10 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType
from . import KNOWN_DEVICES, CharacteristicEntity
from .connection import HKDevice
NUMBER_ENTITIES: dict[str, NumberEntityDescription] = {
CharacteristicsTypes.VENDOR_VOCOLINC_HUMIDIFIER_SPRAY_LEVEL: NumberEntityDescription(
@ -90,7 +92,7 @@ async def async_setup_entry(
conn = hass.data[KNOWN_DEVICES][hkid]
@callback
def async_add_characteristic(char: Characteristic):
def async_add_characteristic(char: Characteristic) -> bool:
entities = []
info = {"aid": char.service.accessory.aid, "iid": char.service.iid}
@ -112,11 +114,11 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
def __init__(
self,
conn,
info,
char,
conn: HKDevice,
info: ConfigType,
char: Characteristic,
description: NumberEntityDescription,
):
) -> None:
"""Initialise a HomeKit number control."""
self.entity_description = description
super().__init__(conn, info, char)
@ -128,7 +130,7 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
return f"{prefix} {self.entity_description.name}"
return self.entity_description.name
def get_characteristic_types(self):
def get_characteristic_types(self) -> list[str]:
"""Define the homekit characteristics the entity is tracking."""
return [self._char.type]
@ -152,7 +154,7 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
"""Return the current characteristic value."""
return self._char.value
async def async_set_value(self, value: float):
async def async_set_value(self, value: float) -> None:
"""Set the characteristic to this value."""
await self.async_put_characteristics(
{
@ -164,7 +166,7 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
class HomeKitEcobeeFanModeNumber(CharacteristicEntity, NumberEntity):
"""Representation of a Number control for Ecobee Fan Mode request."""
def get_characteristic_types(self):
def get_characteristic_types(self) -> list[str]:
"""Define the homekit characteristics the entity is tracking."""
return [self._char.type]
@ -196,7 +198,7 @@ class HomeKitEcobeeFanModeNumber(CharacteristicEntity, NumberEntity):
"""Return the current characteristic value."""
return self._char.value
async def async_set_value(self, value: float):
async def async_set_value(self, value: float) -> None:
"""Set the characteristic to this value."""
# Sending the fan mode request sometimes ends up getting ignored by ecobee