Migrate integrations t-v to extend SensorEntity (#48216)

This commit is contained in:
Erik Montnemery 2021-03-22 19:47:44 +01:00 committed by GitHub
parent c900e3030b
commit 783b453bbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 112 additions and 120 deletions

View file

@ -1,6 +1,7 @@
"""Support for Tado sensors for each zone.""" """Support for Tado sensors for each zone."""
import logging import logging
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 (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
@ -10,7 +11,6 @@ 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 import Entity
from .const import ( from .const import (
CONDITIONS_MAP, CONDITIONS_MAP,
@ -86,7 +86,7 @@ async def async_setup_entry(
async_add_entities(entities, True) async_add_entities(entities, True)
class TadoHomeSensor(TadoHomeEntity, Entity): class TadoHomeSensor(TadoHomeEntity, SensorEntity):
"""Representation of a Tado Sensor.""" """Representation of a Tado Sensor."""
def __init__(self, tado, home_variable): def __init__(self, tado, home_variable):
@ -191,7 +191,7 @@ class TadoHomeSensor(TadoHomeEntity, Entity):
} }
class TadoZoneSensor(TadoZoneEntity, Entity): class TadoZoneSensor(TadoZoneEntity, SensorEntity):
"""Representation of a tado Sensor.""" """Representation of a tado Sensor."""
def __init__(self, tado, zone_name, zone_id, zone_variable): def __init__(self, tado, zone_name, zone_id, zone_variable):

View file

@ -2,8 +2,8 @@
from datetime import timedelta from datetime import timedelta
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_BATTERY_LEVEL, LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS from homeassistant.const import ATTR_BATTERY_LEVEL, LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
@ -25,7 +25,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True) add_entities(devices, True)
class TahomaSensor(TahomaDevice, Entity): class TahomaSensor(TahomaDevice, SensorEntity):
"""Representation of a Tahoma Sensor.""" """Representation of a Tahoma Sensor."""
def __init__(self, tahoma_device, controller): def __init__(self, tahoma_device, controller):

View file

@ -7,10 +7,9 @@ import requests
from tank_utility import auth, device as tank_monitor from tank_utility import auth, device as tank_monitor
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_DEVICES, CONF_EMAIL, CONF_PASSWORD, PERCENTAGE from homeassistant.const import CONF_DEVICES, CONF_EMAIL, CONF_PASSWORD, PERCENTAGE
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -62,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(all_sensors, True) add_entities(all_sensors, True)
class TankUtilitySensor(Entity): class TankUtilitySensor(SensorEntity):
"""Representation of a Tank Utility sensor.""" """Representation of a Tank Utility sensor."""
def __init__(self, email, password, token, device): def __init__(self, email, password, token, device):

View file

@ -2,6 +2,7 @@
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -79,7 +80,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(entities) async_add_entities(entities)
class FuelPriceSensor(CoordinatorEntity): class FuelPriceSensor(CoordinatorEntity, SensorEntity):
"""Contains prices for fuel in a given station.""" """Contains prices for fuel in a given station."""
def __init__(self, fuel_type, station, coordinator, name, show_on_map): def __init__(self, fuel_type, station, coordinator, name, show_on_map):

View file

@ -4,6 +4,7 @@ from __future__ import annotations
from hatasmota import const as hc, status_sensor from hatasmota import const as hc, status_sensor
from homeassistant.components import sensor from homeassistant.components import sensor
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
@ -38,7 +39,6 @@ from homeassistant.const import (
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from .const import DATA_REMOVE_DISCOVER_COMPONENT from .const import DATA_REMOVE_DISCOVER_COMPONENT
from .discovery import TASMOTA_DISCOVERY_ENTITY_NEW from .discovery import TASMOTA_DISCOVERY_ENTITY_NEW
@ -145,7 +145,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, Entity): class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, SensorEntity):
"""Representation of a Tasmota sensor.""" """Representation of a Tasmota sensor."""
def __init__(self, **kwds): def __init__(self, **kwds):

View file

@ -4,7 +4,7 @@ from datetime import timedelta
from pytautulli import Tautulli from pytautulli import Tautulli
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_HOST, CONF_HOST,
@ -18,7 +18,6 @@ from homeassistant.const import (
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 import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
CONF_MONITORED_USERS = "monitored_users" CONF_MONITORED_USERS = "monitored_users"
@ -72,7 +71,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensor, True) async_add_entities(sensor, True)
class TautulliSensor(Entity): class TautulliSensor(SensorEntity):
"""Representation of a Tautulli sensor.""" """Representation of a Tautulli sensor."""
def __init__(self, tautulli, name, monitored_conditions, users): def __init__(self, tautulli, name, monitored_conditions, users):

View file

@ -5,7 +5,7 @@ import socket
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_NAME, CONF_NAME,
@ -17,7 +17,6 @@ from homeassistant.const import (
) )
from homeassistant.exceptions import TemplateError from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -48,7 +47,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([TcpSensor(hass, config)]) add_entities([TcpSensor(hass, config)])
class TcpSensor(Entity): class TcpSensor(SensorEntity):
"""Implementation of a TCP socket based sensor.""" """Implementation of a TCP socket based sensor."""
required = () required = ()

