Skip to content

Commit

Permalink
Use AddEntitiesCallback type, pt.2 (home-assistant#49921)
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI authored Apr 30, 2021
1 parent 4ed74cd commit cbaeec2
Show file tree
Hide file tree
Showing 37 changed files with 91 additions and 103 deletions.
5 changes: 2 additions & 3 deletions homeassistant/components/adguard/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

from datetime import timedelta
from typing import Callable

from adguardhome import AdGuardHome, AdGuardHomeConnectionError

Expand All @@ -11,7 +10,7 @@
from homeassistant.const import PERCENTAGE, TIME_MILLISECONDS
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import AdGuardHomeDeviceEntity
from .const import DATA_ADGUARD_CLIENT, DATA_ADGUARD_VERSION, DOMAIN
Expand All @@ -23,7 +22,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up AdGuard Home sensor based on a config entry."""
adguard = hass.data[DOMAIN][entry.entry_id][DATA_ADGUARD_CLIENT]
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/adguard/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

from datetime import timedelta
import logging
from typing import Callable

from adguardhome import AdGuardHome, AdGuardHomeConnectionError, AdGuardHomeError

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import AdGuardHomeDeviceEntity
from .const import DATA_ADGUARD_CLIENT, DATA_ADGUARD_VERSION, DOMAIN
Expand All @@ -25,7 +24,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up AdGuard Home switch based on a config entry."""
adguard = hass.data[DOMAIN][entry.entry_id][DATA_ADGUARD_CLIENT]
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/awair/sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Support for Awair sensors."""
from __future__ import annotations

from typing import Callable

from python_awair.devices import AwairDevice
import voluptuous as vol

Expand All @@ -13,7 +11,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import CoordinatorEntity

Expand Down Expand Up @@ -57,7 +55,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigType,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
):
"""Set up Awair sensor entity based on a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/bond/cover.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Support for Bond covers."""
from __future__ import annotations

from typing import Any, Callable
from typing import Any

from bond_api import Action, BPUPSubscriptions, DeviceType

from homeassistant.components.cover import DEVICE_CLASS_SHADE, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import BPUP_SUBS, DOMAIN, HUB
from .entity import BondEntity
Expand All @@ -18,7 +19,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Bond cover devices."""
data = hass.data[DOMAIN][entry.entry_id]
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/bond/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import logging
import math
from typing import Any, Callable
from typing import Any

from bond_api import Action, BPUPSubscriptions, DeviceType, Direction

Expand All @@ -17,6 +17,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.percentage import (
int_states_in_range,
percentage_to_ranged_value,
Expand All @@ -33,7 +34,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Bond fan devices."""
data = hass.data[DOMAIN][entry.entry_id]
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/bond/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import logging
from typing import Any, Callable
from typing import Any

from bond_api import Action, BPUPSubscriptions, DeviceType

Expand All @@ -14,6 +14,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import BondHub
from .const import BPUP_SUBS, DOMAIN, HUB
Expand All @@ -26,7 +27,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Bond light devices."""
data = hass.data[DOMAIN][entry.entry_id]
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/bond/switch.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Support for Bond generic devices."""
from __future__ import annotations

from typing import Any, Callable
from typing import Any

from bond_api import Action, BPUPSubscriptions, DeviceType

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import BPUP_SUBS, DOMAIN, HUB
from .entity import BondEntity
Expand All @@ -18,7 +19,7 @@
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Bond generic devices."""
data = hass.data[DOMAIN][entry.entry_id]
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/climacell/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from abc import abstractmethod
from collections.abc import Mapping
import logging
from typing import Any, Callable
from typing import Any

from pyclimacell.const import CURRENT

Expand All @@ -20,7 +20,7 @@
CONF_UNIT_SYSTEM_METRIC,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import slugify

from . import ClimaCellDataUpdateCoordinator, ClimaCellEntity
Expand All @@ -40,7 +40,7 @@
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/climacell/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Mapping
from datetime import datetime
import logging
from typing import Any, Callable
from typing import Any

from pyclimacell.const import (
CURRENT,
Expand Down Expand Up @@ -41,7 +41,7 @@
TEMP_FAHRENHEIT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.sun import is_up
from homeassistant.util import dt as dt_util
from homeassistant.util.distance import convert as distance_convert
Expand Down Expand Up @@ -100,7 +100,7 @@
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up a config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/fritzbox/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for Fritzbox binary sensors."""
from typing import Callable

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_WINDOW,
BinarySensorEntity,
Expand All @@ -13,13 +11,14 @@
ATTR_UNIT_OF_MEASUREMENT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import FritzBoxEntity
from .const import CONF_COORDINATOR, DOMAIN as FRITZBOX_DOMAIN


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Fritzbox binary sensor from ConfigEntry."""
entities = []
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/fritzbox/sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for AVM Fritz!Box smarthome temperature sensor only devices."""
from typing import Callable

from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand All @@ -13,6 +11,7 @@
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import FritzBoxEntity
from .const import (
Expand All @@ -24,7 +23,7 @@


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Fritzbox smarthome sensor from ConfigEntry."""
entities = []
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/fritzbox/switch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for AVM Fritz!Box smarthome switch devices."""
from typing import Callable

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand All @@ -13,6 +11,7 @@
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import FritzBoxEntity
from .const import (
Expand All @@ -29,7 +28,7 @@


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Fritzbox smarthome switch from ConfigEntry."""
entities = []
Expand Down
10 changes: 6 additions & 4 deletions homeassistant/components/gogogate2/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

import logging
from typing import Callable

from gogogate2_api.common import AbstractDoor, DoorStatus, get_configured_doors

Expand All @@ -15,7 +14,7 @@
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .common import (
DeviceDataUpdateCoordinator,
Expand All @@ -29,7 +28,10 @@


async def async_setup_platform(
hass: HomeAssistant, config: dict, add_entities: Callable, discovery_info=None
hass: HomeAssistant,
config: dict,
add_entities: AddEntitiesCallback,
discovery_info=None,
) -> None:
"""Convert old style file configs to new style configs."""
_LOGGER.warning(
Expand All @@ -46,7 +48,7 @@ async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool | None], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the config entry."""
data_update_coordinator = get_data_update_coordinator(hass, config_entry)
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/gogogate2/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

from itertools import chain
from typing import Callable

from gogogate2_api.common import AbstractDoor, get_configured_doors

Expand All @@ -14,7 +13,7 @@
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .common import (
DeviceDataUpdateCoordinator,
Expand All @@ -29,7 +28,7 @@
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool | None], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the config entry."""
data_update_coordinator = get_data_update_coordinator(hass, config_entry)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/google_travel_time/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from datetime import datetime, timedelta
import logging
from typing import Callable

from googlemaps import Client
from googlemaps.distance_matrix import distance_matrix
Expand All @@ -23,6 +22,7 @@
)
from homeassistant.core import CoreState, HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
import homeassistant.util.dt as dt_util

from .const import (
Expand Down Expand Up @@ -102,7 +102,7 @@ def convert_time_to_utc(timestr):
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: Callable[[list[SensorEntity], bool], None],
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up a Google travel time sensor entry."""
if not config_entry.options:
Expand Down
Loading

0 comments on commit cbaeec2

Please sign in to comment.