Add setup type hints to august (#63388)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-05 00:32:11 +01:00 committed by GitHub
parent 058520769b
commit 4c14aad90f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 13 deletions

View file

@ -60,7 +60,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok
async def async_setup_august(hass, config_entry, august_gateway):
async def async_setup_august(
hass: HomeAssistant, config_entry: ConfigEntry, august_gateway: AugustGateway
) -> bool:
"""Set up the August component."""
if CONF_PASSWORD in config_entry.data:

View file

@ -22,8 +22,10 @@ from homeassistant.components.binary_sensor import (
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant.core import callback
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.event import async_call_later
from . import AugustData
@ -152,10 +154,14 @@ SENSOR_TYPES_DOORBELL: tuple[AugustBinarySensorEntityDescription, ...] = (
)
async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the August binary sensors."""
data = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
entities = []
data: AugustData = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
entities: list[BinarySensorEntity] = []
for door in data.locks:
detail = data.get_device_detail(door.device_id)

View file

@ -10,6 +10,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import AugustData
from .const import DATA_AUGUST, DEFAULT_NAME, DEFAULT_TIMEOUT, DOMAIN
from .entity import AugustEntityMixin
@ -20,7 +21,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up August cameras."""
data = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
data: AugustData = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
session = aiohttp_client.async_get_clientsession(hass)
async_add_entities(
[

View file

@ -14,6 +14,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.util.dt as dt_util
from . import AugustData
from .const import DATA_AUGUST, DOMAIN
from .entity import AugustEntityMixin
@ -28,7 +29,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up August locks."""
data = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
data: AugustData = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
async_add_entities([AugustLock(data, lock) for lock in data.locks])

View file

@ -7,17 +7,20 @@ import logging
from typing import Generic, TypeVar
from yalexs.activity import ActivityType
from yalexs.doorbell import Doorbell
from yalexs.keypad import KeypadDetail
from yalexs.lock import LockDetail
from yalexs.lock import Lock, LockDetail
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ENTITY_PICTURE, PERCENTAGE, STATE_UNAVAILABLE
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.entity_registry import async_get_registry
from homeassistant.helpers.restore_state import RestoreEntity
@ -81,13 +84,17 @@ SENSOR_TYPE_KEYPAD_BATTERY = AugustSensorEntityDescription[KeypadDetail](
)
async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the August sensors."""
data = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
entities = []
data: AugustData = hass.data[DOMAIN][config_entry.entry_id][DATA_AUGUST]
entities: list[SensorEntity] = []
migrate_unique_id_devices = []
operation_sensors = []
batteries = {
batteries: dict[str, list[Doorbell | Lock]] = {
"device_battery": [],
"linked_keypad_battery": [],
}