mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Add setup type hints [o-q] (#63465)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
754f4c52c2
commit
8756fa28e2
@ -26,8 +26,10 @@ from homeassistant.const import (
|
|||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -172,10 +174,14 @@ def determine_zones(receiver):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
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 Onkyo platform."""
|
"""Set up the Onkyo platform."""
|
||||||
host = config.get(CONF_HOST)
|
hosts: list[OnkyoDevice] = []
|
||||||
hosts = []
|
|
||||||
|
|
||||||
def service_handle(service: ServiceCall) -> None:
|
def service_handle(service: ServiceCall) -> None:
|
||||||
"""Handle for services."""
|
"""Handle for services."""
|
||||||
@ -193,7 +199,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
schema=ONKYO_SELECT_OUTPUT_SCHEMA,
|
schema=ONKYO_SELECT_OUTPUT_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
if CONF_HOST in config and host not in KNOWN_HOSTS:
|
if CONF_HOST in config and (host := config[CONF_HOST]) not in KNOWN_HOSTS:
|
||||||
try:
|
try:
|
||||||
receiver = eiscp.eISCP(host)
|
receiver = eiscp.eISCP(host)
|
||||||
hosts.append(
|
hosts.append(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Allows to configure a switch using RPi GPIO."""
|
"""Allows to configure a switch using RPi GPIO."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pi4ioe5v9xxxx import pi4ioe5v9xxxx
|
from pi4ioe5v9xxxx import pi4ioe5v9xxxx
|
||||||
@ -6,7 +8,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
CONF_PINS = "pins"
|
CONF_PINS = "pins"
|
||||||
CONF_INVERT_LOGIC = "invert_logic"
|
CONF_INVERT_LOGIC = "invert_logic"
|
||||||
@ -34,7 +39,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
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 swiches devices."""
|
"""Set up the swiches devices."""
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"The pi4ioe5v9xxxx IO Expander integration is deprecated and will be removed "
|
"The pi4ioe5v9xxxx IO Expander integration is deprecated and will be removed "
|
||||||
@ -43,7 +53,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
"https://github.com/home-assistant/architecture/blob/master/adr/0019-GPIO.md"
|
"https://github.com/home-assistant/architecture/blob/master/adr/0019-GPIO.md"
|
||||||
)
|
)
|
||||||
|
|
||||||
pins = config.get(CONF_PINS)
|
pins = config[CONF_PINS]
|
||||||
switches = []
|
switches = []
|
||||||
|
|
||||||
pi4ioe5v9xxxx.setup(
|
pi4ioe5v9xxxx.setup(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for switching devices via Pilight to on and off."""
|
"""Support for switching devices via Pilight to on and off."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
@ -8,7 +10,10 @@ from homeassistant.components.light import (
|
|||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_LIGHTS
|
from homeassistant.const import CONF_LIGHTS
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .base_class import SWITCHES_SCHEMA, PilightBaseDevice
|
from .base_class import SWITCHES_SCHEMA, PilightBaseDevice
|
||||||
from .const import CONF_DIMLEVEL_MAX, CONF_DIMLEVEL_MIN
|
from .const import CONF_DIMLEVEL_MAX, CONF_DIMLEVEL_MIN
|
||||||
@ -25,9 +30,14 @@ 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 Pilight platform."""
|
"""Set up the Pilight platform."""
|
||||||
switches = config.get(CONF_LIGHTS)
|
switches = config[CONF_LIGHTS]
|
||||||
devices = []
|
devices = []
|
||||||
|
|
||||||
for dev_name, dev_config in switches.items():
|
for dev_name, dev_config in switches.items():
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
"""Support for switching devices via Pilight to on and off."""
|
"""Support for switching devices via Pilight to on and off."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||||
from homeassistant.const import CONF_SWITCHES
|
from homeassistant.const import CONF_SWITCHES
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .base_class import SWITCHES_SCHEMA, PilightBaseDevice
|
from .base_class import SWITCHES_SCHEMA, PilightBaseDevice
|
||||||
|
|
||||||
@ -12,9 +17,14 @@ 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 Pilight platform."""
|
"""Set up the Pilight platform."""
|
||||||
switches = config.get(CONF_SWITCHES)
|
switches = config[CONF_SWITCHES]
|
||||||
devices = []
|
devices = []
|
||||||
|
|
||||||
for dev_name, dev_config in switches.items():
|
for dev_name, dev_config in switches.items():
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for August sensors."""
|
"""Support for August sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from tesla_powerwall import MeterType
|
from tesla_powerwall import MeterType
|
||||||
@ -8,7 +10,10 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_KILO_WATT
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_KILO_WATT
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_FREQUENCY,
|
ATTR_FREQUENCY,
|
||||||
@ -34,7 +39,11 @@ _METER_DIRECTIONS = [_METER_DIRECTION_EXPORT, _METER_DIRECTION_IMPORT]
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
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."""
|
"""Set up the August sensors."""
|
||||||
powerwall_data = hass.data[DOMAIN][config_entry.entry_id]
|
powerwall_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
_LOGGER.debug("Powerwall_data: %s", powerwall_data)
|
_LOGGER.debug("Powerwall_data: %s", powerwall_data)
|
||||||
@ -45,7 +54,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
status = powerwall_data[POWERWALL_API_STATUS]
|
status = powerwall_data[POWERWALL_API_STATUS]
|
||||||
powerwalls_serial_numbers = powerwall_data[POWERWALL_API_SERIAL_NUMBERS]
|
powerwalls_serial_numbers = powerwall_data[POWERWALL_API_SERIAL_NUMBERS]
|
||||||
|
|
||||||
entities = []
|
entities: list[SensorEntity] = []
|
||||||
# coordinator.data[POWERWALL_API_METERS].meters holds all meters that are available
|
# coordinator.data[POWERWALL_API_METERS].meters holds all meters that are available
|
||||||
for meter in coordinator.data[POWERWALL_API_METERS].meters:
|
for meter in coordinator.data[POWERWALL_API_METERS].meters:
|
||||||
entities.append(
|
entities.append(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Switch logic for loading/unloading pulseaudio loopback modules."""
|
"""Switch logic for loading/unloading pulseaudio loopback modules."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pulsectl import Pulse, PulseError
|
from pulsectl import Pulse, PulseError
|
||||||
@ -6,7 +8,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
DOMAIN = "pulseaudio_loopback"
|
DOMAIN = "pulseaudio_loopback"
|
||||||
|
|
||||||
@ -31,7 +36,12 @@ 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:
|
||||||
"""Read in all of our configuration, and initialize the loopback switch."""
|
"""Read in all of our configuration, and initialize the loopback switch."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
sink_name = config.get(CONF_SINK_NAME)
|
sink_name = config.get(CONF_SINK_NAME)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for monitoring pyLoad."""
|
"""Support for monitoring pyLoad."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -18,7 +20,10 @@ from homeassistant.const import (
|
|||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
DATA_RATE_MEGABYTES_PER_SECOND,
|
DATA_RATE_MEGABYTES_PER_SECOND,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -46,15 +51,20 @@ 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 pyLoad sensors."""
|
"""Set up the pyLoad sensors."""
|
||||||
host = config.get(CONF_HOST)
|
host = config[CONF_HOST]
|
||||||
port = config.get(CONF_PORT)
|
port = config[CONF_PORT]
|
||||||
protocol = "https" if config[CONF_SSL] else "http"
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
name = config.get(CONF_NAME)
|
name = config[CONF_NAME]
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
monitored_types = config.get(CONF_MONITORED_VARIABLES)
|
monitored_types = config[CONF_MONITORED_VARIABLES]
|
||||||
url = f"{protocol}://{host}:{port}/api/"
|
url = f"{protocol}://{host}:{port}/api/"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -64,7 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
requests.exceptions.HTTPError,
|
requests.exceptions.HTTPError,
|
||||||
) as conn_err:
|
) as conn_err:
|
||||||
_LOGGER.error("Error setting up pyLoad API: %s", conn_err)
|
_LOGGER.error("Error setting up pyLoad API: %s", conn_err)
|
||||||
return False
|
return
|
||||||
|
|
||||||
devices = []
|
devices = []
|
||||||
for ng_type in monitored_types:
|
for ng_type in monitored_types:
|
||||||
|
@ -28,8 +28,11 @@ from homeassistant.const import (
|
|||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
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
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -193,7 +196,12 @@ 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 QNAP NAS sensor."""
|
"""Set up the QNAP NAS sensor."""
|
||||||
api = QNAPStatsAPI(config)
|
api = QNAPStatsAPI(config)
|
||||||
api.update()
|
api.update()
|
||||||
@ -203,7 +211,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
raise PlatformNotReady
|
raise PlatformNotReady
|
||||||
|
|
||||||
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
|
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
|
||||||
sensors = []
|
sensors: list[QNAPSensor] = []
|
||||||
|
|
||||||
# Basic sensors
|
# Basic sensors
|
||||||
sensors.extend(
|
sensors.extend(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for Qwikswitch devices."""
|
"""Support for Qwikswitch devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyqwikswitch.async_ import QSUsb
|
from pyqwikswitch.async_ import QSUsb
|
||||||
@ -14,11 +16,12 @@ from homeassistant.const import (
|
|||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.discovery import load_platform
|
from homeassistant.helpers.discovery import load_platform
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -130,7 +133,7 @@ class QSToggleEntity(QSEntity):
|
|||||||
self.hass.data[DOMAIN].devices.set_value(self.qsid, 0)
|
self.hass.data[DOMAIN].devices.set_value(self.qsid, 0)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Qwiskswitch component setup."""
|
"""Qwiskswitch component setup."""
|
||||||
|
|
||||||
# Add cmd's to in /&listen packets will fire events
|
# Add cmd's to in /&listen packets will fire events
|
||||||
@ -163,7 +166,12 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
hass.data[DOMAIN] = qsusb
|
hass.data[DOMAIN] = qsusb
|
||||||
|
|
||||||
comps = {"switch": [], "light": [], "sensor": [], "binary_sensor": []}
|
comps: dict[str, list] = {
|
||||||
|
"switch": [],
|
||||||
|
"light": [],
|
||||||
|
"sensor": [],
|
||||||
|
"binary_sensor": [],
|
||||||
|
}
|
||||||
|
|
||||||
sensor_ids = []
|
sensor_ids = []
|
||||||
for sens in sensors:
|
for sens in sensors:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user