Add sensor setup type hints [t-v] (#63309)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
d24ebc3c10
commit
6f93ffb7ee
20 changed files with 195 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
||||||
"""Tankerkoenig sensor integration."""
|
"""Tankerkoenig sensor integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -9,6 +10,9 @@ from homeassistant.const import (
|
||||||
ATTR_LONGITUDE,
|
ATTR_LONGITUDE,
|
||||||
CURRENCY_EURO,
|
CURRENCY_EURO,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -32,7 +36,12 @@ ATTRIBUTION = "Data provided by https://creativecommons.tankerkoenig.de"
|
||||||
ICON = "mdi:gas-station"
|
ICON = "mdi:gas-station"
|
||||||
|
|
||||||
|
|
||||||
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 tankerkoenig sensors."""
|
"""Set up the tankerkoenig sensors."""
|
||||||
|
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
LENGTH_MILLIMETERS,
|
LENGTH_MILLIMETERS,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
|
@ -17,7 +18,9 @@ from homeassistant.const import (
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
UV_INDEX,
|
UV_INDEX,
|
||||||
)
|
)
|
||||||
|
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
|
||||||
|
|
||||||
from .entry import TelldusLiveEntity
|
from .entry import TelldusLiveEntity
|
||||||
|
|
||||||
|
@ -103,7 +106,11 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 tellduslive sensors dynamically."""
|
"""Set up tellduslive sensors dynamically."""
|
||||||
|
|
||||||
async def async_discover_sensor(device_id):
|
async def async_discover_sensor(device_id):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Tellstick sensors."""
|
"""Support for Tellstick sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -18,7 +20,10 @@ from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
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__)
|
||||||
|
|
||||||
|
@ -59,7 +64,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Tellstick sensors."""
|
"""Set up the Tellstick sensors."""
|
||||||
|
|
||||||
sensor_value_descriptions = {
|
sensor_value_descriptions = {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for getting temperature from TEMPer devices."""
|
"""Support for getting temperature from TEMPer devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from temperusb.temper import TemperHandler
|
from temperusb.temper import TemperHandler
|
||||||
|
@ -15,6 +17,9 @@ from homeassistant.const import (
|
||||||
DEVICE_DEFAULT_NAME,
|
DEVICE_DEFAULT_NAME,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -36,7 +41,12 @@ def get_temper_devices():
|
||||||
return TemperHandler().get_devices()
|
return TemperHandler().get_devices()
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Temper sensors."""
|
"""Set up the Temper sensors."""
|
||||||
prefix = name = config[CONF_NAME]
|
prefix = name = config[CONF_NAME]
|
||||||
scaling = {"scale": config.get(CONF_SCALE), "offset": config.get(CONF_OFFSET)}
|
scaling = {"scale": config.get(CONF_SCALE), "offset": config.get(CONF_OFFSET)}
|
||||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
@ -15,7 +16,9 @@ from homeassistant.const import (
|
||||||
FREQUENCY_HERTZ,
|
FREQUENCY_HERTZ,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
WallConnectorData,
|
WallConnectorData,
|
||||||
|
@ -127,7 +130,11 @@ WALL_CONNECTOR_SENSORS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_devices: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Create the Wall Connector sensor devices."""
|
"""Create the Wall Connector sensor devices."""
|
||||||
wall_connector_data = hass.data[DOMAIN][config_entry.entry_id]
|
wall_connector_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ Support for getting the state of a Thermoworks Smoke Thermometer.
|
||||||
|
|
||||||
Requires Smoke Gateway Wifi with an internet connection.
|
Requires Smoke Gateway Wifi with an internet connection.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
|
@ -24,7 +26,10 @@ from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
|
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__)
|
||||||
|
|
||||||
|
@ -66,7 +71,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the thermoworks sensor."""
|
"""Set up the thermoworks sensor."""
|
||||||
|
|
||||||
email = config[CONF_EMAIL]
|
email = config[CONF_EMAIL]
|
||||||
|
|
|
@ -13,7 +13,10 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, PERCENTAGE
|
from homeassistant.const import CONF_HOST, PERCENTAGE
|
||||||
|
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
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
||||||
|
@ -65,7 +68,12 @@ STATES = {
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the ThinkingCleaner platform."""
|
"""Set up the ThinkingCleaner platform."""
|
||||||
if host := config.get(CONF_HOST):
|
if host := config.get(CONF_HOST):
|
||||||
devices = [ThinkingCleaner(host, "unknown")]
|
devices = [ThinkingCleaner(host, "unknown")]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for showing the date and the time."""
|
"""Support for showing the date and the time."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -6,9 +8,11 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_DISPLAY_OPTIONS
|
from homeassistant.const import CONF_DISPLAY_OPTIONS
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -35,7 +39,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 Time and Date sensor."""
|
"""Set up the Time and Date sensor."""
|
||||||
if hass.config.time_zone is None:
|
if hass.config.time_zone is None:
|
||||||
_LOGGER.error("Timezone is not set in Home Assistant configuration")
|
_LOGGER.error("Timezone is not set in Home Assistant configuration")
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Platform for Time of Flight sensor VL53L1X from STMicroelectronics."""
|
"""Platform for Time of Flight sensor VL53L1X from STMicroelectronics."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
|
@ -9,7 +11,10 @@ import voluptuous as vol
|
||||||
from homeassistant.components import rpi_gpio
|
from homeassistant.components import rpi_gpio
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS
|
from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
CONF_I2C_ADDRESS = "i2c_address"
|
CONF_I2C_ADDRESS = "i2c_address"
|
||||||
CONF_I2C_BUS = "i2c_bus"
|
CONF_I2C_BUS = "i2c_bus"
|
||||||
|
@ -46,7 +51,12 @@ def init_tof_1(xshut):
|
||||||
rpi_gpio.write_output(xshut, 1)
|
rpi_gpio.write_output(xshut, 1)
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics."""
|
"""Reset and initialize the VL53L1X ToF Sensor from STMicroelectronics."""
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"The Time of Flight integration is deprecated and will be removed "
|
"The Time of Flight integration is deprecated and will be removed "
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Train information for departures and delays, provided by Trafikverket."""
|
"""Train information for departures and delays, provided by Trafikverket."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
@ -12,8 +13,11 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_WEEKDAY, WEEKDAYS
|
||||||
|
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.dt import as_utc, get_time_zone
|
from homeassistant.util.dt import as_utc, get_time_zone
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -53,7 +57,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 departure sensor."""
|
"""Set up the departure sensor."""
|
||||||
httpsession = async_get_clientsession(hass)
|
httpsession = async_get_clientsession(hass)
|
||||||
train_api = TrafikverketTrain(httpsession, config[CONF_API_KEY])
|
train_api = TrafikverketTrain(httpsession, config[CONF_API_KEY])
|
||||||
|
|
|
@ -6,9 +6,11 @@ from contextlib import suppress
|
||||||
from transmissionrpc.torrent import Torrent
|
from transmissionrpc.torrent import Torrent
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME, DATA_RATE_MEGABYTES_PER_SECOND, STATE_IDLE
|
from homeassistant.const import CONF_NAME, DATA_RATE_MEGABYTES_PER_SECOND, STATE_IDLE
|
||||||
from homeassistant.core import 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 . import TransmissionClient
|
from . import TransmissionClient
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -20,7 +22,11 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 Transmission sensors."""
|
"""Set up the Transmission sensors."""
|
||||||
|
|
||||||
tm_client = hass.data[DOMAIN][config_entry.entry_id]
|
tm_client = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Transport NSW (AU) to query next leave event."""
|
"""Support for Transport NSW (AU) to query next leave event."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from TransportNSW import TransportNSW
|
from TransportNSW import TransportNSW
|
||||||
|
@ -12,7 +14,10 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
TIME_MINUTES,
|
TIME_MINUTES,
|
||||||
)
|
)
|
||||||
|
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
|
||||||
|
|
||||||
ATTR_STOP_ID = "stop_id"
|
ATTR_STOP_ID = "stop_id"
|
||||||
ATTR_ROUTE = "route"
|
ATTR_ROUTE = "route"
|
||||||
|
@ -52,7 +57,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Transport NSW sensor."""
|
"""Set up the Transport NSW sensor."""
|
||||||
stop_id = config[CONF_STOP_ID]
|
stop_id = config[CONF_STOP_ID]
|
||||||
api_key = config[CONF_API_KEY]
|
api_key = config[CONF_API_KEY]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for the Twitch stream status."""
|
"""Support for the Twitch stream status."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
@ -7,7 +9,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_TOKEN
|
from homeassistant.const import CONF_CLIENT_ID, CONF_TOKEN
|
||||||
|
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__)
|
||||||
|
|
||||||
|
@ -37,7 +42,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Twitch platform."""
|
"""Set up the Twitch platform."""
|
||||||
channels = config[CONF_CHANNELS]
|
channels = config[CONF_CHANNELS]
|
||||||
client_id = config[CONF_CLIENT_ID]
|
client_id = config[CONF_CLIENT_ID]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for USCIS Case Status."""
|
"""Support for USCIS Case Status."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -7,7 +9,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
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.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -22,7 +27,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the platform in Home Assistant and Case Information."""
|
"""Set up the platform in Home Assistant and Case Information."""
|
||||||
uscis = UscisSensor(config["case_id"], config[CONF_NAME])
|
uscis = UscisSensor(config["case_id"], config[CONF_NAME])
|
||||||
uscis.update()
|
uscis.update()
|
||||||
|
|
|
@ -13,7 +13,9 @@ from homeassistant.components.sensor import (
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT, TIME_MINUTES
|
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT, TIME_MINUTES
|
||||||
|
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 VenstarDataUpdateCoordinator, VenstarEntity
|
from . import VenstarDataUpdateCoordinator, VenstarEntity
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -64,7 +66,11 @@ class VenstarSensorEntityDescription(SensorEntityDescription, VenstarSensorTypeM
|
||||||
"""Base description of a Sensor entity."""
|
"""Base description of a Sensor entity."""
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities) -> None:
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up Vensar device binary_sensors based on a config entry."""
|
"""Set up Vensar device binary_sensors based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
entities: list[Entity] = []
|
entities: list[Entity] = []
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for the Italian train system using ViaggiaTreno API."""
|
"""Support for the Italian train system using ViaggiaTreno API."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
@ -10,7 +12,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, TIME_MINUTES
|
from homeassistant.const import ATTR_ATTRIBUTION, TIME_MINUTES
|
||||||
|
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__)
|
||||||
|
|
||||||
|
@ -57,7 +62,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 ViaggiaTreno platform."""
|
"""Set up the ViaggiaTreno platform."""
|
||||||
train_id = config.get(CONF_TRAIN_ID)
|
train_id = config.get(CONF_TRAIN_ID)
|
||||||
station_id = config.get(CONF_STATION_ID)
|
station_id = config.get(CONF_STATION_ID)
|
||||||
|
|
|
@ -20,6 +20,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
@ -28,6 +29,8 @@ from homeassistant.const import (
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TIME_HOURS,
|
TIME_HOURS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import ViCareRequiredKeysMixin
|
from . import ViCareRequiredKeysMixin
|
||||||
|
@ -355,7 +358,11 @@ async def _entities_from_descriptions(
|
||||||
all_devices.append(entity)
|
all_devices.append(entity)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_devices: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Create the ViCare sensor devices."""
|
"""Create the ViCare sensor devices."""
|
||||||
name = config_entry.data[CONF_NAME]
|
name = config_entry.data[CONF_NAME]
|
||||||
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
"""Support for Vilfo Router sensors."""
|
"""Support for Vilfo Router sensors."""
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -11,7 +14,11 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Add Vilfo Router entities from a config_entry."""
|
"""Add Vilfo Router entities from a config_entry."""
|
||||||
vilfo = hass.data[DOMAIN][config_entry.entry_id]
|
vilfo = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,12 @@ from homeassistant.const import (
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
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
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -78,7 +81,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 Volkszaehler sensors."""
|
"""Set up the Volkszaehler sensors."""
|
||||||
|
|
||||||
host = config[CONF_HOST]
|
host = config[CONF_HOST]
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
"""Support for Volvo On Call sensors."""
|
"""Support for Volvo On Call sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import DATA_KEY, VolvoEntity
|
from . import DATA_KEY, VolvoEntity
|
||||||
|
|
||||||
|
|
||||||
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 Volvo sensors."""
|
"""Set up the Volvo sensors."""
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue