From 23b562386f798c23bd45b343f44fdb8226aba468 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 12:52:29 +0100 Subject: [PATCH] Migrate integrations d-e to extend SensorEntity (#48211) --- homeassistant/components/daikin/sensor.py | 4 ++-- homeassistant/components/danfoss_air/sensor.py | 4 ++-- homeassistant/components/darksky/sensor.py | 11 +++++++---- homeassistant/components/deconz/sensor.py | 6 +++--- homeassistant/components/delijn/sensor.py | 5 ++--- homeassistant/components/deluge/sensor.py | 5 ++--- homeassistant/components/demo/sensor.py | 4 ++-- homeassistant/components/derivative/sensor.py | 4 ++-- homeassistant/components/deutsche_bahn/sensor.py | 5 ++--- .../components/devolo_home_control/sensor.py | 3 ++- homeassistant/components/dexcom/sensor.py | 5 +++-- homeassistant/components/dht/sensor.py | 5 ++--- homeassistant/components/discogs/sensor.py | 5 ++--- homeassistant/components/dnsip/sensor.py | 5 ++--- homeassistant/components/dovado/sensor.py | 5 ++--- homeassistant/components/dsmr/sensor.py | 5 ++--- homeassistant/components/dsmr_reader/sensor.py | 4 ++-- homeassistant/components/dte_energy_bridge/sensor.py | 5 ++--- .../components/dublin_bus_transport/sensor.py | 5 ++--- .../components/dwd_weather_warnings/sensor.py | 5 ++--- homeassistant/components/dweet/sensor.py | 5 ++--- homeassistant/components/dyson/sensor.py | 4 ++-- homeassistant/components/eafm/sensor.py | 3 ++- homeassistant/components/ebox/sensor.py | 5 ++--- homeassistant/components/ebusd/sensor.py | 4 ++-- homeassistant/components/ecoal_boiler/sensor.py | 4 ++-- homeassistant/components/ecobee/sensor.py | 4 ++-- homeassistant/components/econet/sensor.py | 3 ++- .../components/eddystone_temperature/sensor.py | 5 ++--- homeassistant/components/edl21/sensor.py | 5 ++--- homeassistant/components/efergy/sensor.py | 5 ++--- homeassistant/components/eight_sleep/sensor.py | 7 ++++--- homeassistant/components/eliqonline/sensor.py | 5 ++--- homeassistant/components/elkm1/sensor.py | 3 ++- homeassistant/components/emoncms/sensor.py | 5 ++--- homeassistant/components/enocean/sensor.py | 4 ++-- homeassistant/components/enphase_envoy/sensor.py | 4 ++-- .../components/entur_public_transport/sensor.py | 5 ++--- homeassistant/components/environment_canada/sensor.py | 5 ++--- homeassistant/components/envirophat/sensor.py | 5 ++--- homeassistant/components/envisalink/sensor.py | 4 ++-- homeassistant/components/epsonworkforce/sensor.py | 5 ++--- homeassistant/components/esphome/sensor.py | 6 +++--- homeassistant/components/essent/sensor.py | 5 ++--- homeassistant/components/etherscan/sensor.py | 5 ++--- 45 files changed, 100 insertions(+), 115 deletions(-) diff --git a/homeassistant/components/daikin/sensor.py b/homeassistant/components/daikin/sensor.py index 80de4ed34a5..a5b515ea918 100644 --- a/homeassistant/components/daikin/sensor.py +++ b/homeassistant/components/daikin/sensor.py @@ -1,4 +1,5 @@ """Support for Daikin AC sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_ICON, @@ -6,7 +7,6 @@ from homeassistant.const import ( CONF_TYPE, CONF_UNIT_OF_MEASUREMENT, ) -from homeassistant.helpers.entity import Entity from . import DOMAIN as DAIKIN_DOMAIN, DaikinApi from .const import ( @@ -49,7 +49,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities([DaikinSensor.factory(daikin_api, sensor) for sensor in sensors]) -class DaikinSensor(Entity): +class DaikinSensor(SensorEntity): """Representation of a Sensor.""" @staticmethod diff --git a/homeassistant/components/danfoss_air/sensor.py b/homeassistant/components/danfoss_air/sensor.py index 251c9692021..792a95e8ac4 100644 --- a/homeassistant/components/danfoss_air/sensor.py +++ b/homeassistant/components/danfoss_air/sensor.py @@ -3,6 +3,7 @@ import logging from pydanfossair.commands import ReadCommand +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, @@ -10,7 +11,6 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, ) -from homeassistant.helpers.entity import Entity from . import DOMAIN as DANFOSS_AIR_DOMAIN @@ -77,7 +77,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class DanfossAir(Entity): +class DanfossAir(SensorEntity): """Representation of a Sensor.""" def __init__(self, data, name, sensor_unit, sensor_type, device_class): diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index 7e6463dc08e..058969d96f9 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -6,7 +6,11 @@ import forecastio from requests.exceptions import ConnectionError as ConnectError, HTTPError, Timeout import voluptuous as vol -from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE, PLATFORM_SCHEMA +from homeassistant.components.sensor import ( + DEVICE_CLASS_TEMPERATURE, + PLATFORM_SCHEMA, + SensorEntity, +) from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_API_KEY, @@ -29,7 +33,6 @@ from homeassistant.const import ( UV_INDEX, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -544,7 +547,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class DarkSkySensor(Entity): +class DarkSkySensor(SensorEntity): """Implementation of a Dark Sky sensor.""" def __init__( @@ -708,7 +711,7 @@ class DarkSkySensor(Entity): return state -class DarkSkyAlertSensor(Entity): +class DarkSkyAlertSensor(SensorEntity): """Implementation of a Dark Sky sensor.""" def __init__(self, forecast_data, sensor_type, name): diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index b08ec0d091b..8f23b47a1b9 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -12,7 +12,7 @@ from pydeconz.sensor import ( Thermostat, ) -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.const import ( ATTR_TEMPERATURE, ATTR_VOLTAGE, @@ -122,7 +122,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class DeconzSensor(DeconzDevice): +class DeconzSensor(SensorEntity, DeconzDevice): """Representation of a deCONZ sensor.""" TYPE = DOMAIN @@ -186,7 +186,7 @@ class DeconzSensor(DeconzDevice): return attr -class DeconzBattery(DeconzDevice): +class DeconzBattery(SensorEntity, DeconzDevice): """Battery class for when a device is only represented as an event.""" TYPE = DOMAIN diff --git a/homeassistant/components/delijn/sensor.py b/homeassistant/components/delijn/sensor.py index 44b70c4e7a8..cff93c89954 100644 --- a/homeassistant/components/delijn/sensor.py +++ b/homeassistant/components/delijn/sensor.py @@ -5,11 +5,10 @@ from pydelijn.api import Passages from pydelijn.common import HttpException 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_API_KEY, DEVICE_CLASS_TIMESTAMP from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -58,7 +57,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors, True) -class DeLijnPublicTransportSensor(Entity): +class DeLijnPublicTransportSensor(SensorEntity): """Representation of a Ruter sensor.""" def __init__(self, line): diff --git a/homeassistant/components/deluge/sensor.py b/homeassistant/components/deluge/sensor.py index 5e8df89c20d..0c79e6f835e 100644 --- a/homeassistant/components/deluge/sensor.py +++ b/homeassistant/components/deluge/sensor.py @@ -4,7 +4,7 @@ import logging from deluge_client import DelugeRPCClient, FailedToReconnectException import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_HOST, CONF_MONITORED_VARIABLES, @@ -17,7 +17,6 @@ from homeassistant.const import ( ) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _THROTTLED_REFRESH = None @@ -68,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev) -class DelugeSensor(Entity): +class DelugeSensor(SensorEntity): """Representation of a Deluge sensor.""" def __init__(self, sensor_type, deluge_client, client_name): diff --git a/homeassistant/components/demo/sensor.py b/homeassistant/components/demo/sensor.py index 9c005d2d7f5..7607bad4e1c 100644 --- a/homeassistant/components/demo/sensor.py +++ b/homeassistant/components/demo/sensor.py @@ -1,4 +1,5 @@ """Demo platform that has a couple of fake sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_BATTERY_LEVEL, CONCENTRATION_PARTS_PER_MILLION, @@ -9,7 +10,6 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, ) -from homeassistant.helpers.entity import Entity from . import DOMAIN @@ -59,7 +59,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): await async_setup_platform(hass, {}, async_add_entities) -class DemoSensor(Entity): +class DemoSensor(SensorEntity): """Representation of a Demo sensor.""" def __init__( diff --git a/homeassistant/components/derivative/sensor.py b/homeassistant/components/derivative/sensor.py index ddbe1d19e31..72d0186d94d 100644 --- a/homeassistant/components/derivative/sensor.py +++ b/homeassistant/components/derivative/sensor.py @@ -4,7 +4,7 @@ import logging import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_UNIT_OF_MEASUREMENT, CONF_NAME, @@ -86,7 +86,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([derivative]) -class DerivativeSensor(RestoreEntity): +class DerivativeSensor(SensorEntity, RestoreEntity): """Representation of an derivative sensor.""" def __init__( diff --git a/homeassistant/components/deutsche_bahn/sensor.py b/homeassistant/components/deutsche_bahn/sensor.py index 1de6609c756..33fd9a8224f 100644 --- a/homeassistant/components/deutsche_bahn/sensor.py +++ b/homeassistant/components/deutsche_bahn/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta import schiene import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_OFFSET import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util CONF_DESTINATION = "to" @@ -40,7 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([DeutscheBahnSensor(start, destination, offset, only_direct)], True) -class DeutscheBahnSensor(Entity): +class DeutscheBahnSensor(SensorEntity): """Implementation of a Deutsche Bahn sensor.""" def __init__(self, start, goal, offset, only_direct): diff --git a/homeassistant/components/devolo_home_control/sensor.py b/homeassistant/components/devolo_home_control/sensor.py index 9fa3bdcf809..f125448b4cc 100644 --- a/homeassistant/components/devolo_home_control/sensor.py +++ b/homeassistant/components/devolo_home_control/sensor.py @@ -6,6 +6,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_VOLTAGE, + SensorEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import PERCENTAGE @@ -65,7 +66,7 @@ async def async_setup_entry( async_add_entities(entities, False) -class DevoloMultiLevelDeviceEntity(DevoloDeviceEntity): +class DevoloMultiLevelDeviceEntity(SensorEntity, DevoloDeviceEntity): """Abstract representation of a multi level sensor within devolo Home Control.""" @property diff --git a/homeassistant/components/dexcom/sensor.py b/homeassistant/components/dexcom/sensor.py index afb3feeec4d..09c7ff4e051 100644 --- a/homeassistant/components/dexcom/sensor.py +++ b/homeassistant/components/dexcom/sensor.py @@ -1,4 +1,5 @@ """Support for Dexcom sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -16,7 +17,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors, False) -class DexcomGlucoseValueSensor(CoordinatorEntity): +class DexcomGlucoseValueSensor(SensorEntity, CoordinatorEntity): """Representation of a Dexcom glucose value sensor.""" def __init__(self, coordinator, username, unit_of_measurement): @@ -58,7 +59,7 @@ class DexcomGlucoseValueSensor(CoordinatorEntity): return self._unique_id -class DexcomGlucoseTrendSensor(CoordinatorEntity): +class DexcomGlucoseTrendSensor(SensorEntity, CoordinatorEntity): """Representation of a Dexcom glucose trend sensor.""" def __init__(self, coordinator, username): diff --git a/homeassistant/components/dht/sensor.py b/homeassistant/components/dht/sensor.py index 0bddd5a187e..c1fa32e71d1 100644 --- a/homeassistant/components/dht/sensor.py +++ b/homeassistant/components/dht/sensor.py @@ -5,7 +5,7 @@ import logging import Adafruit_DHT # pylint: disable=import-error 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, @@ -14,7 +14,6 @@ from homeassistant.const import ( TEMP_FAHRENHEIT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.util.temperature import celsius_to_fahrenheit @@ -93,7 +92,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class DHTSensor(Entity): +class DHTSensor(SensorEntity): """Implementation of the DHT sensor.""" def __init__( diff --git a/homeassistant/components/discogs/sensor.py b/homeassistant/components/discogs/sensor.py index 6f45a4ab959..81beec0e60e 100644 --- a/homeassistant/components/discogs/sensor.py +++ b/homeassistant/components/discogs/sensor.py @@ -6,7 +6,7 @@ import random import discogs_client 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_MONITORED_CONDITIONS, @@ -15,7 +15,6 @@ from homeassistant.const import ( ) from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -89,7 +88,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class DiscogsSensor(Entity): +class DiscogsSensor(SensorEntity): """Create a new Discogs sensor for a specific type.""" def __init__(self, discogs_data, name, sensor_type): diff --git a/homeassistant/components/dnsip/sensor.py b/homeassistant/components/dnsip/sensor.py index b202ff8485c..01d6e2f4f2a 100644 --- a/homeassistant/components/dnsip/sensor.py +++ b/homeassistant/components/dnsip/sensor.py @@ -6,10 +6,9 @@ import aiodns from aiodns.error import DNSError 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -55,7 +54,7 @@ async def async_setup_platform(hass, config, async_add_devices, discovery_info=N async_add_devices([WanIpSensor(hass, name, hostname, resolver, ipv6)], True) -class WanIpSensor(Entity): +class WanIpSensor(SensorEntity): """Implementation of a DNS IP sensor.""" def __init__(self, hass, name, hostname, resolver, ipv6): diff --git a/homeassistant/components/dovado/sensor.py b/homeassistant/components/dovado/sensor.py index 8c8dffbb8b6..e7b3dbdd363 100644 --- a/homeassistant/components/dovado/sensor.py +++ b/homeassistant/components/dovado/sensor.py @@ -4,10 +4,9 @@ import re import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_SENSORS, DATA_GIGABYTES, PERCENTAGE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from . import DOMAIN as DOVADO_DOMAIN @@ -53,7 +52,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities) -class DovadoSensor(Entity): +class DovadoSensor(SensorEntity): """Representation of a Dovado sensor.""" def __init__(self, data, sensor): diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 0d2c55051e8..12304fa51d4 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -12,7 +12,7 @@ from dsmr_parser.clients.protocol import create_dsmr_reader, create_tcp_dsmr_rea import serial import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_HOST, @@ -22,7 +22,6 @@ from homeassistant.const import ( ) from homeassistant.core import CoreState, callback from homeassistant.helpers import config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import Throttle @@ -286,7 +285,7 @@ async def async_setup_entry( hass.data[DOMAIN][entry.entry_id][DATA_TASK] = task -class DSMREntity(Entity): +class DSMREntity(SensorEntity): """Entity reading values from DSMR telegram.""" def __init__(self, name, device_name, device_serial, obis, config, force_update): diff --git a/homeassistant/components/dsmr_reader/sensor.py b/homeassistant/components/dsmr_reader/sensor.py index 14234b49dbe..0ee5932c1bb 100644 --- a/homeassistant/components/dsmr_reader/sensor.py +++ b/homeassistant/components/dsmr_reader/sensor.py @@ -1,7 +1,7 @@ """Support for DSMR Reader through MQTT.""" from homeassistant.components import mqtt +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.util import slugify from .definitions import DEFINITIONS @@ -19,7 +19,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors) -class DSMRSensor(Entity): +class DSMRSensor(SensorEntity): """Representation of a DSMR sensor that is updated via MQTT.""" def __init__(self, topic): diff --git a/homeassistant/components/dte_energy_bridge/sensor.py b/homeassistant/components/dte_energy_bridge/sensor.py index efd00b3da1e..27475990de0 100644 --- a/homeassistant/components/dte_energy_bridge/sensor.py +++ b/homeassistant/components/dte_energy_bridge/sensor.py @@ -4,10 +4,9 @@ import logging import requests 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, HTTP_OK import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -39,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([DteEnergyBridgeSensor(ip_address, name, version)], True) -class DteEnergyBridgeSensor(Entity): +class DteEnergyBridgeSensor(SensorEntity): """Implementation of the DTE Energy Bridge sensors.""" def __init__(self, ip_address, name, version): diff --git a/homeassistant/components/dublin_bus_transport/sensor.py b/homeassistant/components/dublin_bus_transport/sensor.py index 5b0cbaf9f18..909eed09b9a 100644 --- a/homeassistant/components/dublin_bus_transport/sensor.py +++ b/homeassistant/components/dublin_bus_transport/sensor.py @@ -9,10 +9,9 @@ from datetime import datetime, timedelta import requests 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, HTTP_OK, TIME_MINUTES import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util _RESOURCE = "https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation" @@ -65,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([DublinPublicTransportSensor(data, stop, route, name)], True) -class DublinPublicTransportSensor(Entity): +class DublinPublicTransportSensor(SensorEntity): """Implementation of an Dublin public transport sensor.""" def __init__(self, data, stop, route, name): diff --git a/homeassistant/components/dwd_weather_warnings/sensor.py b/homeassistant/components/dwd_weather_warnings/sensor.py index af91e279600..78fa9bd8552 100644 --- a/homeassistant/components/dwd_weather_warnings/sensor.py +++ b/homeassistant/components/dwd_weather_warnings/sensor.py @@ -15,10 +15,9 @@ import logging from dwdwfsapi import DwdWeatherWarningsAPI 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_MONITORED_CONDITIONS, CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -87,7 +86,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class DwdWeatherWarningsSensor(Entity): +class DwdWeatherWarningsSensor(SensorEntity): """Representation of a DWD-Weather-Warnings sensor.""" def __init__(self, api, name, sensor_type): diff --git a/homeassistant/components/dweet/sensor.py b/homeassistant/components/dweet/sensor.py index f3f604ff369..f1243cd5407 100644 --- a/homeassistant/components/dweet/sensor.py +++ b/homeassistant/components/dweet/sensor.py @@ -6,7 +6,7 @@ import logging import dweepy import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_DEVICE, CONF_NAME, @@ -14,7 +14,6 @@ from homeassistant.const import ( CONF_VALUE_TEMPLATE, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -56,7 +55,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([DweetSensor(hass, dweet, name, value_template, unit)], True) -class DweetSensor(Entity): +class DweetSensor(SensorEntity): """Representation of a Dweet sensor.""" def __init__(self, hass, dweet, name, value_template, unit_of_measurement): diff --git a/homeassistant/components/dyson/sensor.py b/homeassistant/components/dyson/sensor.py index 80a64e787f0..356bfc61cb2 100644 --- a/homeassistant/components/dyson/sensor.py +++ b/homeassistant/components/dyson/sensor.py @@ -2,6 +2,7 @@ from libpurecool.dyson_pure_cool import DysonPureCool from libpurecool.dyson_pure_cool_link import DysonPureCoolLink +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_ICON, @@ -13,7 +14,6 @@ from homeassistant.const import ( TEMP_CELSIUS, TIME_HOURS, ) -from homeassistant.helpers.entity import Entity from . import DYSON_DEVICES, DysonEntity @@ -101,7 +101,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class DysonSensor(DysonEntity, Entity): +class DysonSensor(SensorEntity, DysonEntity): """Representation of a generic Dyson sensor.""" def __init__(self, device, sensor_type): diff --git a/homeassistant/components/eafm/sensor.py b/homeassistant/components/eafm/sensor.py index 9e2d4e5cef9..8fa2a47c157 100644 --- a/homeassistant/components/eafm/sensor.py +++ b/homeassistant/components/eafm/sensor.py @@ -5,6 +5,7 @@ import logging from aioeafm import get_station import async_timeout +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION, LENGTH_METERS from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.update_coordinator import ( @@ -77,7 +78,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): await coordinator.async_refresh() -class Measurement(CoordinatorEntity): +class Measurement(SensorEntity, CoordinatorEntity): """A gauge at a flood monitoring station.""" attribution = "This uses Environment Agency flood and river level data from the real-time data API" diff --git a/homeassistant/components/ebox/sensor.py b/homeassistant/components/ebox/sensor.py index aa6945bac99..72d169f389e 100644 --- a/homeassistant/components/ebox/sensor.py +++ b/homeassistant/components/ebox/sensor.py @@ -10,7 +10,7 @@ from pyebox import EboxClient from pyebox.client import PyEboxError 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_VARIABLES, CONF_NAME, @@ -22,7 +22,6 @@ from homeassistant.const import ( ) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -90,7 +89,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors, True) -class EBoxSensor(Entity): +class EBoxSensor(SensorEntity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): diff --git a/homeassistant/components/ebusd/sensor.py b/homeassistant/components/ebusd/sensor.py index 53dac4eb4c0..00f6a6b2b3e 100644 --- a/homeassistant/components/ebusd/sensor.py +++ b/homeassistant/components/ebusd/sensor.py @@ -2,7 +2,7 @@ import datetime import logging -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from homeassistant.util import Throttle import homeassistant.util.dt as dt_util @@ -34,7 +34,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class EbusdSensor(Entity): +class EbusdSensor(SensorEntity): """Ebusd component sensor methods definition.""" def __init__(self, data, sensor, name): diff --git a/homeassistant/components/ecoal_boiler/sensor.py b/homeassistant/components/ecoal_boiler/sensor.py index 963f547283f..e1c9308b5a9 100644 --- a/homeassistant/components/ecoal_boiler/sensor.py +++ b/homeassistant/components/ecoal_boiler/sensor.py @@ -1,6 +1,6 @@ """Allows reading temperatures from ecoal/esterownik.pl controller.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import TEMP_CELSIUS -from homeassistant.helpers.entity import Entity from . import AVAILABLE_SENSORS, DATA_ECOAL_BOILER @@ -17,7 +17,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class EcoalTempSensor(Entity): +class EcoalTempSensor(SensorEntity): """Representation of a temperature sensor using ecoal status data.""" def __init__(self, ecoal_contr, name, status_attr): diff --git a/homeassistant/components/ecobee/sensor.py b/homeassistant/components/ecobee/sensor.py index cfbaa7a4516..5abe809e59d 100644 --- a/homeassistant/components/ecobee/sensor.py +++ b/homeassistant/components/ecobee/sensor.py @@ -1,13 +1,13 @@ """Support for Ecobee sensors.""" from pyecobee.const import ECOBEE_STATE_CALIBRATING, ECOBEE_STATE_UNKNOWN +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, PERCENTAGE, TEMP_FAHRENHEIT, ) -from homeassistant.helpers.entity import Entity from .const import _LOGGER, DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER @@ -32,7 +32,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(dev, True) -class EcobeeSensor(Entity): +class EcobeeSensor(SensorEntity): """Representation of an Ecobee sensor.""" def __init__(self, data, sensor_name, sensor_type, sensor_index): diff --git a/homeassistant/components/econet/sensor.py b/homeassistant/components/econet/sensor.py index e0ef7dc6ce9..8198eb75045 100644 --- a/homeassistant/components/econet/sensor.py +++ b/homeassistant/components/econet/sensor.py @@ -1,6 +1,7 @@ """Support for Rheem EcoNet water heaters.""" from pyeconet.equipment import EquipmentType +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, PERCENTAGE, @@ -47,7 +48,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors) -class EcoNetSensor(EcoNetEntity): +class EcoNetSensor(SensorEntity, EcoNetEntity): """Define a Econet sensor.""" def __init__(self, econet_device, device_name): diff --git a/homeassistant/components/eddystone_temperature/sensor.py b/homeassistant/components/eddystone_temperature/sensor.py index f8a7254b6fa..70afde4ffb1 100644 --- a/homeassistant/components/eddystone_temperature/sensor.py +++ b/homeassistant/components/eddystone_temperature/sensor.py @@ -10,7 +10,7 @@ import logging from beacontools import BeaconScanner, EddystoneFilter, EddystoneTLMFrame 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, EVENT_HOMEASSISTANT_START, @@ -19,7 +19,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -97,7 +96,7 @@ def get_from_conf(config, config_key, length): return string -class EddystoneTemp(Entity): +class EddystoneTemp(SensorEntity): """Representation of a temperature sensor.""" def __init__(self, name, namespace, instance): diff --git a/homeassistant/components/edl21/sensor.py b/homeassistant/components/edl21/sensor.py index 1f21eaa4004..090b2780ec4 100644 --- a/homeassistant/components/edl21/sensor.py +++ b/homeassistant/components/edl21/sensor.py @@ -7,7 +7,7 @@ from sml import SmlGetListResponse from sml.asyncio import SmlProtocol 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.core import callback import homeassistant.helpers.config_validation as cv @@ -15,7 +15,6 @@ from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, ) -from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.helpers.typing import Optional from homeassistant.util.dt import utcnow @@ -193,7 +192,7 @@ class EDL21: self._async_add_entities(new_entities, update_before_add=True) -class EDL21Entity(Entity): +class EDL21Entity(SensorEntity): """Entity reading values from EDL21 telegram.""" def __init__(self, electricity_id, obis, name, telegram): diff --git a/homeassistant/components/efergy/sensor.py b/homeassistant/components/efergy/sensor.py index 02bc8fa0ccb..6e2ac1c01c7 100644 --- a/homeassistant/components/efergy/sensor.py +++ b/homeassistant/components/efergy/sensor.py @@ -4,7 +4,7 @@ import logging import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_CURRENCY, CONF_MONITORED_VARIABLES, @@ -13,7 +13,6 @@ from homeassistant.const import ( POWER_WATT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _RESOURCE = "https://engage.efergy.com/mobile_proxy/" @@ -94,7 +93,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class EfergySensor(Entity): +class EfergySensor(SensorEntity): """Implementation of an Efergy sensor.""" def __init__(self, sensor_type, app_token, utc_offset, period, currency, sid=None): diff --git a/homeassistant/components/eight_sleep/sensor.py b/homeassistant/components/eight_sleep/sensor.py index f858309d02c..f5a0d1b1f8d 100644 --- a/homeassistant/components/eight_sleep/sensor.py +++ b/homeassistant/components/eight_sleep/sensor.py @@ -1,6 +1,7 @@ """Support for Eight Sleep sensors.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT from . import ( @@ -66,7 +67,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(all_sensors, True) -class EightHeatSensor(EightSleepHeatEntity): +class EightHeatSensor(SensorEntity, EightSleepHeatEntity): """Representation of an eight sleep heat-based sensor.""" def __init__(self, name, eight, sensor): @@ -119,7 +120,7 @@ class EightHeatSensor(EightSleepHeatEntity): } -class EightUserSensor(EightSleepUserEntity): +class EightUserSensor(SensorEntity, EightSleepUserEntity): """Representation of an eight sleep user-based sensor.""" def __init__(self, name, eight, sensor, units): @@ -289,7 +290,7 @@ class EightUserSensor(EightSleepUserEntity): return state_attr -class EightRoomSensor(EightSleepUserEntity): +class EightRoomSensor(SensorEntity, EightSleepUserEntity): """Representation of an eight sleep room sensor.""" def __init__(self, name, eight, sensor, units): diff --git a/homeassistant/components/eliqonline/sensor.py b/homeassistant/components/eliqonline/sensor.py index b3d56e42325..a4d812850f7 100644 --- a/homeassistant/components/eliqonline/sensor.py +++ b/homeassistant/components/eliqonline/sensor.py @@ -6,11 +6,10 @@ import logging import eliqonline import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_ACCESS_TOKEN, CONF_NAME, POWER_WATT from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -52,7 +51,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([EliqSensor(api, channel_id, name)], True) -class EliqSensor(Entity): +class EliqSensor(SensorEntity): """Implementation of an ELIQ Online sensor.""" def __init__(self, api, channel_id, name): diff --git a/homeassistant/components/elkm1/sensor.py b/homeassistant/components/elkm1/sensor.py index 7d63f283f0b..c8d4fd722bb 100644 --- a/homeassistant/components/elkm1/sensor.py +++ b/homeassistant/components/elkm1/sensor.py @@ -8,6 +8,7 @@ from elkm1_lib.const import ( from elkm1_lib.util import pretty_const, username import voluptuous as vol +from homeassistant.components.sensor import SensorEntity from homeassistant.const import VOLT from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_platform @@ -67,7 +68,7 @@ def temperature_to_state(temperature, undefined_temperature): return temperature if temperature > undefined_temperature else None -class ElkSensor(ElkAttachedEntity): +class ElkSensor(SensorEntity, ElkAttachedEntity): """Base representation of Elk-M1 sensor.""" def __init__(self, element, elk, elk_data): diff --git a/homeassistant/components/emoncms/sensor.py b/homeassistant/components/emoncms/sensor.py index 523350532a0..4913f6340cc 100644 --- a/homeassistant/components/emoncms/sensor.py +++ b/homeassistant/components/emoncms/sensor.py @@ -5,7 +5,7 @@ import logging import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_API_KEY, CONF_ID, @@ -19,7 +19,6 @@ from homeassistant.const import ( ) from homeassistant.helpers import template import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -125,7 +124,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class EmonCmsSensor(Entity): +class EmonCmsSensor(SensorEntity): """Implementation of an Emoncms sensor.""" def __init__( diff --git a/homeassistant/components/enocean/sensor.py b/homeassistant/components/enocean/sensor.py index 011dcdafdb6..18362a3c6ac 100644 --- a/homeassistant/components/enocean/sensor.py +++ b/homeassistant/components/enocean/sensor.py @@ -1,7 +1,7 @@ """Support for EnOcean sensors.""" import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_ID, @@ -101,7 +101,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([EnOceanWindowHandle(dev_id, dev_name)]) -class EnOceanSensor(EnOceanEntity, RestoreEntity): +class EnOceanSensor(SensorEntity, EnOceanEntity, RestoreEntity): """Representation of an EnOcean sensor device such as a power meter.""" def __init__(self, dev_id, dev_name, sensor_type): diff --git a/homeassistant/components/enphase_envoy/sensor.py b/homeassistant/components/enphase_envoy/sensor.py index e40c8e94372..794c0ca2dbd 100644 --- a/homeassistant/components/enphase_envoy/sensor.py +++ b/homeassistant/components/enphase_envoy/sensor.py @@ -8,7 +8,7 @@ from envoy_reader.envoy_reader import EnvoyReader import httpx import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_IP_ADDRESS, CONF_MONITORED_CONDITIONS, @@ -156,7 +156,7 @@ async def async_setup_platform( async_add_entities(entities) -class Envoy(CoordinatorEntity): +class Envoy(SensorEntity, CoordinatorEntity): """Envoy entity.""" def __init__(self, sensor_type, name, serial_number, unit, coordinator): diff --git a/homeassistant/components/entur_public_transport/sensor.py b/homeassistant/components/entur_public_transport/sensor.py index 23c895c58a1..c9c530c6b08 100644 --- a/homeassistant/components/entur_public_transport/sensor.py +++ b/homeassistant/components/entur_public_transport/sensor.py @@ -4,7 +4,7 @@ from datetime import datetime, timedelta from enturclient import EnturPublicTransportData 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_LATITUDE, @@ -15,7 +15,6 @@ from homeassistant.const import ( ) from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle import homeassistant.util.dt as dt_util @@ -148,7 +147,7 @@ class EnturProxy: return self._api.get_stop_info(stop_id) -class EnturPublicTransportSensor(Entity): +class EnturPublicTransportSensor(SensorEntity): """Implementation of a Entur public transport sensor.""" def __init__(self, api: EnturProxy, name: str, stop: str, show_on_map: bool): diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index f178b3c6275..0f0fb04fd00 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -6,7 +6,7 @@ import re from env_canada import ECData 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, ATTR_LOCATION, @@ -15,7 +15,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -65,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([ECSensor(sensor_type, ec_data) for sensor_type in sensor_list], True) -class ECSensor(Entity): +class ECSensor(SensorEntity): """Implementation of an Environment Canada sensor.""" def __init__(self, sensor_type, ec_data): diff --git a/homeassistant/components/envirophat/sensor.py b/homeassistant/components/envirophat/sensor.py index 873d9935ee8..137d6aee853 100644 --- a/homeassistant/components/envirophat/sensor.py +++ b/homeassistant/components/envirophat/sensor.py @@ -5,7 +5,7 @@ import logging 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, CONF_NAME, @@ -14,7 +14,6 @@ from homeassistant.const import ( VOLT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -71,7 +70,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class EnvirophatSensor(Entity): +class EnvirophatSensor(SensorEntity): """Representation of an Enviro pHAT sensor.""" def __init__(self, data, sensor_types): diff --git a/homeassistant/components/envisalink/sensor.py b/homeassistant/components/envisalink/sensor.py index 9551b51b3e9..ff4c73500f9 100644 --- a/homeassistant/components/envisalink/sensor.py +++ b/homeassistant/components/envisalink/sensor.py @@ -1,9 +1,9 @@ """Support for Envisalink sensors (shows panel info).""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from . import ( CONF_PARTITIONNAME, @@ -37,7 +37,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(devices) -class EnvisalinkSensor(EnvisalinkDevice, Entity): +class EnvisalinkSensor(SensorEntity, EnvisalinkDevice): """Representation of an Envisalink keypad.""" def __init__(self, hass, partition_name, partition_number, info, controller): diff --git a/homeassistant/components/epsonworkforce/sensor.py b/homeassistant/components/epsonworkforce/sensor.py index 7c6042c8959..22f74e1c0b1 100644 --- a/homeassistant/components/epsonworkforce/sensor.py +++ b/homeassistant/components/epsonworkforce/sensor.py @@ -4,11 +4,10 @@ from datetime import timedelta from epsonprinter_pkg.epsonprinterapi import EpsonPrinterAPI import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_HOST, CONF_MONITORED_CONDITIONS, PERCENTAGE from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity MONITORED_CONDITIONS = { "black": ["Ink level Black", PERCENTAGE, "mdi:water"], @@ -45,7 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(sensors, True) -class EpsonPrinterCartridge(Entity): +class EpsonPrinterCartridge(SensorEntity): """Representation of a cartridge sensor.""" def __init__(self, api, cartridgeidx): diff --git a/homeassistant/components/esphome/sensor.py b/homeassistant/components/esphome/sensor.py index 17799e4484f..99f66f48029 100644 --- a/homeassistant/components/esphome/sensor.py +++ b/homeassistant/components/esphome/sensor.py @@ -6,7 +6,7 @@ import math from aioesphomeapi import SensorInfo, SensorState, TextSensorInfo, TextSensorState import voluptuous as vol -from homeassistant.components.sensor import DEVICE_CLASSES +from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity from homeassistant.config_entries import ConfigEntry import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import HomeAssistantType @@ -42,7 +42,7 @@ async def async_setup_entry( # pylint: disable=invalid-overridden-method -class EsphomeSensor(EsphomeEntity): +class EsphomeSensor(SensorEntity, EsphomeEntity): """A sensor implementation for esphome.""" @property @@ -89,7 +89,7 @@ class EsphomeSensor(EsphomeEntity): return self._static_info.device_class -class EsphomeTextSensor(EsphomeEntity): +class EsphomeTextSensor(SensorEntity, EsphomeEntity): """A text sensor implementation for ESPHome.""" @property diff --git a/homeassistant/components/essent/sensor.py b/homeassistant/components/essent/sensor.py index 26f7c930241..f0dc70d7be4 100644 --- a/homeassistant/components/essent/sensor.py +++ b/homeassistant/components/essent/sensor.py @@ -6,10 +6,9 @@ from datetime import timedelta from pyessent import PyEssent import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, ENERGY_KILO_WATT_HOUR import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle SCAN_INTERVAL = timedelta(hours=1) @@ -82,7 +81,7 @@ class EssentBase: self._meter_data[possible_meter] = meter_data -class EssentMeter(Entity): +class EssentMeter(SensorEntity): """Representation of Essent measurements.""" def __init__(self, essent_base, meter, meter_type, tariff, unit): diff --git a/homeassistant/components/etherscan/sensor.py b/homeassistant/components/etherscan/sensor.py index e56b49181d4..1fa2edbf2e8 100644 --- a/homeassistant/components/etherscan/sensor.py +++ b/homeassistant/components/etherscan/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta from pyetherscan import get_balance 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_ADDRESS, CONF_NAME, CONF_TOKEN import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTRIBUTION = "Data provided by etherscan.io" @@ -42,7 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([EtherscanSensor(name, address, token, token_address)], True) -class EtherscanSensor(Entity): +class EtherscanSensor(SensorEntity): """Representation of an Etherscan.io sensor.""" def __init__(self, name, address, token, token_address):