Add setup type hints [l] (#63450)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
177b573454
commit
506a0b526b
10 changed files with 118 additions and 26 deletions
|
@ -1,4 +1,6 @@
|
|||
"""Support for LaCrosse sensor components."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -22,10 +24,12 @@ from homeassistant.const import (
|
|||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -67,10 +71,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the LaCrosse sensors."""
|
||||
usb_device = config.get(CONF_DEVICE)
|
||||
baud = int(config.get(CONF_BAUD))
|
||||
usb_device = config[CONF_DEVICE]
|
||||
baud = int(config[CONF_BAUD])
|
||||
expire_after = config.get(CONF_EXPIRE_AFTER)
|
||||
|
||||
_LOGGER.debug("%s %s", usb_device, baud)
|
||||
|
@ -80,7 +89,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
lacrosse.open()
|
||||
except SerialException as exc:
|
||||
_LOGGER.warning("Unable to open serial port: %s", exc)
|
||||
return False
|
||||
return
|
||||
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda event: lacrosse.close())
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Sensor for Last.fm account status."""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
import re
|
||||
|
@ -9,7 +11,10 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -32,10 +37,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Last.fm sensor platform."""
|
||||
api_key = config[CONF_API_KEY]
|
||||
users = config.get(CONF_USERS)
|
||||
users = config[CONF_USERS]
|
||||
|
||||
lastfm_api = lastfm.LastFMNetwork(api_key=api_key)
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for LG TV running on NetCast 3 or 4."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from pylgnetcast import LgNetCastClient, LgNetCastError
|
||||
|
@ -28,8 +30,11 @@ from homeassistant.const import (
|
|||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.script import Script
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
@ -62,12 +67,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the LG TV platform."""
|
||||
|
||||
host = config.get(CONF_HOST)
|
||||
access_token = config.get(CONF_ACCESS_TOKEN)
|
||||
name = config.get(CONF_NAME)
|
||||
name = config[CONF_NAME]
|
||||
on_action = config.get(CONF_ON_ACTION)
|
||||
|
||||
client = LgNetCastClient(host, access_token)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for LimitlessLED bulbs."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from limitlessled import Color
|
||||
|
@ -31,8 +33,11 @@ from homeassistant.components.light import (
|
|||
LightEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_TYPE, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util.color import color_hs_to_RGB, color_temperature_mired_to_kelvin
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -143,7 +148,12 @@ def rewrite_legacy(config):
|
|||
return {"bridges": new_bridges}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the LimitlessLED lights."""
|
||||
|
||||
# Two legacy configuration formats are supported to maintain backwards
|
||||
|
@ -152,7 +162,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
|
||||
# Use the expanded configuration format.
|
||||
lights = []
|
||||
for bridge_conf in config.get(CONF_BRIDGES):
|
||||
for bridge_conf in config[CONF_BRIDGES]:
|
||||
bridge = Bridge(
|
||||
bridge_conf.get(CONF_HOST),
|
||||
port=bridge_conf.get(CONF_PORT, DEFAULT_PORT),
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for monitoring the state of Linode Nodes."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -8,7 +10,10 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import (
|
||||
ATTR_CREATED,
|
||||
|
@ -31,10 +36,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Linode droplet sensor."""
|
||||
linode = hass.data.get(DATA_LINODE)
|
||||
nodes = config.get(CONF_NODES)
|
||||
linode = hass.data[DATA_LINODE]
|
||||
nodes = config[CONF_NODES]
|
||||
|
||||
dev = []
|
||||
for node in nodes:
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
"""Support for interacting with Linode nodes."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import (
|
||||
ATTR_CREATED,
|
||||
|
@ -28,10 +33,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Linode Node switch."""
|
||||
linode = hass.data.get(DATA_LINODE)
|
||||
nodes = config.get(CONF_NODES)
|
||||
linode = hass.data[DATA_LINODE]
|
||||
nodes = config[CONF_NODES]
|
||||
|
||||
dev = []
|
||||
for node in nodes:
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
from typing import Any
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
ATTR_BATTERY_CHARGING,
|
||||
|
@ -13,8 +14,11 @@ from homeassistant.const import (
|
|||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util.dt import as_local
|
||||
|
||||
from .const import ATTRIBUTION, DEVICE_BRAND, DOMAIN as LOGI_CIRCLE_DOMAIN, SENSOR_TYPES
|
||||
|
@ -22,17 +26,24 @@ from .const import ATTRIBUTION, DEVICE_BRAND, DOMAIN as LOGI_CIRCLE_DOMAIN, SENS
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up a sensor for a Logi Circle device. Obsolete."""
|
||||
_LOGGER.warning("Logi Circle no longer works with sensor platform configuration")
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up a Logi Circle sensor based on a config entry."""
|
||||
devices = await hass.data[LOGI_CIRCLE_DOMAIN].cameras
|
||||
time_zone = str(hass.config.time_zone)
|
||||
|
||||
monitored_conditions = entry.data.get(CONF_SENSORS).get(CONF_MONITORED_CONDITIONS)
|
||||
monitored_conditions = entry.data[CONF_SENSORS].get(CONF_MONITORED_CONDITIONS)
|
||||
entities = [
|
||||
LogiSensor(device, time_zone, description)
|
||||
for description in SENSOR_TYPES
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Sensor for checking the status of London air."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from http import HTTPStatus
|
||||
import logging
|
||||
|
@ -7,7 +9,10 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -60,12 +65,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the London Air sensor."""
|
||||
data = APIData()
|
||||
data.update()
|
||||
sensors = []
|
||||
for name in config.get(CONF_LOCATIONS):
|
||||
for name in config[CONF_LOCATIONS]:
|
||||
sensors.append(AirSensor(name, data))
|
||||
|
||||
add_entities(sensors, True)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Sensor for checking the status of London Underground tube lines."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from london_tube_status import TubeData
|
||||
|
@ -6,7 +8,10 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
ATTRIBUTION = "Powered by TfL Open Data"
|
||||
|
||||
|
@ -38,13 +43,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Tube sensor."""
|
||||
|
||||
data = TubeData()
|
||||
data.update()
|
||||
sensors = []
|
||||
for line in config.get(CONF_LINE):
|
||||
for line in config[CONF_LINE]:
|
||||
sensors.append(LondonTubeSensor(line, data))
|
||||
|
||||
add_entities(sensors, True)
|
||||
|
|
|
@ -11,9 +11,11 @@ from homeassistant.const import (
|
|||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util import slugify
|
||||
|
||||
DOMAIN = "lutron"
|
||||
|
@ -50,7 +52,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
def setup(hass, base_config):
|
||||
def setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
|
||||
"""Set up the Lutron integration."""
|
||||
hass.data[LUTRON_BUTTONS] = []
|
||||
hass.data[LUTRON_CONTROLLER] = None
|
||||
|
@ -62,7 +64,7 @@ def setup(hass, base_config):
|
|||
"binary_sensor": [],
|
||||
}
|
||||
|
||||
config = base_config.get(DOMAIN)
|
||||
config = base_config[DOMAIN]
|
||||
hass.data[LUTRON_CONTROLLER] = Lutron(
|
||||
config[CONF_HOST], config[CONF_USERNAME], config[CONF_PASSWORD]
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue