Add setup type hints [e] (#63430)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
cd5bd2ff8b
commit
3f3ba4f714
8 changed files with 93 additions and 22 deletions
homeassistant/components
eddystone_temperature
elkm1
entur_public_transport
|
@ -4,6 +4,8 @@ Read temperature information from Eddystone beacons.
|
||||||
Your beacons must be configured to transmit UID (for identification) and TLM
|
Your beacons must be configured to transmit UID (for identification) and TLM
|
||||||
(for temperature) frames.
|
(for temperature) frames.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
|
@ -22,7 +24,10 @@ from homeassistant.const import (
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
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__)
|
||||||
|
|
||||||
|
@ -47,11 +52,16 @@ 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:
|
||||||
"""Validate configuration, create devices and start monitoring thread."""
|
"""Validate configuration, create devices and start monitoring thread."""
|
||||||
bt_device_id = config.get("bt_device_id")
|
bt_device_id = config.get("bt_device_id")
|
||||||
|
|
||||||
beacons = config.get(CONF_BEACONS)
|
beacons = config[CONF_BEACONS]
|
||||||
devices = []
|
devices = []
|
||||||
|
|
||||||
for dev_name, properties in beacons.items():
|
for dev_name, properties in beacons.items():
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Each ElkM1 area will be created as a separate alarm_control_panel."""
|
"""Each ElkM1 area will be created as a separate alarm_control_panel."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from elkm1_lib.const import AlarmState, ArmedStatus, ArmLevel, ArmUpState
|
from elkm1_lib.const import AlarmState, ArmedStatus, ArmLevel, ArmUpState
|
||||||
from elkm1_lib.util import username
|
from elkm1_lib.util import username
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -13,6 +15,7 @@ from homeassistant.components.alarm_control_panel.const import (
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
SUPPORT_ALARM_ARM_HOME,
|
||||||
SUPPORT_ALARM_ARM_NIGHT,
|
SUPPORT_ALARM_ARM_NIGHT,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ALARM_ARMED_AWAY,
|
STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME,
|
STATE_ALARM_ARMED_HOME,
|
||||||
|
@ -22,8 +25,10 @@ from homeassistant.const import (
|
||||||
STATE_ALARM_PENDING,
|
STATE_ALARM_PENDING,
|
||||||
STATE_ALARM_TRIGGERED,
|
STATE_ALARM_TRIGGERED,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
|
||||||
from . import ElkAttachedEntity, create_elk_entities
|
from . import ElkAttachedEntity, create_elk_entities
|
||||||
|
@ -53,11 +58,15 @@ SERVICE_ALARM_BYPASS = "alarm_bypass"
|
||||||
SERVICE_ALARM_CLEAR_BYPASS = "alarm_clear_bypass"
|
SERVICE_ALARM_CLEAR_BYPASS = "alarm_clear_bypass"
|
||||||
|
|
||||||
|
|
||||||
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 ElkM1 alarm platform."""
|
"""Set up the ElkM1 alarm platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
entities = []
|
entities: list[ElkArea] = []
|
||||||
create_elk_entities(elk_data, elk.areas, "area", ElkArea, entities)
|
create_elk_entities(elk_data, elk.areas, "area", ElkArea, entities)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for control of Elk-M1 connected thermostats."""
|
"""Support for control of Elk-M1 connected thermostats."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from elkm1_lib.const import ThermostatFan, ThermostatMode, ThermostatSetting
|
from elkm1_lib.const import ThermostatFan, ThermostatMode, ThermostatSetting
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity
|
from homeassistant.components.climate import ClimateEntity
|
||||||
|
@ -14,7 +16,10 @@ from homeassistant.components.climate.const import (
|
||||||
SUPPORT_FAN_MODE,
|
SUPPORT_FAN_MODE,
|
||||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PRECISION_WHOLE, STATE_ON
|
from homeassistant.const import PRECISION_WHOLE, STATE_ON
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkEntity, create_elk_entities
|
from . import ElkEntity, create_elk_entities
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -28,10 +33,14 @@ SUPPORT_HVAC = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Create the Elk-M1 thermostat platform."""
|
"""Create the Elk-M1 thermostat platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = []
|
entities: list[ElkThermostat] = []
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
create_elk_entities(
|
create_elk_entities(
|
||||||
elk_data, elk.thermostats, "thermostat", ElkThermostat, entities
|
elk_data, elk.thermostats, "thermostat", ElkThermostat, entities
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
"""Support for control of ElkM1 lighting (X10, UPB, etc)."""
|
"""Support for control of ElkM1 lighting (X10, UPB, etc)."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkEntity, create_elk_entities
|
from . import ElkEntity, create_elk_entities
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
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 Elk light platform."""
|
"""Set up the Elk light platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = []
|
entities: list[ElkLight] = []
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
create_elk_entities(elk_data, elk.lights, "plc", ElkLight, entities)
|
create_elk_entities(elk_data, elk.lights, "plc", ElkLight, entities)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
"""Support for control of ElkM1 tasks ("macros")."""
|
"""Support for control of ElkM1 tasks ("macros")."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.scene import Scene
|
from homeassistant.components.scene import Scene
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkAttachedEntity, create_elk_entities
|
from . import ElkAttachedEntity, create_elk_entities
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Create the Elk-M1 scene platform."""
|
"""Create the Elk-M1 scene platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = []
|
entities: list[ElkTask] = []
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
create_elk_entities(elk_data, elk.tasks, "task", ElkTask, entities)
|
create_elk_entities(elk_data, elk.tasks, "task", ElkTask, entities)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for control of ElkM1 sensors."""
|
"""Support for control of ElkM1 sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from elkm1_lib.const import (
|
from elkm1_lib.const import (
|
||||||
SettingFormat,
|
SettingFormat,
|
||||||
ZoneLogicalStatus,
|
ZoneLogicalStatus,
|
||||||
|
@ -9,10 +11,13 @@ from elkm1_lib.util import pretty_const, username
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT
|
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkAttachedEntity, create_elk_entities
|
from . import ElkAttachedEntity, create_elk_entities
|
||||||
from .const import ATTR_VALUE, DOMAIN, ELK_USER_CODE_SERVICE_SCHEMA
|
from .const import ATTR_VALUE, DOMAIN, ELK_USER_CODE_SERVICE_SCHEMA
|
||||||
|
@ -28,10 +33,14 @@ ELK_SET_COUNTER_SERVICE_SCHEMA = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Create the Elk-M1 sensor platform."""
|
"""Create the Elk-M1 sensor platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = []
|
entities: list[ElkSensor] = []
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
create_elk_entities(elk_data, elk.counters, "counter", ElkCounter, entities)
|
create_elk_entities(elk_data, elk.counters, "counter", ElkCounter, entities)
|
||||||
create_elk_entities(elk_data, elk.keypads, "keypad", ElkKeypad, entities)
|
create_elk_entities(elk_data, elk.keypads, "keypad", ElkKeypad, entities)
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
"""Support for control of ElkM1 outputs (relays)."""
|
"""Support for control of ElkM1 outputs (relays)."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkAttachedEntity, create_elk_entities
|
from . import ElkAttachedEntity, create_elk_entities
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Create the Elk-M1 switch platform."""
|
"""Create the Elk-M1 switch platform."""
|
||||||
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
elk_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities = []
|
entities: list[ElkOutput] = []
|
||||||
elk = elk_data["elk"]
|
elk = elk_data["elk"]
|
||||||
create_elk_entities(elk_data, elk.outputs, "output", ElkOutput, entities)
|
create_elk_entities(elk_data, elk.outputs, "output", ElkOutput, entities)
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
|
@ -15,8 +15,11 @@ from homeassistant.const import (
|
||||||
CONF_SHOW_ON_MAP,
|
CONF_SHOW_ON_MAP,
|
||||||
TIME_MINUTES,
|
TIME_MINUTES,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
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.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
@ -85,16 +88,21 @@ def due_in_minutes(timestamp: datetime) -> int:
|
||||||
return int(diff.total_seconds() / 60)
|
return int(diff.total_seconds() / 60)
|
||||||
|
|
||||||
|
|
||||||
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 the Entur public transport sensor."""
|
"""Set up the Entur public transport sensor."""
|
||||||
|
|
||||||
expand = config.get(CONF_EXPAND_PLATFORMS)
|
expand = config[CONF_EXPAND_PLATFORMS]
|
||||||
line_whitelist = config.get(CONF_WHITELIST_LINES)
|
line_whitelist = config[CONF_WHITELIST_LINES]
|
||||||
name = config.get(CONF_NAME)
|
name = config[CONF_NAME]
|
||||||
show_on_map = config.get(CONF_SHOW_ON_MAP)
|
show_on_map = config[CONF_SHOW_ON_MAP]
|
||||||
stop_ids = config.get(CONF_STOP_IDS)
|
stop_ids = config[CONF_STOP_IDS]
|
||||||
omit_non_boarding = config.get(CONF_OMIT_NON_BOARDING)
|
omit_non_boarding = config[CONF_OMIT_NON_BOARDING]
|
||||||
number_of_departures = config.get(CONF_NUMBER_OF_DEPARTURES)
|
number_of_departures = config[CONF_NUMBER_OF_DEPARTURES]
|
||||||
|
|
||||||
stops = [s for s in stop_ids if "StopPlace" in s]
|
stops = [s for s in stop_ids if "StopPlace" in s]
|
||||||
quays = [s for s in stop_ids if "Quay" in s]
|
quays = [s for s in stop_ids if "Quay" in s]
|
||||||
|
|
Loading…
Add table
Reference in a new issue