View file

@ -6,10 +6,9 @@ import requests
import voluptuous as vol import voluptuous as vol
import xmltodict import xmltodict
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT, VOLT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT, VOLT
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -49,7 +48,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True return True
class Ted5000Sensor(Entity): class Ted5000Sensor(SensorEntity):
"""Implementation of a Ted5000 sensor.""" """Implementation of a Ted5000 sensor."""
def __init__(self, gateway, name, mtu, unit): def __init__(self, gateway, name, mtu, unit):

View file

@ -1,5 +1,6 @@
"""Support for Tellstick Net/Telstick Live sensors.""" """Support for Tellstick Net/Telstick Live sensors."""
from homeassistant.components import sensor, tellduslive from homeassistant.components import sensor, tellduslive
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_ILLUMINANCE,
@ -71,7 +72,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
class TelldusLiveSensor(TelldusLiveEntity): class TelldusLiveSensor(TelldusLiveEntity, SensorEntity):
"""Representation of a Telldus Live sensor.""" """Representation of a Telldus Live sensor."""
@property @property

View file

@ -6,7 +6,7 @@ from tellcore import telldus
import tellcore.constants as tellcore_constants import tellcore.constants as tellcore_constants
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_ID, CONF_ID,
CONF_NAME, CONF_NAME,
@ -15,7 +15,6 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -126,7 +125,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class TellstickSensor(Entity): class TellstickSensor(SensorEntity):
"""Representation of a Tellstick sensor.""" """Representation of a Tellstick sensor."""
def __init__(self, name, tellcore_sensor, datatype, sensor_info): def __init__(self, name, tellcore_sensor, datatype, sensor_info):

View file

@ -4,14 +4,13 @@ import logging
from temperusb.temper import TemperHandler from temperusb.temper import TemperHandler
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
CONF_OFFSET, CONF_OFFSET,
DEVICE_DEFAULT_NAME, DEVICE_DEFAULT_NAME,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -58,7 +57,7 @@ def reset_devices():
sensor.set_temper_device(device) sensor.set_temper_device(device)
class TemperSensor(Entity): class TemperSensor(SensorEntity):
"""Representation of a Temper temperature sensor.""" """Representation of a Temper temperature sensor."""
def __init__(self, temper_device, temp_unit, name, scaling): def __init__(self, temper_device, temp_unit, name, scaling):

View file

@ -7,6 +7,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASSES_SCHEMA, DEVICE_CLASSES_SCHEMA,
ENTITY_ID_FORMAT, ENTITY_ID_FORMAT,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SensorEntity,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
@ -23,7 +24,7 @@ from homeassistant.const import (
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import TemplateError from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from .const import CONF_AVAILABILITY_TEMPLATE, DOMAIN, PLATFORMS from .const import CONF_AVAILABILITY_TEMPLATE, DOMAIN, PLATFORMS
@ -99,7 +100,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(await _async_create_entities(hass, config)) async_add_entities(await _async_create_entities(hass, config))
class SensorTemplate(TemplateEntity, Entity): class SensorTemplate(TemplateEntity, SensorEntity):
"""Representation of a Template Sensor.""" """Representation of a Template Sensor."""
def __init__( def __init__(

View file

@ -1,14 +1,13 @@
"""Support for the Tesla sensors.""" """Support for the Tesla sensors."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import DEVICE_CLASSES from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
LENGTH_KILOMETERS, LENGTH_KILOMETERS,
LENGTH_MILES, LENGTH_MILES,
TEMP_CELSIUS, TEMP_CELSIUS,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
from homeassistant.helpers.entity import Entity
from homeassistant.util.distance import convert from homeassistant.util.distance import convert
from . import DOMAIN as TESLA_DOMAIN, TeslaDevice from . import DOMAIN as TESLA_DOMAIN, TeslaDevice
@ -27,7 +26,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class TeslaSensor(TeslaDevice, Entity): class TeslaSensor(TeslaDevice, SensorEntity):
"""Representation of Tesla sensors.""" """Representation of Tesla sensors."""
def __init__(self, tesla_device, coordinator, sensor_type=None): def __init__(self, tesla_device, coordinator, sensor_type=None):

View file

@ -11,7 +11,7 @@ from stringcase import camelcase, snakecase
import thermoworks_smoke import thermoworks_smoke
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_BATTERY_LEVEL,
CONF_EMAIL, CONF_EMAIL,
@ -21,7 +21,6 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -91,7 +90,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.error(msg) _LOGGER.error(msg)
class ThermoworksSmokeSensor(Entity): class ThermoworksSmokeSensor(SensorEntity):
"""Implementation of a thermoworks smoke sensor.""" """Implementation of a thermoworks smoke sensor."""
def __init__(self, sensor_type, serial, mgr): def __init__(self, sensor_type, serial, mgr):

View file

@ -7,7 +7,7 @@ from aiohttp.hdrs import ACCEPT, AUTHORIZATION
import async_timeout import async_timeout
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_DEVICE_ID, ATTR_DEVICE_ID,
ATTR_TIME, ATTR_TIME,
@ -18,7 +18,6 @@ from homeassistant.const import (
) )
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 import Entity
from . import DATA_TTN, TTN_ACCESS_KEY, TTN_APP_ID, TTN_DATA_STORAGE_URL from . import DATA_TTN, TTN_ACCESS_KEY, TTN_APP_ID, TTN_DATA_STORAGE_URL
@ -59,7 +58,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(devices, True) async_add_entities(devices, True)
class TtnDataSensor(Entity): class TtnDataSensor(SensorEntity):
"""Representation of a The Things Network Data Storage sensor.""" """Representation of a The Things Network Data Storage sensor."""
def __init__(self, ttn_data_storage, device_id, value, unit_of_measurement): def __init__(self, ttn_data_storage, device_id, value, unit_of_measurement):

View file

@ -5,10 +5,9 @@ from pythinkingcleaner import Discovery, ThinkingCleaner
import voluptuous as vol import voluptuous as vol
from homeassistant import util from homeassistant import util
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_HOST, PERCENTAGE from homeassistant.const import CONF_HOST, PERCENTAGE
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
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)
@ -73,7 +72,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(dev) add_entities(dev)
class ThinkingCleanerSensor(Entity): class ThinkingCleanerSensor(SensorEntity):
"""Representation of a ThinkingCleaner Sensor.""" """Representation of a ThinkingCleaner Sensor."""
def __init__(self, tc_object, sensor_type, update_devices): def __init__(self, tc_object, sensor_type, update_devices):

View file

@ -6,10 +6,9 @@ from random import randrange
import aiohttp import aiohttp
from homeassistant.components.sensor import DEVICE_CLASS_POWER from homeassistant.components.sensor import DEVICE_CLASS_POWER, SensorEntity
from homeassistant.const import POWER_WATT from homeassistant.const import POWER_WATT
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle, dt as dt_util from homeassistant.util import Throttle, dt as dt_util
from .const import DOMAIN as TIBBER_DOMAIN, MANUFACTURER from .const import DOMAIN as TIBBER_DOMAIN, MANUFACTURER
@ -45,7 +44,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(dev, True) async_add_entities(dev, True)
class TibberSensor(Entity): class TibberSensor(SensorEntity):
"""Representation of a generic Tibber sensor.""" """Representation of a generic Tibber sensor."""
def __init__(self, tibber_home): def __init__(self, tibber_home):

View file

@ -4,11 +4,10 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA 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 callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -47,7 +46,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class TimeDateSensor(Entity): class TimeDateSensor(SensorEntity):
"""Implementation of a Time and Date sensor.""" """Implementation of a Time and Date sensor."""
def __init__(self, hass, option_type): def __init__(self, hass, option_type):

View file

@ -6,10 +6,9 @@ from requests import HTTPError
from tmb import IBus from tmb import IBus
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, TIME_MINUTES from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, TIME_MINUTES
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -63,7 +62,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class TMBSensor(Entity): class TMBSensor(SensorEntity):
"""Implementation of a TMB line/stop Sensor.""" """Implementation of a TMB line/stop Sensor."""
def __init__(self, ibus_client, stop, line, name): def __init__(self, ibus_client, stop, line, name):

View file

@ -7,10 +7,9 @@ from VL53L1X2 import VL53L1X # pylint: disable=import-error
import voluptuous as vol import voluptuous as vol
from homeassistant.components import rpi_gpio from homeassistant.components import rpi_gpio
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS from homeassistant.const import CONF_NAME, LENGTH_MILLIMETERS
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
CONF_I2C_ADDRESS = "i2c_address" CONF_I2C_ADDRESS = "i2c_address"
CONF_I2C_BUS = "i2c_bus" CONF_I2C_BUS = "i2c_bus"
@ -65,7 +64,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(dev, True) async_add_entities(dev, True)
class VL53L1XSensor(Entity): class VL53L1XSensor(SensorEntity):
"""Implementation of VL53L1X sensor.""" """Implementation of VL53L1X sensor."""
def __init__(self, vl53l1x_sensor, name, unit, i2c_address): def __init__(self, vl53l1x_sensor, name, unit, i2c_address):

View file

@ -1,6 +1,7 @@
"""Support for Toon sensors.""" """Support for Toon sensors."""
from __future__ import annotations from __future__ import annotations
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
@ -109,7 +110,7 @@ async def async_setup_entry(
async_add_entities(sensors, True) async_add_entities(sensors, True)
class ToonSensor(ToonEntity): class ToonSensor(ToonEntity, SensorEntity):
"""Defines a Toon sensor.""" """Defines a Toon sensor."""
def __init__(self, coordinator: ToonDataUpdateCoordinator, *, key: str) -> None: def __init__(self, coordinator: ToonDataUpdateCoordinator, *, key: str) -> None:

View file

@ -4,11 +4,10 @@ import re
import voluptuous as vol import voluptuous as vol
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_EMAIL, CONF_NAME, DEGREE from homeassistant.const import CONF_EMAIL, CONF_NAME, DEGREE
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
API_PATH = "/api/torque" API_PATH = "/api/torque"
@ -106,7 +105,7 @@ class TorqueReceiveDataView(HomeAssistantView):
return "OK!" return "OK!"
class TorqueSensor(Entity): class TorqueSensor(SensorEntity):
"""Representation of a Torque sensor.""" """Representation of a Torque sensor."""
def __init__(self, name, unit): def __init__(self, name, unit):

View file

@ -1,5 +1,6 @@
"""Support for IKEA Tradfri sensors.""" """Support for IKEA Tradfri sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
from .base_class import TradfriBaseDevice from .base_class import TradfriBaseDevice
@ -25,7 +26,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(TradfriSensor(sensor, api, gateway_id) for sensor in sensors) async_add_entities(TradfriSensor(sensor, api, gateway_id) for sensor in sensors)
class TradfriSensor(TradfriBaseDevice): class TradfriSensor(TradfriBaseDevice, SensorEntity):
"""The platform class required by Home Assistant.""" """The platform class required by Home Assistant."""
def __init__(self, device, api, gateway_id): def __init__(self, device, api, gateway_id):

View file

@ -6,7 +6,7 @@ import logging
from pytrafikverket import TrafikverketTrain from pytrafikverket import TrafikverketTrain
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_NAME, CONF_NAME,
@ -16,7 +16,6 @@ from homeassistant.const import (
) )
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 import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -116,7 +115,7 @@ def next_departuredate(departure):
return next_weekday(today_date, WEEKDAYS.index(departure[0])) return next_weekday(today_date, WEEKDAYS.index(departure[0]))
class TrainSensor(Entity): class TrainSensor(SensorEntity):
"""Contains data about a train depature.""" """Contains data about a train depature."""
def __init__(self, train_api, name, from_station, to_station, weekday, time): def __init__(self, train_api, name, from_station, to_station, weekday, time):

View file

@ -8,7 +8,7 @@ import aiohttp
from pytrafikverket.trafikverket_weather import TrafikverketWeather from pytrafikverket.trafikverket_weather import TrafikverketWeather
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONF_API_KEY, CONF_API_KEY,
@ -24,7 +24,6 @@ from homeassistant.const import (
) )
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 import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -145,7 +144,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(dev, True) async_add_entities(dev, True)
class TrafikverketWeatherStation(Entity): class TrafikverketWeatherStation(SensorEntity):
"""Representation of a Trafikverket sensor.""" """Representation of a Trafikverket sensor."""
def __init__(self, weather_api, name, sensor_type, sensor_station): def __init__(self, weather_api, name, sensor_type, sensor_station):

View file

@ -3,10 +3,10 @@ from __future__ import annotations
from transmissionrpc.torrent import Torrent from transmissionrpc.torrent import Torrent
from homeassistant.components.sensor import SensorEntity
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 callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from . import TransmissionClient from . import TransmissionClient
from .const import ( from .const import (
@ -38,7 +38,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(dev, True) async_add_entities(dev, True)
class TransmissionSensor(Entity): class TransmissionSensor(SensorEntity):
"""A base class for all Transmission sensors.""" """A base class for all Transmission sensors."""
def __init__(self, tm_client, client_name, sensor_name, sub_type=None): def __init__(self, tm_client, client_name, sensor_name, sub_type=None):

View file

@ -4,7 +4,7 @@ from datetime import timedelta
from TransportNSW import TransportNSW from TransportNSW import TransportNSW
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_MODE, ATTR_MODE,
@ -13,7 +13,6 @@ from homeassistant.const import (
TIME_MINUTES, TIME_MINUTES,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
ATTR_STOP_ID = "stop_id" ATTR_STOP_ID = "stop_id"
ATTR_ROUTE = "route" ATTR_ROUTE = "route"
@ -65,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([TransportNSWSensor(data, stop_id, name)], True) add_entities([TransportNSWSensor(data, stop_id, name)], True)
class TransportNSWSensor(Entity): class TransportNSWSensor(SensorEntity):
"""Implementation of an Transport NSW sensor.""" """Implementation of an Transport NSW sensor."""
def __init__(self, data, stop_id, name): def __init__(self, data, stop_id, name):

View file

@ -6,7 +6,7 @@ from travispy import TravisPy
from travispy.errors import TravisError from travispy.errors import TravisError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONF_API_KEY, CONF_API_KEY,
@ -15,7 +15,6 @@ from homeassistant.const import (
TIME_SECONDS, TIME_SECONDS,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -94,7 +93,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True return True
class TravisCISensor(Entity): class TravisCISensor(SensorEntity):
"""Representation of a Travis CI sensor.""" """Representation of a Travis CI sensor."""
def __init__(self, data, repo_name, user, branch, sensor_type): def __init__(self, data, repo_name, user, branch, sensor_type):

View file

@ -12,6 +12,7 @@ from twentemilieu import (
TwenteMilieuConnectionError, TwenteMilieuConnectionError,
) )
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ID from homeassistant.const import CONF_ID
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -71,7 +72,7 @@ async def async_setup_entry(
async_add_entities(sensors, True) async_add_entities(sensors, True)
class TwenteMilieuSensor(Entity): class TwenteMilieuSensor(SensorEntity):
"""Defines a Twente Milieu sensor.""" """Defines a Twente Milieu sensor."""
def __init__( def __init__(

View file

@ -5,10 +5,9 @@ from requests.exceptions import HTTPError
from twitch import TwitchClient from twitch import TwitchClient
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA 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
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -56,7 +55,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([TwitchSensor(channel_id, client) for channel_id in channel_ids], True) add_entities([TwitchSensor(channel_id, client) for channel_id in channel_ids], True)
class TwitchSensor(Entity): class TwitchSensor(SensorEntity):
"""Representation of an Twitch channel.""" """Representation of an Twitch channel."""
def __init__(self, channel, client): def __init__(self, channel, client):

View file

@ -6,10 +6,9 @@ import re
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_MODE, HTTP_OK, TIME_MINUTES from homeassistant.const import CONF_MODE, HTTP_OK, TIME_MINUTES
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -83,7 +82,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class UkTransportSensor(Entity): class UkTransportSensor(SensorEntity):
""" """
Sensor that reads the UK transport web API. Sensor that reads the UK transport web API.

View file

@ -6,7 +6,7 @@ Support for uptime sensors of network clients.
from datetime import datetime, timedelta from datetime import datetime, timedelta
from homeassistant.components.sensor import DEVICE_CLASS_TIMESTAMP, DOMAIN from homeassistant.components.sensor import DEVICE_CLASS_TIMESTAMP, DOMAIN, SensorEntity
from homeassistant.const import DATA_MEGABYTES from homeassistant.const import DATA_MEGABYTES
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -79,7 +79,7 @@ def add_uptime_entities(controller, async_add_entities, clients):
async_add_entities(sensors) async_add_entities(sensors)
class UniFiBandwidthSensor(UniFiClient): class UniFiBandwidthSensor(UniFiClient, SensorEntity):
"""UniFi bandwidth sensor base class.""" """UniFi bandwidth sensor base class."""
DOMAIN = DOMAIN DOMAIN = DOMAIN
@ -126,7 +126,7 @@ class UniFiTxBandwidthSensor(UniFiBandwidthSensor):
return self.client.tx_bytes / 1000000 return self.client.tx_bytes / 1000000
class UniFiUpTimeSensor(UniFiClient): class UniFiUpTimeSensor(UniFiClient, SensorEntity):
"""UniFi uptime sensor.""" """UniFi uptime sensor."""
DOMAIN = DOMAIN DOMAIN = DOMAIN

View file

@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from typing import Any, Mapping from typing import Any, Mapping
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DATA_BYTES, DATA_RATE_KIBIBYTES_PER_SECOND from homeassistant.const import DATA_BYTES, DATA_RATE_KIBIBYTES_PER_SECOND
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
@ -117,7 +118,7 @@ async def async_setup_entry(
async_add_entities(sensors, True) async_add_entities(sensors, True)
class UpnpSensor(CoordinatorEntity): class UpnpSensor(CoordinatorEntity, SensorEntity):
"""Base class for UPnP/IGD sensors.""" """Base class for UPnP/IGD sensors."""
def __init__( def __init__(

View file

@ -2,10 +2,13 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import DEVICE_CLASS_TIMESTAMP, PLATFORM_SCHEMA from homeassistant.components.sensor import (
DEVICE_CLASS_TIMESTAMP,
PLATFORM_SCHEMA,
SensorEntity,
)
from homeassistant.const import CONF_NAME, CONF_UNIT_OF_MEASUREMENT from homeassistant.const import CONF_NAME, CONF_UNIT_OF_MEASUREMENT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
DEFAULT_NAME = "Uptime" DEFAULT_NAME = "Uptime"
@ -30,7 +33,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([UptimeSensor(name)], True) async_add_entities([UptimeSensor(name)], True)
class UptimeSensor(Entity): class UptimeSensor(SensorEntity):
"""Representation of an uptime sensor.""" """Representation of an uptime sensor."""
def __init__(self, name): def __init__(self, name):

View file

@ -5,10 +5,9 @@ import logging
import uscisstatus import uscisstatus
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -33,7 +32,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.error("Setup USCIS Sensor Fail check if your Case ID is Valid") _LOGGER.error("Setup USCIS Sensor Fail check if your Case ID is Valid")
class UscisSensor(Entity): class UscisSensor(SensorEntity):
"""USCIS Sensor will check case status on daily basis.""" """USCIS Sensor will check case status on daily basis."""
MIN_TIME_BETWEEN_UPDATES = timedelta(hours=24) MIN_TIME_BETWEEN_UPDATES = timedelta(hours=24)

View file

@ -5,6 +5,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
CONF_NAME, CONF_NAME,
@ -102,7 +103,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class UtilityMeterSensor(RestoreEntity): class UtilityMeterSensor(RestoreEntity, SensorEntity):
"""Representation of an utility meter sensor.""" """Representation of an utility meter sensor."""
def __init__( def __init__(

View file

@ -3,6 +3,7 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
@ -12,7 +13,6 @@ from homeassistant.const import (
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from . import DOMAIN, METRIC_KEY_MODE, SIGNAL_VALLOX_STATE_UPDATE from . import DOMAIN, METRIC_KEY_MODE, SIGNAL_VALLOX_STATE_UPDATE
@ -96,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensors, update_before_add=False) async_add_entities(sensors, update_before_add=False)
class ValloxSensor(Entity): class ValloxSensor(SensorEntity):
"""Representation of a Vallox sensor.""" """Representation of a Vallox sensor."""
def __init__( def __init__(

View file

@ -5,10 +5,9 @@ import logging
import vasttrafik import vasttrafik
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_DELAY, CONF_NAME from homeassistant.const import ATTR_ATTRIBUTION, CONF_DELAY, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
from homeassistant.util.dt import now from homeassistant.util.dt import now
@ -71,7 +70,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class VasttrafikDepartureSensor(Entity): class VasttrafikDepartureSensor(SensorEntity):
"""Implementation of a Vasttrafik Departure Sensor.""" """Implementation of a Vasttrafik Departure Sensor."""
def __init__(self, planner, name, departure, heading, lines, delay): def __init__(self, planner, name, departure, heading, lines, delay):

View file

@ -1,4 +1,5 @@
"""Support for Velbus sensors.""" """Support for Velbus sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR from homeassistant.const import DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR
from . import VelbusEntity from . import VelbusEntity
@ -18,7 +19,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class VelbusSensor(VelbusEntity): class VelbusSensor(VelbusEntity, SensorEntity):
"""Representation of a sensor.""" """Representation of a sensor."""
def __init__(self, module, channel, counter=False): def __init__(self, module, channel, counter=False):

View file

@ -6,7 +6,11 @@ from typing import Callable, cast
import pyvera as veraApi import pyvera as veraApi
from homeassistant.components.sensor import DOMAIN as PLATFORM_DOMAIN, ENTITY_ID_FORMAT from homeassistant.components.sensor import (
DOMAIN as PLATFORM_DOMAIN,
ENTITY_ID_FORMAT,
SensorEntity,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -35,7 +39,7 @@ async def async_setup_entry(
) )
class VeraSensor(VeraDevice[veraApi.VeraSensor], Entity): class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity):
"""Representation of a Vera Sensor.""" """Representation of a Vera Sensor."""
def __init__( def __init__(

View file

@ -6,6 +6,7 @@ from typing import Any, Callable, Iterable
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
SensorEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
@ -45,7 +46,7 @@ async def async_setup_entry(
async_add_entities(sensors) async_add_entities(sensors)
class VerisureThermometer(CoordinatorEntity, Entity): class VerisureThermometer(CoordinatorEntity, SensorEntity):
"""Representation of a Verisure thermometer.""" """Representation of a Verisure thermometer."""
coordinator: VerisureDataUpdateCoordinator coordinator: VerisureDataUpdateCoordinator
@ -109,7 +110,7 @@ class VerisureThermometer(CoordinatorEntity, Entity):
return TEMP_CELSIUS return TEMP_CELSIUS
class VerisureHygrometer(CoordinatorEntity, Entity): class VerisureHygrometer(CoordinatorEntity, SensorEntity):
"""Representation of a Verisure hygrometer.""" """Representation of a Verisure hygrometer."""
coordinator: VerisureDataUpdateCoordinator coordinator: VerisureDataUpdateCoordinator
@ -173,7 +174,7 @@ class VerisureHygrometer(CoordinatorEntity, Entity):
return PERCENTAGE return PERCENTAGE
class VerisureMouseDetection(CoordinatorEntity, Entity): class VerisureMouseDetection(CoordinatorEntity, SensorEntity):
"""Representation of a Verisure mouse detector.""" """Representation of a Verisure mouse detector."""
coordinator: VerisureDataUpdateCoordinator coordinator: VerisureDataUpdateCoordinator

View file

@ -1,7 +1,7 @@
"""Support for VersaSense sensor peripheral.""" """Support for VersaSense sensor peripheral."""
import logging import logging
from homeassistant.helpers.entity import Entity from homeassistant.components.sensor import SensorEntity
from . import DOMAIN from . import DOMAIN
from .const import ( from .const import (
@ -40,7 +40,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensor_list) async_add_entities(sensor_list)
class VSensor(Entity): class VSensor(SensorEntity):
"""Representation of a Sensor.""" """Representation of a Sensor."""
def __init__(self, peripheral, parent_name, unit, measurement, consumer): def __init__(self, peripheral, parent_name, unit, measurement, consumer):

View file

@ -10,11 +10,10 @@ from pyhaversion import (
) )
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_NAME, CONF_SOURCE from homeassistant.const import CONF_NAME, CONF_SOURCE
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 import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
ALL_IMAGES = [ ALL_IMAGES = [
@ -94,7 +93,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([VersionSensor(haversion, name)], True) async_add_entities([VersionSensor(haversion, name)], True)
class VersionSensor(Entity): class VersionSensor(SensorEntity):
"""Representation of a Home Assistant version sensor.""" """Representation of a Home Assistant version sensor."""
def __init__(self, haversion, name): def __init__(self, haversion, name):

View file

@ -6,10 +6,9 @@ import aiohttp
import async_timeout import async_timeout
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, HTTP_OK, TIME_MINUTES from homeassistant.const import ATTR_ATTRIBUTION, HTTP_OK, TIME_MINUTES
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -82,7 +81,7 @@ async def async_http_request(hass, uri):
_LOGGER.error("Received non-JSON data from ViaggiaTreno API endpoint") _LOGGER.error("Received non-JSON data from ViaggiaTreno API endpoint")
class ViaggiaTrenoSensor(Entity): class ViaggiaTrenoSensor(SensorEntity):
"""Implementation of a ViaggiaTreno sensor.""" """Implementation of a ViaggiaTreno sensor."""
def __init__(self, train_id, station_id, name): def __init__(self, train_id, station_id, name):

View file

@ -3,6 +3,7 @@ import logging
import requests import requests
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ICON, CONF_ICON,
@ -14,7 +15,6 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_HOURS, TIME_HOURS,
) )
from homeassistant.helpers.entity import Entity
from . import ( from . import (
DOMAIN as VICARE_DOMAIN, DOMAIN as VICARE_DOMAIN,
@ -269,7 +269,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class ViCareSensor(Entity): class ViCareSensor(SensorEntity):
"""Representation of a ViCare sensor.""" """Representation of a ViCare sensor."""
def __init__(self, name, api, sensor_type): def __init__(self, name, api, sensor_type):

View file

@ -1,6 +1,6 @@
"""Support for Vilfo Router sensors.""" """Support for Vilfo Router sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ICON from homeassistant.const import ATTR_ICON
from homeassistant.helpers.entity import Entity
from .const import ( from .const import (
ATTR_API_DATA_FIELD, ATTR_API_DATA_FIELD,
@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(sensors, True) async_add_entities(sensors, True)
class VilfoRouterSensor(Entity): class VilfoRouterSensor(SensorEntity):
"""Define a Vilfo Router Sensor.""" """Define a Vilfo Router Sensor."""
def __init__(self, sensor_type, api): def __init__(self, sensor_type, api):

View file

@ -6,7 +6,7 @@ from volkszaehler import Volkszaehler
from volkszaehler.exceptions import VolkszaehlerApiConnectionError from volkszaehler.exceptions import VolkszaehlerApiConnectionError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_MONITORED_CONDITIONS, CONF_MONITORED_CONDITIONS,
@ -18,7 +18,6 @@ from homeassistant.const import (
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 import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -77,7 +76,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(dev, True) async_add_entities(dev, True)
class VolkszaehlerSensor(Entity): class VolkszaehlerSensor(SensorEntity):
"""Implementation of a Volkszaehler sensor.""" """Implementation of a Volkszaehler sensor."""
def __init__(self, vz_api, name, sensor_type): def __init__(self, vz_api, name, sensor_type):

View file

@ -1,4 +1,6 @@
"""Support for Volvo On Call sensors.""" """Support for Volvo On Call sensors."""
from homeassistant.components.sensor import SensorEntity
from . import DATA_KEY, VolvoEntity from . import DATA_KEY, VolvoEntity
@ -9,7 +11,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([VolvoSensor(hass.data[DATA_KEY], *discovery_info)]) async_add_entities([VolvoSensor(hass.data[DATA_KEY], *discovery_info)])
class VolvoSensor(VolvoEntity): class VolvoSensor(VolvoEntity, SensorEntity):
"""Representation of a Volvo sensor.""" """Representation of a Volvo sensor."""
@property @property

View file

@ -3,10 +3,9 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, DATA_GIGABYTES from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, DATA_GIGABYTES
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from . import ( from . import (
ATTR_CURRENT_BANDWIDTH_USED, ATTR_CURRENT_BANDWIDTH_USED,
@ -58,7 +57,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class VultrSensor(Entity): class VultrSensor(SensorEntity):
"""Representation of a Vultr subscription sensor.""" """Representation of a Vultr subscription sensor."""
def __init__(self, vultr, subscription, condition, name): def __init__(self, vultr, subscription, condition, name):