Define AddEntitiesCallback type (#49812)

This commit is contained in:
Ruslan Sayfutdinov 2021-04-29 11:28:14 +01:00 committed by GitHub
parent de6c9e67b1
commit 0301706fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 145 additions and 106 deletions

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any, Callable from typing import Any
from bsblan import BSBLan, BSBLanError, Info, State from bsblan import BSBLan, BSBLanError, Info, State
@ -27,7 +27,7 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import ( from .const import (
ATTR_IDENTIFIERS, ATTR_IDENTIFIERS,
@ -76,7 +76,7 @@ BSBLAN_TO_HA_PRESET = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up BSBLan device based on a config entry.""" """Set up BSBLan device based on a config entry."""
bsblan: BSBLan = hass.data[DOMAIN][entry.entry_id][DATA_BSBLAN_CLIENT] bsblan: BSBLan = hass.data[DOMAIN][entry.entry_id][DATA_BSBLAN_CLIENT]

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Callable
from directv import DIRECTV from directv import DIRECTV
@ -27,6 +26,7 @@ from homeassistant.components.media_player.const import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from . import DIRECTVEntity from . import DIRECTVEntity
@ -66,7 +66,7 @@ SUPPORT_DTV_CLIENT = (
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list, bool], None], async_add_entities: AddEntitiesCallback,
) -> bool: ) -> bool:
"""Set up the DirecTV config entry.""" """Set up the DirecTV config entry."""
dtv = hass.data[DOMAIN][entry.entry_id] dtv = hass.data[DOMAIN][entry.entry_id]

View File

@ -4,13 +4,14 @@ from __future__ import annotations
from collections.abc import Iterable from collections.abc import Iterable
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any, Callable from typing import Any
from directv import DIRECTV, DIRECTVError from directv import DIRECTV, DIRECTVError
from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import DIRECTVEntity from . import DIRECTVEntity
from .const import DOMAIN from .const import DOMAIN
@ -23,7 +24,7 @@ SCAN_INTERVAL = timedelta(minutes=2)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list, bool], None], async_add_entities: AddEntitiesCallback,
) -> bool: ) -> bool:
"""Load DirecTV remote based on a config entry.""" """Load DirecTV remote based on a config entry."""
dtv = hass.data[DOMAIN][entry.entry_id] dtv = hass.data[DOMAIN][entry.entry_id]

View File

@ -1,6 +1,4 @@
"""Support for AVM Fritz!Box smarthome thermostate devices.""" """Support for AVM Fritz!Box smarthome thermostate devices."""
from typing import Callable
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
ATTR_HVAC_MODE, ATTR_HVAC_MODE,
@ -23,6 +21,7 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import FritzBoxEntity from . import FritzBoxEntity
from .const import ( from .const import (
@ -53,7 +52,7 @@ OFF_REPORT_SET_TEMPERATURE = 0.0
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up the Fritzbox smarthome thermostat from ConfigEntry.""" """Set up the Fritzbox smarthome thermostat from ConfigEntry."""
entities = [] entities = []

View File

@ -1,8 +1,6 @@
"""Binary sensors for the Elexa Guardian integration.""" """Binary sensors for the Elexa Guardian integration."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY, DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOISTURE,
@ -12,6 +10,7 @@ from homeassistant.components.binary_sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import PairedSensorEntity, ValveControllerEntity from . import PairedSensorEntity, ValveControllerEntity
@ -43,7 +42,7 @@ VALVE_CONTROLLER_SENSORS = [SENSOR_KIND_AP_INFO, SENSOR_KIND_LEAK_DETECTED]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up Guardian switches based on a config entry.""" """Set up Guardian switches based on a config entry."""

View File

@ -1,8 +1,6 @@
"""Sensors for the Elexa Guardian integration.""" """Sensors for the Elexa Guardian integration."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -14,6 +12,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import PairedSensorEntity, ValveControllerEntity from . import PairedSensorEntity, ValveControllerEntity
@ -48,7 +47,7 @@ VALVE_CONTROLLER_SENSORS = [SENSOR_KIND_TEMPERATURE, SENSOR_KIND_UPTIME]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up Guardian switches based on a config entry.""" """Set up Guardian switches based on a config entry."""

View File

@ -1,8 +1,6 @@
"""Switches for the Elexa Guardian integration.""" """Switches for the Elexa Guardian integration."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from aioguardian import Client from aioguardian import Client
from aioguardian.errors import GuardianError from aioguardian.errors import GuardianError
import voluptuous as vol import voluptuous as vol
@ -12,6 +10,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_FILENAME, CONF_PORT, CONF_URL from homeassistant.const import CONF_FILENAME, CONF_PORT, CONF_URL
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import ValveControllerEntity from . import ValveControllerEntity
@ -40,7 +39,7 @@ SERVICE_UPGRADE_FIRMWARE = "upgrade_firmware"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up Guardian switches based on a config entry.""" """Set up Guardian switches based on a config entry."""
platform = entity_platform.current_platform.get() platform = entity_platform.current_platform.get()

View File

@ -1,12 +1,10 @@
"""Binary sensor platform for Hass.io addons.""" """Binary sensor platform for Hass.io addons."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import ADDONS_COORDINATOR from . import ADDONS_COORDINATOR
from .const import ATTR_UPDATE_AVAILABLE from .const import ATTR_UPDATE_AVAILABLE
@ -16,7 +14,7 @@ from .entity import HassioAddonEntity, HassioOSEntity
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Binary sensor set up for Hass.io config entry.""" """Binary sensor set up for Hass.io config entry."""
coordinator = hass.data[ADDONS_COORDINATOR] coordinator = hass.data[ADDONS_COORDINATOR]

View File

@ -1,12 +1,10 @@
"""Sensor platform for Hass.io addons.""" """Sensor platform for Hass.io addons."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import ADDONS_COORDINATOR from . import ADDONS_COORDINATOR
from .const import ATTR_VERSION, ATTR_VERSION_LATEST from .const import ATTR_VERSION, ATTR_VERSION_LATEST
@ -16,7 +14,7 @@ from .entity import HassioAddonEntity, HassioOSEntity
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Sensor set up for Hass.io config entry.""" """Sensor set up for Hass.io config entry."""
coordinator = hass.data[ADDONS_COORDINATOR] coordinator = hass.data[ADDONS_COORDINATOR]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
import attr import attr
from huawei_lte_api.enums.cradle import ConnectionStatusEnum from huawei_lte_api.enums.cradle import ConnectionStatusEnum
@ -15,6 +15,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
from .const import ( from .const import (
@ -30,7 +31,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up from config entry.""" """Set up from config entry."""
router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]] router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]]

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import logging import logging
import re import re
from typing import Any, Callable, Dict, List, cast from typing import Any, Dict, List, cast
import attr import attr
from stringcase import snakecase from stringcase import snakecase
@ -19,6 +19,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HuaweiLteBaseEntity, Router from . import HuaweiLteBaseEntity, Router
from .const import ( from .const import (
@ -53,7 +54,7 @@ def _get_hosts(
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up from config entry.""" """Set up from config entry."""
@ -130,7 +131,7 @@ def _is_us(host: _HostType) -> bool:
def async_add_new_entities( def async_add_new_entities(
hass: HomeAssistant, hass: HomeAssistant,
router_url: str, router_url: str,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
tracked: set[str], tracked: set[str],
) -> None: ) -> None:
"""Add new entities that are not already being tracked.""" """Add new entities that are not already being tracked."""

View File

@ -25,6 +25,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
@ -356,7 +357,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up from config entry.""" """Set up from config entry."""
router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]] router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
import attr import attr
@ -15,6 +15,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
from .const import DOMAIN, KEY_DIALUP_MOBILE_DATASWITCH from .const import DOMAIN, KEY_DIALUP_MOBILE_DATASWITCH
@ -25,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up from config entry.""" """Set up from config entry."""
router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]] router = hass.data[DOMAIN].routers[config_entry.data[CONF_URL]]

View File

@ -2,13 +2,13 @@
from __future__ import annotations from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from typing import Any, Callable from typing import Any
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_LOCATION, DEVICE_CLASS_TIMESTAMP, PERCENTAGE from homeassistant.const import ATTR_LOCATION, DEVICE_CLASS_TIMESTAMP, PERCENTAGE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from . import IPPDataUpdateCoordinator, IPPEntity from . import IPPDataUpdateCoordinator, IPPEntity
@ -29,7 +29,7 @@ from .const import (
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up IPP sensor based on a config entry.""" """Set up IPP sensor based on a config entry."""
coordinator: IPPDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] coordinator: IPPDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
import aiohttp import aiohttp
from motioneye_client.client import MotionEyeClient from motioneye_client.client import MotionEyeClient
@ -30,6 +30,7 @@ from homeassistant.const import (
HTTP_DIGEST_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -58,7 +59,7 @@ PLATFORMS = ["camera"]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up motionEye from a config entry.""" """Set up motionEye from a config entry."""
entry_data = hass.data[DOMAIN][entry.entry_id] entry_data = hass.data[DOMAIN][entry.entry_id]

View File

@ -1,6 +1,4 @@
"""Support for MySensors binary sensors.""" """Support for MySensors binary sensors."""
from typing import Callable
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOISTURE,
@ -18,6 +16,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_ON from homeassistant.const import STATE_ON
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
SENSORS = { SENSORS = {
"S_DOOR": "door", "S_DOOR": "door",
@ -32,7 +31,9 @@ SENSORS = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""

View File

@ -1,6 +1,4 @@
"""MySensors platform that offers a Climate (MySensors-HVAC) component.""" """MySensors platform that offers a Climate (MySensors-HVAC) component."""
from typing import Callable
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
@ -21,6 +19,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
DICT_HA_TO_MYS = { DICT_HA_TO_MYS = {
HVAC_MODE_AUTO: "AutoChangeOver", HVAC_MODE_AUTO: "AutoChangeOver",
@ -40,7 +39,9 @@ OPERATION_LIST = [HVAC_MODE_OFF, HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_HEAT]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""

View File

@ -1,7 +1,6 @@
"""Support for MySensors covers.""" """Support for MySensors covers."""
from enum import Enum, unique from enum import Enum, unique
import logging import logging
from typing import Callable
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.cover import ATTR_POSITION, DOMAIN, CoverEntity from homeassistant.components.cover import ATTR_POSITION, DOMAIN, CoverEntity
@ -11,6 +10,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -26,7 +26,9 @@ class CoverState(Enum):
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""

View File

@ -1,6 +1,4 @@
"""Support for MySensors lights.""" """Support for MySensors lights."""
from typing import Callable
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
@ -18,6 +16,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from homeassistant.util.color import rgb_hex_to_rgb_list from homeassistant.util.color import rgb_hex_to_rgb_list
@ -25,7 +24,9 @@ SUPPORT_MYSENSORS_RGBW = SUPPORT_COLOR | SUPPORT_WHITE_VALUE
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""
device_class_map = { device_class_map = {

View File

@ -1,6 +1,4 @@
"""Support for MySensors sensors.""" """Support for MySensors sensors."""
from typing import Callable
from awesomeversion import AwesomeVersion from awesomeversion import AwesomeVersion
from homeassistant.components import mysensors from homeassistant.components import mysensors
@ -27,6 +25,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
SENSORS = { SENSORS = {
"V_TEMP": [None, "mdi:thermometer"], "V_TEMP": [None, "mdi:thermometer"],
@ -64,7 +63,9 @@ SENSORS = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""

View File

@ -1,6 +1,4 @@
"""Support for MySensors switches.""" """Support for MySensors switches."""
from typing import Callable
import voluptuous as vol import voluptuous as vol
from homeassistant.components import mysensors from homeassistant.components import mysensors
@ -8,6 +6,7 @@ from homeassistant.components.switch import DOMAIN, SwitchEntity
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant 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 . import on_unload from . import on_unload
from ...config_entries import ConfigEntry from ...config_entries import ConfigEntry
@ -22,7 +21,9 @@ SEND_IR_CODE_SERVICE_SCHEMA = vol.Schema(
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
): ):
"""Set up this platform for a specific ConfigEntry(==Gateway).""" """Set up this platform for a specific ConfigEntry(==Gateway)."""
device_class_map = { device_class_map = {

View File

@ -4,7 +4,6 @@ from __future__ import annotations
from asyncio import TimeoutError as AsyncIOTimeoutError from asyncio import TimeoutError as AsyncIOTimeoutError
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Callable
from aiohttp import ClientError from aiohttp import ClientError
from py_nightscout import Api as NightscoutAPI from py_nightscout import Api as NightscoutAPI
@ -13,7 +12,7 @@ from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_DATE from homeassistant.const import ATTR_DATE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import ATTR_DELTA, ATTR_DEVICE, ATTR_DIRECTION, DOMAIN from .const import ATTR_DELTA, ATTR_DEVICE, ATTR_DIRECTION, DOMAIN
@ -27,7 +26,7 @@ DEFAULT_NAME = "Blood Glucose"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up the Glucose Sensor.""" """Set up the Glucose Sensor."""
api = hass.data[DOMAIN][entry.entry_id] api = hass.data[DOMAIN][entry.entry_id]

View File

@ -3,7 +3,6 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Callable
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -14,7 +13,7 @@ from homeassistant.const import (
DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_TIMESTAMP,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from . import NZBGetEntity from . import NZBGetEntity
@ -44,7 +43,7 @@ SENSOR_TYPES = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up NZBGet sensor based on a config entry.""" """Set up NZBGet sensor based on a config entry."""
coordinator: NZBGetDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][ coordinator: NZBGetDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][

View File

@ -1,13 +1,11 @@
"""Support for NZBGet switches.""" """Support for NZBGet switches."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import NZBGetEntity from . import NZBGetEntity
from .const import DATA_COORDINATOR, DOMAIN from .const import DATA_COORDINATOR, DOMAIN
@ -17,7 +15,7 @@ from .coordinator import NZBGetDataUpdateCoordinator
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up NZBGet sensor based on a config entry.""" """Set up NZBGet sensor based on a config entry."""
coordinator: NZBGetDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][ coordinator: NZBGetDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from typing import Callable
from plumlightpad import Plum from plumlightpad import Plum
@ -16,7 +15,7 @@ from homeassistant.components.light import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from .const import DOMAIN from .const import DOMAIN
@ -25,7 +24,7 @@ from .const import DOMAIN
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity]], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Plum Lightpad dimmer lights and glow rings.""" """Set up Plum Lightpad dimmer lights and glow rings."""

View File

@ -1,8 +1,6 @@
"""Support for ReCollect Waste sensors.""" """Support for ReCollect Waste sensors."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from aiorecollect.client import PickupType from aiorecollect.client import PickupType
import voluptuous as vol import voluptuous as vol
@ -16,6 +14,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -57,7 +56,7 @@ def async_get_pickup_type_names(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistant, hass: HomeAssistant,
config: dict, config: dict,
async_add_entities: Callable, async_add_entities: AddEntitiesCallback,
discovery_info: dict = None, discovery_info: dict = None,
): ):
"""Import Recollect Waste configuration from YAML.""" """Import Recollect Waste configuration from YAML."""
@ -75,7 +74,7 @@ async def async_setup_platform(
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up ReCollect Waste sensors based on a config entry.""" """Set up ReCollect Waste sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]

View File

@ -1,11 +1,10 @@
"""Support for the Roku remote.""" """Support for the Roku remote."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import RokuDataUpdateCoordinator, RokuEntity, roku_exception_handler from . import RokuDataUpdateCoordinator, RokuEntity, roku_exception_handler
from .const import DOMAIN from .const import DOMAIN
@ -14,7 +13,7 @@ from .const import DOMAIN
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list, bool], None], async_add_entities: AddEntitiesCallback,
) -> bool: ) -> bool:
"""Load Roku remote based on a config entry.""" """Load Roku remote based on a config entry."""
coordinator = hass.data[DOMAIN][entry.entry_id] coordinator = hass.data[DOMAIN][entry.entry_id]

View File

@ -2,10 +2,9 @@
from __future__ import annotations from __future__ import annotations
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Iterable
from datetime import date, datetime, timedelta from datetime import date, datetime, timedelta
import logging import logging
from typing import Any, Callable from typing import Any
from requests.exceptions import ConnectTimeout, HTTPError from requests.exceptions import ConnectTimeout, HTTPError
from solaredge import Solaredge from solaredge import Solaredge
@ -16,7 +15,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER from homeassistant.const import CONF_API_KEY, DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -39,7 +38,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[Iterable[Entity]], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Add an solarEdge entry.""" """Add an solarEdge entry."""
# Add the needed sensors to hass # Add the needed sensors to hass

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any, Callable from typing import Any
from sonarr import Sonarr, SonarrConnectionError, SonarrError from sonarr import Sonarr, SonarrConnectionError, SonarrError
@ -11,7 +11,7 @@ from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DATA_GIGABYTES from homeassistant.const import DATA_GIGABYTES
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from . import SonarrEntity from . import SonarrEntity
@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
entry: ConfigEntry, entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Sonarr sensors based on a config entry.""" """Set up Sonarr sensors based on a config entry."""
options = entry.options options = entry.options

View File

@ -64,6 +64,7 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
) )
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.network import is_internal_request from homeassistant.helpers.network import is_internal_request
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -146,7 +147,9 @@ UNAVAILABLE_VALUES = {"", "NOT_IMPLEMENTED", None}
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Sonos from a config entry.""" """Set up Sonos from a config entry."""
platform = entity_platform.current_platform.get() platform = entity_platform.current_platform.get()

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import functools import functools
import numbers import numbers
from typing import Any, Callable from typing import Any
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY, DEVICE_CLASS_BATTERY,
@ -28,6 +28,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from .core import discovery from .core import discovery
@ -72,7 +73,9 @@ STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up the Zigbee Home Automation sensor from config entry.""" """Set up the Zigbee Home Automation sensor from config entry."""
entities_to_create = hass.data[DATA_ZHA][DOMAIN] entities_to_create = hass.data[DATA_ZHA][DOMAIN]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Callable, TypedDict from typing import TypedDict
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const import CommandClass from zwave_js_server.const import CommandClass
@ -25,6 +25,7 @@ from homeassistant.components.binary_sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -219,7 +220,9 @@ PROPERTY_SENSOR_MAPPINGS: list[PropertySensorMapping] = [
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave binary sensor from config entry.""" """Set up Z-Wave binary sensor from config entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -1,7 +1,7 @@
"""Representation of Z-Wave thermostats.""" """Representation of Z-Wave thermostats."""
from __future__ import annotations from __future__ import annotations
from typing import Any, Callable, cast from typing import Any, cast
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const import ( from zwave_js_server.const import (
@ -53,6 +53,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.temperature import convert_temperature from homeassistant.helpers.temperature import convert_temperature
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
@ -98,7 +99,9 @@ ATTR_FAN_STATE = "fan_state"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave climate from config entry.""" """Set up Z-Wave climate from config entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.model.value import Value as ZwaveValue from zwave_js_server.model.value import Value as ZwaveValue
@ -18,6 +18,7 @@ from homeassistant.components.cover import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -36,7 +37,9 @@ BARRIER_STATE_OPEN = 255
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave Cover from Config Entry.""" """Set up Z-Wave Cover from Config Entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import math import math
from typing import Any, Callable from typing import Any
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
@ -14,6 +14,7 @@ from homeassistant.components.fan import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.percentage import ( from homeassistant.util.percentage import (
int_states_in_range, int_states_in_range,
percentage_to_ranged_value, percentage_to_ranged_value,
@ -30,7 +31,9 @@ SPEED_RANGE = (1, 99) # off is not included
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave Fan from Config Entry.""" """Set up Z-Wave Fan from Config Entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const import ColorComponent, CommandClass from zwave_js_server.const import ColorComponent, CommandClass
@ -24,6 +24,7 @@ from homeassistant.components.light import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
@ -45,7 +46,9 @@ MULTI_COLOR_MAP = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave Light from Config Entry.""" """Set up Z-Wave Light from Config Entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
import voluptuous as vol import voluptuous as vol
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
@ -23,6 +23,7 @@ from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -46,7 +47,9 @@ SERVICE_CLEAR_LOCK_USERCODE = "clear_lock_usercode"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave lock from config entry.""" """Set up Z-Wave lock from config entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -1,14 +1,13 @@
"""Support for Z-Wave controls using the number platform.""" """Support for Z-Wave controls using the number platform."""
from __future__ import annotations from __future__ import annotations
from typing import Callable
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberEntity from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -16,7 +15,9 @@ from .entity import ZWaveBaseEntity
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave Number entity from Config Entry.""" """Set up Z-Wave Number entity from Config Entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Callable, cast from typing import cast
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const import CommandClass, ConfigurationValueType from zwave_js_server.const import CommandClass, ConfigurationValueType
@ -25,6 +25,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -34,7 +35,9 @@ LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave sensor from config entry.""" """Set up Z-Wave sensor from config entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any, Callable from typing import Any
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
@ -10,6 +10,7 @@ from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntit
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN from .const import DATA_CLIENT, DATA_UNSUBSCRIBE, DOMAIN
from .discovery import ZwaveDiscoveryInfo from .discovery import ZwaveDiscoveryInfo
@ -23,7 +24,9 @@ BARRIER_EVENT_SIGNALING_ON = 255
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up Z-Wave sensor from config entry.""" """Set up Z-Wave sensor from config entry."""
client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT] client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

View File

@ -10,6 +10,8 @@ from logging import Logger
from types import ModuleType from types import ModuleType
from typing import TYPE_CHECKING, Callable from typing import TYPE_CHECKING, Callable
from typing_extensions import Protocol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.const import ( from homeassistant.const import (
ATTR_RESTORED, ATTR_RESTORED,
@ -58,6 +60,15 @@ PLATFORM_NOT_READY_BASE_WAIT_TIME = 30 # seconds
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class AddEntitiesCallback(Protocol):
"""Protocol type for EntityPlatform.add_entities callback."""
def __call__(
self, new_entities: Iterable[Entity], update_before_add: bool = False
) -> None:
"""Define add_entities type."""
class EntityPlatform: class EntityPlatform:
"""Manage the entities for a single platform.""" """Manage the entities for a single platform."""