Add setup type hints [a] (#63424)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
eed6ca51e9
commit
6a67143732
6 changed files with 59 additions and 17 deletions
|
@ -1,4 +1,5 @@
|
||||||
"""AirTouch 4 component to control of AirTouch 4 Climate Devices."""
|
"""AirTouch 4 component to control of AirTouch 4 Climate Devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -19,9 +20,11 @@ from homeassistant.components.climate.const import (
|
||||||
SUPPORT_FAN_MODE,
|
SUPPORT_FAN_MODE,
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
SUPPORT_TARGET_TEMPERATURE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -63,14 +66,21 @@ HA_FAN_SPEED_TO_AT = {value: key for key, value in AT_TO_HA_FAN_SPEED.items()}
|
||||||
_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 Airtouch 4."""
|
"""Set up the Airtouch 4."""
|
||||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
info = coordinator.data
|
info = coordinator.data
|
||||||
entities = [
|
entities: list[ClimateEntity] = [
|
||||||
AirtouchGroup(coordinator, group["group_number"], info)
|
AirtouchGroup(coordinator, group["group_number"], info)
|
||||||
for group in info["groups"]
|
for group in info["groups"]
|
||||||
] + [AirtouchAC(coordinator, ac["ac_number"], info) for ac in info["acs"]]
|
]
|
||||||
|
entities.extend(
|
||||||
|
AirtouchAC(coordinator, ac["ac_number"], info) for ac in info["acs"]
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER.debug(" Found entities %s", entities)
|
_LOGGER.debug(" Found entities %s", entities)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Stock market information from Alpha Vantage."""
|
"""Stock market information from Alpha Vantage."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -8,7 +10,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_CURRENCY, CONF_NAME
|
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_CURRENCY, CONF_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
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -61,7 +66,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 Alpha Vantage sensor."""
|
"""Set up the Alpha Vantage sensor."""
|
||||||
api_key = config[CONF_API_KEY]
|
api_key = config[CONF_API_KEY]
|
||||||
symbols = config.get(CONF_SYMBOLS, [])
|
symbols = config.get(CONF_SYMBOLS, [])
|
||||||
|
@ -75,7 +85,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
|
||||||
timeseries = TimeSeries(key=api_key)
|
timeseries = TimeSeries(key=api_key)
|
||||||
|
|
||||||
dev = []
|
dev: list[SensorEntity] = []
|
||||||
for symbol in symbols:
|
for symbol in symbols:
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Configuring timeseries for symbols: %s", symbol[CONF_SYMBOL])
|
_LOGGER.debug("Configuring timeseries for symbols: %s", symbol[CONF_SYMBOL])
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for ANEL PwrCtrl switches."""
|
"""Support for ANEL PwrCtrl switches."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -7,7 +9,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_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
|
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__)
|
||||||
|
@ -28,7 +33,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 PwrCtrl devices/switches."""
|
"""Set up PwrCtrl devices/switches."""
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
username = config[CONF_USERNAME]
|
username = config[CONF_USERNAME]
|
||||||
|
@ -46,9 +56,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
master.query(ip_addr=host)
|
master.query(ip_addr=host)
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
_LOGGER.error("Unable to discover PwrCtrl device: %s", str(ex))
|
_LOGGER.error("Unable to discover PwrCtrl device: %s", str(ex))
|
||||||
return False
|
return
|
||||||
|
|
||||||
devices = []
|
devices: list[SwitchEntity] = []
|
||||||
for device in master.devices.values():
|
for device in master.devices.values():
|
||||||
parent_device = PwrCtrlDevice(device)
|
parent_device = PwrCtrlDevice(device)
|
||||||
devices.extend(
|
devices.extend(
|
||||||
|
|
|
@ -28,10 +28,12 @@ from homeassistant.const import (
|
||||||
URL_API_TEMPLATE,
|
URL_API_TEMPLATE,
|
||||||
)
|
)
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ServiceNotFound, TemplateError, Unauthorized
|
from homeassistant.exceptions import ServiceNotFound, TemplateError, Unauthorized
|
||||||
from homeassistant.helpers import template
|
from homeassistant.helpers import template
|
||||||
from homeassistant.helpers.json import JSONEncoder
|
from homeassistant.helpers.json import JSONEncoder
|
||||||
from homeassistant.helpers.service import async_get_all_descriptions
|
from homeassistant.helpers.service import async_get_all_descriptions
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ STREAM_PING_PAYLOAD = "ping"
|
||||||
STREAM_PING_INTERVAL = 50 # seconds
|
STREAM_PING_INTERVAL = 50 # seconds
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Register the API with the HTTP interface."""
|
"""Register the API with the HTTP interface."""
|
||||||
hass.http.register_view(APIStatusView)
|
hass.http.register_view(APIStatusView)
|
||||||
hass.http.register_view(APIEventStream)
|
hass.http.register_view(APIEventStream)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Support for an exposed aREST RESTful API of a device."""
|
"""Support for an exposed aREST RESTful API of a device."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
@ -8,7 +9,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_NAME, CONF_RESOURCE
|
from homeassistant.const import CONF_NAME, CONF_RESOURCE
|
||||||
|
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
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -39,7 +43,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 aREST switches."""
|
"""Set up the aREST switches."""
|
||||||
resource = config[CONF_RESOURCE]
|
resource = config[CONF_RESOURCE]
|
||||||
|
|
||||||
|
@ -49,12 +58,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Missing resource or schema in configuration. Add http:// to your URL"
|
"Missing resource or schema in configuration. Add http:// to your URL"
|
||||||
)
|
)
|
||||||
return False
|
return
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
_LOGGER.error("No route to device at %s", resource)
|
_LOGGER.error("No route to device at %s", resource)
|
||||||
return False
|
return
|
||||||
|
|
||||||
dev = []
|
dev: list[SwitchEntity] = []
|
||||||
pins = config[CONF_PINS]
|
pins = config[CONF_PINS]
|
||||||
for pinnum, pin in pins.items():
|
for pinnum, pin in pins.items():
|
||||||
dev.append(
|
dev.append(
|
||||||
|
|
|
@ -10,10 +10,11 @@ from asterisk_mbox.commands import (
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_connect
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up for the Asterisk Voicemail box."""
|
"""Set up for the Asterisk Voicemail box."""
|
||||||
conf = config.get(DOMAIN)
|
conf = config[DOMAIN]
|
||||||
|
|
||||||
host = conf[CONF_HOST]
|
host = conf[CONF_HOST]
|
||||||
port = conf[CONF_PORT]
|
port = conf[CONF_PORT]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue