From fdf97eaca34f56ea19c3c73758641233e10056b5 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 19:59:03 +0100 Subject: [PATCH] Migrate integrations i-m to extend SensorEntity (#48213) --- homeassistant/components/iammeter/sensor.py | 4 ++-- homeassistant/components/iaqualink/sensor.py | 4 ++-- homeassistant/components/icloud/sensor.py | 4 ++-- homeassistant/components/ihc/sensor.py | 4 ++-- homeassistant/components/imap/sensor.py | 5 ++--- .../components/imap_email_content/sensor.py | 5 ++--- homeassistant/components/incomfort/sensor.py | 4 ++-- homeassistant/components/influxdb/sensor.py | 8 +++++--- homeassistant/components/integration/sensor.py | 4 ++-- homeassistant/components/ios/sensor.py | 4 ++-- homeassistant/components/iota/sensor.py | 5 +++-- homeassistant/components/iperf3/sensor.py | 3 ++- homeassistant/components/ipp/sensor.py | 3 ++- homeassistant/components/iqvia/sensor.py | 5 +++-- .../components/irish_rail_transport/sensor.py | 5 ++--- .../components/islamic_prayer_times/sensor.py | 4 ++-- homeassistant/components/isy994/sensor.py | 6 +++--- .../components/jewish_calendar/sensor.py | 4 ++-- homeassistant/components/juicenet/sensor.py | 4 ++-- homeassistant/components/kaiterra/sensor.py | 4 ++-- homeassistant/components/keba/sensor.py | 4 ++-- homeassistant/components/kira/sensor.py | 4 ++-- homeassistant/components/knx/sensor.py | 4 ++-- homeassistant/components/konnected/sensor.py | 4 ++-- homeassistant/components/kwb/sensor.py | 5 ++--- homeassistant/components/lacrosse/sensor.py | 10 +++++++--- homeassistant/components/lastfm/sensor.py | 5 ++--- homeassistant/components/launch_library/sensor.py | 5 ++--- homeassistant/components/lcn/sensor.py | 6 +++--- homeassistant/components/lightwave/sensor.py | 4 ++-- homeassistant/components/linux_battery/sensor.py | 5 ++--- homeassistant/components/litterrobot/sensor.py | 8 ++++---- homeassistant/components/local_ip/sensor.py | 4 ++-- homeassistant/components/logi_circle/sensor.py | 4 ++-- homeassistant/components/london_air/sensor.py | 5 ++--- .../components/london_underground/sensor.py | 5 ++--- homeassistant/components/loopenergy/sensor.py | 9 ++++----- homeassistant/components/luftdaten/sensor.py | 4 ++-- homeassistant/components/lyft/sensor.py | 5 ++--- homeassistant/components/lyric/sensor.py | 3 ++- homeassistant/components/magicseaweed/sensor.py | 5 ++--- homeassistant/components/mazda/sensor.py | 15 ++++++++------- homeassistant/components/melcloud/sensor.py | 4 ++-- homeassistant/components/meteo_france/sensor.py | 3 ++- homeassistant/components/metoffice/sensor.py | 4 ++-- homeassistant/components/mfi/sensor.py | 5 ++--- homeassistant/components/mhz19/sensor.py | 5 ++--- homeassistant/components/miflora/sensor.py | 5 ++--- homeassistant/components/min_max/sensor.py | 5 ++--- .../components/minecraft_server/sensor.py | 3 ++- homeassistant/components/mitemp_bt/sensor.py | 5 ++--- homeassistant/components/mobile_app/sensor.py | 3 ++- homeassistant/components/modbus/sensor.py | 8 ++++++-- homeassistant/components/modem_callerid/sensor.py | 5 ++--- homeassistant/components/mold_indicator/sensor.py | 5 ++--- homeassistant/components/moon/sensor.py | 5 ++--- homeassistant/components/motion_blinds/sensor.py | 6 +++--- homeassistant/components/mqtt/sensor.py | 5 ++--- homeassistant/components/mqtt_room/sensor.py | 5 ++--- homeassistant/components/mvglive/sensor.py | 5 ++--- homeassistant/components/mychevy/sensor.py | 7 +++---- homeassistant/components/mysensors/sensor.py | 4 ++-- 62 files changed, 152 insertions(+), 157 deletions(-) diff --git a/homeassistant/components/iammeter/sensor.py b/homeassistant/components/iammeter/sensor.py index f885c2c49d3..b1882619fda 100644 --- a/homeassistant/components/iammeter/sensor.py +++ b/homeassistant/components/iammeter/sensor.py @@ -8,7 +8,7 @@ from iammeter import real_time_api from iammeter.power_meter import IamMeterError 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_NAME, CONF_PORT from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers import debounce @@ -74,7 +74,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(entities) -class IamMeter(CoordinatorEntity): +class IamMeter(CoordinatorEntity, SensorEntity): """Class for a sensor.""" def __init__(self, coordinator, uid, sensor_name, unit, dev_name): diff --git a/homeassistant/components/iaqualink/sensor.py b/homeassistant/components/iaqualink/sensor.py index 565cfcca667..eac6e2b7851 100644 --- a/homeassistant/components/iaqualink/sensor.py +++ b/homeassistant/components/iaqualink/sensor.py @@ -1,7 +1,7 @@ """Support for Aqualink temperature sensors.""" from __future__ import annotations -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.helpers.typing import HomeAssistantType @@ -22,7 +22,7 @@ async def async_setup_entry( async_add_entities(devs, True) -class HassAqualinkSensor(AqualinkEntity): +class HassAqualinkSensor(AqualinkEntity, SensorEntity): """Representation of a sensor.""" @property diff --git a/homeassistant/components/icloud/sensor.py b/homeassistant/components/icloud/sensor.py index e75c9aa3854..ddd3d54c556 100644 --- a/homeassistant/components/icloud/sensor.py +++ b/homeassistant/components/icloud/sensor.py @@ -1,11 +1,11 @@ """Support for iCloud sensors.""" from __future__ import annotations +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.typing import HomeAssistantType @@ -48,7 +48,7 @@ def add_entities(account, async_add_entities, tracked): async_add_entities(new_tracked, True) -class IcloudDeviceBatterySensor(Entity): +class IcloudDeviceBatterySensor(SensorEntity): """Representation of a iCloud device battery sensor.""" def __init__(self, account: IcloudAccount, device: IcloudDevice): diff --git a/homeassistant/components/ihc/sensor.py b/homeassistant/components/ihc/sensor.py index cb1688bc7be..3348e857f51 100644 --- a/homeassistant/components/ihc/sensor.py +++ b/homeassistant/components/ihc/sensor.py @@ -1,6 +1,6 @@ """Support for IHC sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_UNIT_OF_MEASUREMENT -from homeassistant.helpers.entity import Entity from . import IHC_CONTROLLER, IHC_INFO from .ihcdevice import IHCDevice @@ -26,7 +26,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class IHCSensor(IHCDevice, Entity): +class IHCSensor(IHCDevice, SensorEntity): """Implementation of the IHC sensor.""" def __init__( diff --git a/homeassistant/components/imap/sensor.py b/homeassistant/components/imap/sensor.py index 4917abc6028..4158d1be801 100644 --- a/homeassistant/components/imap/sensor.py +++ b/homeassistant/components/imap/sensor.py @@ -6,7 +6,7 @@ from aioimaplib import IMAP4_SSL, AioImapException import async_timeout 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_PASSWORD, @@ -16,7 +16,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__) @@ -62,7 +61,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([sensor], True) -class ImapSensor(Entity): +class ImapSensor(SensorEntity): """Representation of an IMAP sensor.""" def __init__(self, name, user, password, server, port, charset, folder, search): diff --git a/homeassistant/components/imap_email_content/sensor.py b/homeassistant/components/imap_email_content/sensor.py index 84dc527ac52..22c395a7c8f 100644 --- a/homeassistant/components/imap_email_content/sensor.py +++ b/homeassistant/components/imap_email_content/sensor.py @@ -7,7 +7,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_DATE, CONF_NAME, @@ -18,7 +18,6 @@ from homeassistant.const import ( CONTENT_TYPE_TEXT_PLAIN, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -145,7 +144,7 @@ class EmailReader: return None -class EmailContentSensor(Entity): +class EmailContentSensor(SensorEntity): """Representation of an EMail sensor.""" def __init__(self, hass, email_reader, name, allowed_senders, value_template): diff --git a/homeassistant/components/incomfort/sensor.py b/homeassistant/components/incomfort/sensor.py index 8cb07fce14b..a9e1faaba10 100644 --- a/homeassistant/components/incomfort/sensor.py +++ b/homeassistant/components/incomfort/sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Any -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity from homeassistant.const import ( DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, @@ -40,7 +40,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class IncomfortSensor(IncomfortChild): +class IncomfortSensor(IncomfortChild, SensorEntity): """Representation of an InComfort/InTouch sensor device.""" def __init__(self, client, heater, name) -> None: diff --git a/homeassistant/components/influxdb/sensor.py b/homeassistant/components/influxdb/sensor.py index cfabd3ee099..299fc595f4b 100644 --- a/homeassistant/components/influxdb/sensor.py +++ b/homeassistant/components/influxdb/sensor.py @@ -5,7 +5,10 @@ import logging import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA +from homeassistant.components.sensor import ( + PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA, + SensorEntity, +) from homeassistant.const import ( CONF_API_VERSION, CONF_NAME, @@ -16,7 +19,6 @@ from homeassistant.const import ( ) from homeassistant.exceptions import PlatformNotReady, TemplateError import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from . import create_influx_url, get_influx_connection, validate_version_specific_config @@ -169,7 +171,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda _: influx.close()) -class InfluxSensor(Entity): +class InfluxSensor(SensorEntity): """Implementation of a Influxdb sensor.""" def __init__(self, hass, influx, query): diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index 3be60dcd7f7..0ab4ac0d2c4 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/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_METHOD, @@ -83,7 +83,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([integral]) -class IntegrationSensor(RestoreEntity): +class IntegrationSensor(RestoreEntity, SensorEntity): """Representation of an integration sensor.""" def __init__( diff --git a/homeassistant/components/ios/sensor.py b/homeassistant/components/ios/sensor.py index a8cffacabe9..c1442f0de9f 100644 --- a/homeassistant/components/ios/sensor.py +++ b/homeassistant/components/ios/sensor.py @@ -1,9 +1,9 @@ """Support for Home Assistant iOS app sensors.""" from homeassistant.components import ios +from homeassistant.components.sensor import SensorEntity from homeassistant.const import PERCENTAGE from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level from .const import DOMAIN @@ -32,7 +32,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(dev, True) -class IOSSensor(Entity): +class IOSSensor(SensorEntity): """Representation of an iOS sensor.""" def __init__(self, sensor_type, device_name, device): diff --git a/homeassistant/components/iota/sensor.py b/homeassistant/components/iota/sensor.py index 751324d61b1..62260be2410 100644 --- a/homeassistant/components/iota/sensor.py +++ b/homeassistant/components/iota/sensor.py @@ -1,6 +1,7 @@ """Support for IOTA wallet sensors.""" from datetime import timedelta +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME from . import CONF_WALLETS, IotaDevice @@ -27,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class IotaBalanceSensor(IotaDevice): +class IotaBalanceSensor(IotaDevice, SensorEntity): """Implement an IOTA sensor for displaying wallets balance.""" def __init__(self, wallet_config, iota_config): @@ -60,7 +61,7 @@ class IotaBalanceSensor(IotaDevice): self._state = self.api.get_inputs()["totalBalance"] -class IotaNodeSensor(IotaDevice): +class IotaNodeSensor(IotaDevice, SensorEntity): """Implement an IOTA sensor for displaying attributes of node.""" def __init__(self, iota_config): diff --git a/homeassistant/components/iperf3/sensor.py b/homeassistant/components/iperf3/sensor.py index a8a79008817..610ff91250f 100644 --- a/homeassistant/components/iperf3/sensor.py +++ b/homeassistant/components/iperf3/sensor.py @@ -1,4 +1,5 @@ """Support for Iperf3 sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -23,7 +24,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info) async_add_entities(sensors, True) -class Iperf3Sensor(RestoreEntity): +class Iperf3Sensor(RestoreEntity, SensorEntity): """A Iperf3 sensor implementation.""" def __init__(self, iperf3_data, sensor_type): diff --git a/homeassistant/components/ipp/sensor.py b/homeassistant/components/ipp/sensor.py index 1ff98df7a5f..83826409ed8 100644 --- a/homeassistant/components/ipp/sensor.py +++ b/homeassistant/components/ipp/sensor.py @@ -4,6 +4,7 @@ from __future__ import annotations from datetime import timedelta from typing import Any, Callable +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_LOCATION, DEVICE_CLASS_TIMESTAMP, PERCENTAGE from homeassistant.helpers.entity import Entity @@ -52,7 +53,7 @@ async def async_setup_entry( async_add_entities(sensors, True) -class IPPSensor(IPPEntity): +class IPPSensor(IPPEntity, SensorEntity): """Defines an IPP sensor.""" def __init__( diff --git a/homeassistant/components/iqvia/sensor.py b/homeassistant/components/iqvia/sensor.py index 48ec1cf97b1..169ff405d6d 100644 --- a/homeassistant/components/iqvia/sensor.py +++ b/homeassistant/components/iqvia/sensor.py @@ -3,6 +3,7 @@ from statistics import mean import numpy as np +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_STATE from homeassistant.core import callback @@ -98,7 +99,7 @@ def calculate_trend(indices): return TREND_FLAT -class ForecastSensor(IQVIAEntity): +class ForecastSensor(IQVIAEntity, SensorEntity): """Define sensor related to forecast data.""" @callback @@ -137,7 +138,7 @@ class ForecastSensor(IQVIAEntity): self._state = average -class IndexSensor(IQVIAEntity): +class IndexSensor(IQVIAEntity, SensorEntity): """Define sensor related to indices.""" @callback diff --git a/homeassistant/components/irish_rail_transport/sensor.py b/homeassistant/components/irish_rail_transport/sensor.py index bd277020125..b5ba16f8541 100644 --- a/homeassistant/components/irish_rail_transport/sensor.py +++ b/homeassistant/components/irish_rail_transport/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta from pyirishrail.pyirishrail import IrishRailRTPI 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTR_STATION = "Station" ATTR_ORIGIN = "Origin" @@ -64,7 +63,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class IrishRailTransportSensor(Entity): +class IrishRailTransportSensor(SensorEntity): """Implementation of an irish rail public transport sensor.""" def __init__(self, data, station, direction, destination, stops_at, name): diff --git a/homeassistant/components/islamic_prayer_times/sensor.py b/homeassistant/components/islamic_prayer_times/sensor.py index 41b3cf4c667..3133320d978 100644 --- a/homeassistant/components/islamic_prayer_times/sensor.py +++ b/homeassistant/components/islamic_prayer_times/sensor.py @@ -1,8 +1,8 @@ """Platform to retrieve Islamic prayer times information for Home Assistant.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TIMESTAMP from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_TYPES @@ -20,7 +20,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class IslamicPrayerTimeSensor(Entity): +class IslamicPrayerTimeSensor(SensorEntity): """Representation of an Islamic prayer time sensor.""" def __init__(self, sensor_type, client): diff --git a/homeassistant/components/isy994/sensor.py b/homeassistant/components/isy994/sensor.py index 4d3c4c72763..2927fbb62b1 100644 --- a/homeassistant/components/isy994/sensor.py +++ b/homeassistant/components/isy994/sensor.py @@ -5,7 +5,7 @@ from typing import Callable from pyisy.constants import ISY_VALUE_UNKNOWN -from homeassistant.components.sensor import DOMAIN as SENSOR +from homeassistant.components.sensor import DOMAIN as SENSOR, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.helpers.typing import HomeAssistantType @@ -45,7 +45,7 @@ async def async_setup_entry( async_add_entities(devices) -class ISYSensorEntity(ISYNodeEntity): +class ISYSensorEntity(ISYNodeEntity, SensorEntity): """Representation of an ISY994 sensor device.""" @property @@ -105,7 +105,7 @@ class ISYSensorEntity(ISYNodeEntity): return raw_units -class ISYSensorVariableEntity(ISYEntity): +class ISYSensorVariableEntity(ISYEntity, SensorEntity): """Representation of an ISY994 variable as a sensor device.""" def __init__(self, vname: str, vobj: object) -> None: diff --git a/homeassistant/components/jewish_calendar/sensor.py b/homeassistant/components/jewish_calendar/sensor.py index 14336b1f935..5690cd35a03 100644 --- a/homeassistant/components/jewish_calendar/sensor.py +++ b/homeassistant/components/jewish_calendar/sensor.py @@ -3,8 +3,8 @@ import logging import hdate +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TIMESTAMP, SUN_EVENT_SUNSET -from homeassistant.helpers.entity import Entity from homeassistant.helpers.sun import get_astral_event_date import homeassistant.util.dt as dt_util @@ -30,7 +30,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors) -class JewishCalendarSensor(Entity): +class JewishCalendarSensor(SensorEntity): """Representation of an Jewish calendar sensor.""" def __init__(self, data, sensor, sensor_info): diff --git a/homeassistant/components/juicenet/sensor.py b/homeassistant/components/juicenet/sensor.py index 10008f30e7c..d908dc069ef 100644 --- a/homeassistant/components/juicenet/sensor.py +++ b/homeassistant/components/juicenet/sensor.py @@ -1,4 +1,5 @@ """Support for monitoring juicenet/juicepoint/juicebox based EVSE sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ELECTRICAL_CURRENT_AMPERE, ENERGY_WATT_HOUR, @@ -7,7 +8,6 @@ from homeassistant.const import ( TIME_SECONDS, VOLT, ) -from homeassistant.helpers.entity import Entity from .const import DOMAIN, JUICENET_API, JUICENET_COORDINATOR from .entity import JuiceNetDevice @@ -36,7 +36,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class JuiceNetSensorDevice(JuiceNetDevice, Entity): +class JuiceNetSensorDevice(JuiceNetDevice, SensorEntity): """Implementation of a JuiceNet sensor.""" def __init__(self, device, sensor_type, coordinator): diff --git a/homeassistant/components/kaiterra/sensor.py b/homeassistant/components/kaiterra/sensor.py index d9500c7a000..1e4dd0cbbca 100644 --- a/homeassistant/components/kaiterra/sensor.py +++ b/homeassistant/components/kaiterra/sensor.py @@ -1,7 +1,7 @@ """Support for Kaiterra Temperature ahn Humidity Sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_DEVICE_ID, CONF_NAME, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from .const import DISPATCHER_KAITERRA, DOMAIN @@ -25,7 +25,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class KaiterraSensor(Entity): +class KaiterraSensor(SensorEntity): """Implementation of a Kaittera sensor.""" def __init__(self, api, name, device_id, sensor): diff --git a/homeassistant/components/keba/sensor.py b/homeassistant/components/keba/sensor.py index ed85ccd06a6..836785490e8 100644 --- a/homeassistant/components/keba/sensor.py +++ b/homeassistant/components/keba/sensor.py @@ -1,10 +1,10 @@ """Support for KEBA charging station sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_POWER, ELECTRICAL_CURRENT_AMPERE, ENERGY_KILO_WATT_HOUR, ) -from homeassistant.helpers.entity import Entity from . import DOMAIN @@ -62,7 +62,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors) -class KebaSensor(Entity): +class KebaSensor(SensorEntity): """The entity class for KEBA charging stations sensors.""" def __init__(self, keba, key, name, entity_type, icon, unit, device_class=None): diff --git a/homeassistant/components/kira/sensor.py b/homeassistant/components/kira/sensor.py index a8c49d1c04b..a6b1b9ada22 100644 --- a/homeassistant/components/kira/sensor.py +++ b/homeassistant/components/kira/sensor.py @@ -1,8 +1,8 @@ """KIRA interface to receive UDP packets from an IR-IP bridge.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_DEVICE, CONF_NAME, STATE_UNKNOWN -from homeassistant.helpers.entity import Entity from . import CONF_SENSOR, DOMAIN @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([KiraReceiver(device, kira)]) -class KiraReceiver(Entity): +class KiraReceiver(SensorEntity): """Implementation of a Kira Receiver.""" def __init__(self, name, kira): diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index f3155eebf01..4397f8bcc0b 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -5,7 +5,7 @@ from typing import Callable, Iterable from xknx.devices import Sensor as XknxSensor -from homeassistant.components.sensor import DEVICE_CLASSES +from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ( ConfigType, @@ -32,7 +32,7 @@ async def async_setup_platform( async_add_entities(entities) -class KNXSensor(KnxEntity, Entity): +class KNXSensor(KnxEntity, SensorEntity): """Representation of a KNX sensor.""" def __init__(self, device: XknxSensor) -> None: diff --git a/homeassistant/components/konnected/sensor.py b/homeassistant/components/konnected/sensor.py index dece8d06c87..18975bdb467 100644 --- a/homeassistant/components/konnected/sensor.py +++ b/homeassistant/components/konnected/sensor.py @@ -1,4 +1,5 @@ """Support for DHT and DS18B20 sensors attached to a Konnected device.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONF_DEVICES, CONF_NAME, @@ -12,7 +13,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from .const import DOMAIN as KONNECTED_DOMAIN, SIGNAL_DS18B20_NEW @@ -70,7 +70,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_dispatcher_connect(hass, SIGNAL_DS18B20_NEW, async_add_ds18b20) -class KonnectedSensor(Entity): +class KonnectedSensor(SensorEntity): """Represents a Konnected DHT Sensor.""" def __init__(self, device_id, data, sensor_type, addr=None, initial_state=None): diff --git a/homeassistant/components/kwb/sensor.py b/homeassistant/components/kwb/sensor.py index bd0430f9786..eb96b206653 100644 --- a/homeassistant/components/kwb/sensor.py +++ b/homeassistant/components/kwb/sensor.py @@ -2,7 +2,7 @@ from pykwb import kwb 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_HOST, @@ -11,7 +11,6 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity DEFAULT_RAW = False DEFAULT_NAME = "KWB" @@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class KWBSensor(Entity): +class KWBSensor(SensorEntity): """Representation of a KWB Easyfire sensor.""" def __init__(self, easyfire, sensor, client_name): diff --git a/homeassistant/components/lacrosse/sensor.py b/homeassistant/components/lacrosse/sensor.py index 35cdcecddba..32090797f11 100644 --- a/homeassistant/components/lacrosse/sensor.py +++ b/homeassistant/components/lacrosse/sensor.py @@ -6,7 +6,11 @@ import pylacrosse from serial import SerialException import voluptuous as vol -from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA +from homeassistant.components.sensor import ( + ENTITY_ID_FORMAT, + PLATFORM_SCHEMA, + SensorEntity, +) from homeassistant.const import ( CONF_DEVICE, CONF_ID, @@ -19,7 +23,7 @@ from homeassistant.const import ( ) from homeassistant.core import callback 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.event import async_track_point_in_utc_time from homeassistant.util import dt as dt_util @@ -108,7 +112,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class LaCrosseSensor(Entity): +class LaCrosseSensor(SensorEntity): """Implementation of a Lacrosse sensor.""" _temperature = None diff --git a/homeassistant/components/lastfm/sensor.py b/homeassistant/components/lastfm/sensor.py index 2f599ad37fd..128450826d6 100644 --- a/homeassistant/components/lastfm/sensor.py +++ b/homeassistant/components/lastfm/sensor.py @@ -7,10 +7,9 @@ import pylast as lastfm from pylast import WSError 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class LastfmSensor(Entity): +class LastfmSensor(SensorEntity): """A class for the Last.fm account.""" def __init__(self, user, lastfm_api): diff --git a/homeassistant/components/launch_library/sensor.py b/homeassistant/components/launch_library/sensor.py index 7663bf86fc5..831e44dca8f 100644 --- a/homeassistant/components/launch_library/sensor.py +++ b/homeassistant/components/launch_library/sensor.py @@ -7,11 +7,10 @@ import logging from pylaunches import PyLaunches, PyLaunchesException 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 from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from .const import ( ATTR_AGENCY, @@ -40,7 +39,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([LaunchLibrarySensor(launches, name)], True) -class LaunchLibrarySensor(Entity): +class LaunchLibrarySensor(SensorEntity): """Representation of a launch_library Sensor.""" def __init__(self, launches: PyLaunches, name: str) -> None: diff --git a/homeassistant/components/lcn/sensor.py b/homeassistant/components/lcn/sensor.py index 510df46cd1e..64870e22e4c 100644 --- a/homeassistant/components/lcn/sensor.py +++ b/homeassistant/components/lcn/sensor.py @@ -2,7 +2,7 @@ import pypck -from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR +from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR, SensorEntity from homeassistant.const import ( CONF_ADDRESS, CONF_DOMAIN, @@ -51,7 +51,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class LcnVariableSensor(LcnEntity): +class LcnVariableSensor(LcnEntity, SensorEntity): """Representation of a LCN sensor for variables.""" def __init__(self, config, entry_id, device_connection): @@ -99,7 +99,7 @@ class LcnVariableSensor(LcnEntity): self.async_write_ha_state() -class LcnLedLogicSensor(LcnEntity): +class LcnLedLogicSensor(LcnEntity, SensorEntity): """Representation of a LCN sensor for leds and logicops.""" def __init__(self, config, entry_id, device_connection): diff --git a/homeassistant/components/lightwave/sensor.py b/homeassistant/components/lightwave/sensor.py index 2144979106a..1128078f8bc 100644 --- a/homeassistant/components/lightwave/sensor.py +++ b/homeassistant/components/lightwave/sensor.py @@ -1,6 +1,6 @@ """Support for LightwaveRF TRV - Associated Battery.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE -from homeassistant.helpers.entity import Entity from . import CONF_SERIAL, LIGHTWAVE_LINK @@ -22,7 +22,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(batteries) -class LightwaveBattery(Entity): +class LightwaveBattery(SensorEntity): """Lightwave TRV Battery.""" def __init__(self, name, lwlink, serial): diff --git a/homeassistant/components/linux_battery/sensor.py b/homeassistant/components/linux_battery/sensor.py index feefa34a7a7..b7746392cee 100644 --- a/homeassistant/components/linux_battery/sensor.py +++ b/homeassistant/components/linux_battery/sensor.py @@ -5,10 +5,9 @@ import os from batinfo import Batteries import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ATTR_NAME, CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -68,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([LinuxBatterySensor(name, battery_id, system)], True) -class LinuxBatterySensor(Entity): +class LinuxBatterySensor(SensorEntity): """Representation of a Linux Battery sensor.""" def __init__(self, name, battery_id, system): diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index 8ae512fa801..8038fdbb2cb 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -3,8 +3,8 @@ from __future__ import annotations from pylitterbot.robot import Robot +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TIMESTAMP, PERCENTAGE -from homeassistant.helpers.entity import Entity from .const import DOMAIN from .hub import LitterRobotEntity, LitterRobotHub @@ -21,7 +21,7 @@ def icon_for_gauge_level(gauge_level: int | None = None, offset: int = 0) -> str return "mdi:gauge-low" -class LitterRobotPropertySensor(LitterRobotEntity, Entity): +class LitterRobotPropertySensor(LitterRobotEntity, SensorEntity): """Litter-Robot property sensors.""" def __init__( @@ -37,7 +37,7 @@ class LitterRobotPropertySensor(LitterRobotEntity, Entity): return getattr(self.robot, self.sensor_attribute) -class LitterRobotWasteSensor(LitterRobotPropertySensor, Entity): +class LitterRobotWasteSensor(LitterRobotPropertySensor): """Litter-Robot sensors.""" @property @@ -51,7 +51,7 @@ class LitterRobotWasteSensor(LitterRobotPropertySensor, Entity): return icon_for_gauge_level(self.state, 10) -class LitterRobotSleepTimeSensor(LitterRobotPropertySensor, Entity): +class LitterRobotSleepTimeSensor(LitterRobotPropertySensor): """Litter-Robot sleep time sensors.""" @property diff --git a/homeassistant/components/local_ip/sensor.py b/homeassistant/components/local_ip/sensor.py index d159b641fa2..1d2cce72105 100644 --- a/homeassistant/components/local_ip/sensor.py +++ b/homeassistant/components/local_ip/sensor.py @@ -1,7 +1,7 @@ """Sensor platform for local_ip.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME -from homeassistant.helpers.entity import Entity from homeassistant.util import get_local_ip from .const import DOMAIN, SENSOR @@ -13,7 +13,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities([IPSensor(name)], True) -class IPSensor(Entity): +class IPSensor(SensorEntity): """A simple sensor.""" def __init__(self, name): diff --git a/homeassistant/components/logi_circle/sensor.py b/homeassistant/components/logi_circle/sensor.py index 3d980b1dae3..29cd6e28e1c 100644 --- a/homeassistant/components/logi_circle/sensor.py +++ b/homeassistant/components/logi_circle/sensor.py @@ -1,6 +1,7 @@ """Support for Logi Circle sensors.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_BATTERY_CHARGING, @@ -9,7 +10,6 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.util.dt import as_local @@ -42,7 +42,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors, True) -class LogiSensor(Entity): +class LogiSensor(SensorEntity): """A sensor implementation for a Logi Circle camera.""" def __init__(self, camera, time_zone, sensor_type): diff --git a/homeassistant/components/london_air/sensor.py b/homeassistant/components/london_air/sensor.py index c39d77585a8..23eea5c00e0 100644 --- a/homeassistant/components/london_air/sensor.py +++ b/homeassistant/components/london_air/sensor.py @@ -5,10 +5,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 HTTP_OK 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 @@ class APIData: self.data = parse_api_response(response.json()) -class AirSensor(Entity): +class AirSensor(SensorEntity): """Single authority air sensor.""" ICON = "mdi:cloud-outline" diff --git a/homeassistant/components/london_underground/sensor.py b/homeassistant/components/london_underground/sensor.py index acb605901c9..b7f2cb50cbf 100644 --- a/homeassistant/components/london_underground/sensor.py +++ b/homeassistant/components/london_underground/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta from london_tube_status import TubeData 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTRIBUTION = "Powered by TfL Open Data" @@ -51,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class LondonTubeSensor(Entity): +class LondonTubeSensor(SensorEntity): """Sensor that reads the status of a line from Tube Data.""" def __init__(self, name, data): diff --git a/homeassistant/components/loopenergy/sensor.py b/homeassistant/components/loopenergy/sensor.py index 85494d354b5..78e55f22eb8 100644 --- a/homeassistant/components/loopenergy/sensor.py +++ b/homeassistant/components/loopenergy/sensor.py @@ -4,14 +4,13 @@ import logging import pyloopenergy import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, CONF_UNIT_SYSTEM_METRIC, EVENT_HOMEASSISTANT_STOP, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -82,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class LoopEnergyDevice(Entity): +class LoopEnergySensor(SensorEntity): """Implementation of an Loop Energy base sensor.""" def __init__(self, controller): @@ -116,7 +115,7 @@ class LoopEnergyDevice(Entity): self.schedule_update_ha_state(True) -class LoopEnergyElec(LoopEnergyDevice): +class LoopEnergyElec(LoopEnergySensor): """Implementation of an Loop Energy Electricity sensor.""" def __init__(self, controller): @@ -133,7 +132,7 @@ class LoopEnergyElec(LoopEnergyDevice): self._state = round(self._controller.electricity_useage, 2) -class LoopEnergyGas(LoopEnergyDevice): +class LoopEnergyGas(LoopEnergySensor): """Implementation of an Loop Energy Gas sensor.""" def __init__(self, controller): diff --git a/homeassistant/components/luftdaten/sensor.py b/homeassistant/components/luftdaten/sensor.py index 5985c63801e..aec77961b94 100644 --- a/homeassistant/components/luftdaten/sensor.py +++ b/homeassistant/components/luftdaten/sensor.py @@ -1,6 +1,7 @@ """Support for Luftdaten sensors.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_LATITUDE, @@ -9,7 +10,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from . import ( DATA_LUFTDATEN, @@ -45,7 +45,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors, True) -class LuftdatenSensor(Entity): +class LuftdatenSensor(SensorEntity): """Implementation of a Luftdaten sensor.""" def __init__(self, luftdaten, sensor_type, name, icon, unit, show): diff --git a/homeassistant/components/lyft/sensor.py b/homeassistant/components/lyft/sensor.py index 872281f685c..c979231a216 100644 --- a/homeassistant/components/lyft/sensor.py +++ b/homeassistant/components/lyft/sensor.py @@ -7,10 +7,9 @@ from lyft_rides.client import LyftRidesClient from lyft_rides.errors import APIError 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_CLIENT_SECRET, TIME_MINUTES import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class LyftSensor(Entity): +class LyftSensor(SensorEntity): """Implementation of an Lyft sensor.""" def __init__(self, sensorType, products, product_id, product): diff --git a/homeassistant/components/lyric/sensor.py b/homeassistant/components/lyric/sensor.py index c4950f119d9..db90f474124 100644 --- a/homeassistant/components/lyric/sensor.py +++ b/homeassistant/components/lyric/sensor.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta from aiolyric.objects.device import LyricDevice from aiolyric.objects.location import LyricLocation +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, @@ -67,7 +68,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class LyricSensor(LyricDeviceEntity): +class LyricSensor(LyricDeviceEntity, SensorEntity): """Defines a Honeywell Lyric sensor.""" def __init__( diff --git a/homeassistant/components/magicseaweed/sensor.py b/homeassistant/components/magicseaweed/sensor.py index 406f5e53955..0dd27a60ae0 100644 --- a/homeassistant/components/magicseaweed/sensor.py +++ b/homeassistant/components/magicseaweed/sensor.py @@ -5,7 +5,7 @@ import logging import magicseaweed 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, @@ -13,7 +13,6 @@ from homeassistant.const import ( CONF_NAME, ) 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 @@ -90,7 +89,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class MagicSeaweedSensor(Entity): +class MagicSeaweedSensor(SensorEntity): """Implementation of a MagicSeaweed sensor.""" def __init__(self, forecast_data, sensor_type, name, unit_system, hour=None): diff --git a/homeassistant/components/mazda/sensor.py b/homeassistant/components/mazda/sensor.py index a05291673e8..7382347e6de 100644 --- a/homeassistant/components/mazda/sensor.py +++ b/homeassistant/components/mazda/sensor.py @@ -1,4 +1,5 @@ """Platform for Mazda sensor integration.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_KILOMETERS, @@ -29,7 +30,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class MazdaFuelRemainingSensor(MazdaEntity): +class MazdaFuelRemainingSensor(MazdaEntity, SensorEntity): """Class for the fuel remaining sensor.""" @property @@ -59,7 +60,7 @@ class MazdaFuelRemainingSensor(MazdaEntity): return self.coordinator.data[self.index]["status"]["fuelRemainingPercent"] -class MazdaFuelDistanceSensor(MazdaEntity): +class MazdaFuelDistanceSensor(MazdaEntity, SensorEntity): """Class for the fuel distance sensor.""" @property @@ -100,7 +101,7 @@ class MazdaFuelDistanceSensor(MazdaEntity): ) -class MazdaOdometerSensor(MazdaEntity): +class MazdaOdometerSensor(MazdaEntity, SensorEntity): """Class for the odometer sensor.""" @property @@ -137,7 +138,7 @@ class MazdaOdometerSensor(MazdaEntity): ) -class MazdaFrontLeftTirePressureSensor(MazdaEntity): +class MazdaFrontLeftTirePressureSensor(MazdaEntity, SensorEntity): """Class for the front left tire pressure sensor.""" @property @@ -170,7 +171,7 @@ class MazdaFrontLeftTirePressureSensor(MazdaEntity): return None if tire_pressure is None else round(tire_pressure) -class MazdaFrontRightTirePressureSensor(MazdaEntity): +class MazdaFrontRightTirePressureSensor(MazdaEntity, SensorEntity): """Class for the front right tire pressure sensor.""" @property @@ -203,7 +204,7 @@ class MazdaFrontRightTirePressureSensor(MazdaEntity): return None if tire_pressure is None else round(tire_pressure) -class MazdaRearLeftTirePressureSensor(MazdaEntity): +class MazdaRearLeftTirePressureSensor(MazdaEntity, SensorEntity): """Class for the rear left tire pressure sensor.""" @property @@ -236,7 +237,7 @@ class MazdaRearLeftTirePressureSensor(MazdaEntity): return None if tire_pressure is None else round(tire_pressure) -class MazdaRearRightTirePressureSensor(MazdaEntity): +class MazdaRearRightTirePressureSensor(MazdaEntity, SensorEntity): """Class for the rear right tire pressure sensor.""" @property diff --git a/homeassistant/components/melcloud/sensor.py b/homeassistant/components/melcloud/sensor.py index bd85d1b13bc..356992ece11 100644 --- a/homeassistant/components/melcloud/sensor.py +++ b/homeassistant/components/melcloud/sensor.py @@ -2,6 +2,7 @@ from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW from pymelcloud.atw_device import Zone +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_ICON, @@ -9,7 +10,6 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS, ) -from homeassistant.helpers.entity import Entity from . import MelCloudDevice from .const import DOMAIN @@ -110,7 +110,7 @@ async def async_setup_entry(hass, entry, async_add_entities): ) -class MelDeviceSensor(Entity): +class MelDeviceSensor(SensorEntity): """Representation of a Sensor.""" def __init__(self, api: MelCloudDevice, measurement, definition): diff --git a/homeassistant/components/meteo_france/sensor.py b/homeassistant/components/meteo_france/sensor.py index 74b4ab5a6d1..b6ec221a97e 100644 --- a/homeassistant/components/meteo_france/sensor.py +++ b/homeassistant/components/meteo_france/sensor.py @@ -6,6 +6,7 @@ from meteofrance_api.helpers import ( readeable_phenomenoms_dict, ) +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.helpers.typing import HomeAssistantType @@ -74,7 +75,7 @@ async def async_setup_entry( ) -class MeteoFranceSensor(CoordinatorEntity): +class MeteoFranceSensor(CoordinatorEntity, SensorEntity): """Representation of a Meteo-France sensor.""" def __init__(self, sensor_type: str, coordinator: DataUpdateCoordinator): diff --git a/homeassistant/components/metoffice/sensor.py b/homeassistant/components/metoffice/sensor.py index 2f4dd72b3a1..6a7cf5254a6 100644 --- a/homeassistant/components/metoffice/sensor.py +++ b/homeassistant/components/metoffice/sensor.py @@ -1,4 +1,5 @@ """Support for UK Met Office weather service.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, DEVICE_CLASS_HUMIDITY, @@ -10,7 +11,6 @@ from homeassistant.const import ( UV_INDEX, ) from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ConfigType, HomeAssistantType from .const import ( @@ -92,7 +92,7 @@ async def async_setup_entry( ) -class MetOfficeCurrentSensor(Entity): +class MetOfficeCurrentSensor(SensorEntity): """Implementation of a Met Office current weather condition sensor.""" def __init__(self, entry_data, hass_data, sensor_type): diff --git a/homeassistant/components/mfi/sensor.py b/homeassistant/components/mfi/sensor.py index 671a52bbf01..c7a64f17bd6 100644 --- a/homeassistant/components/mfi/sensor.py +++ b/homeassistant/components/mfi/sensor.py @@ -5,7 +5,7 @@ from mficlient.client import FailedToLogin, MFiClient 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_HOST, CONF_PASSWORD, @@ -18,7 +18,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class MfiSensor(Entity): +class MfiSensor(SensorEntity): """Representation of a mFi sensor.""" def __init__(self, port, hass): diff --git a/homeassistant/components/mhz19/sensor.py b/homeassistant/components/mhz19/sensor.py index f26481f9d25..0f0735dd5da 100644 --- a/homeassistant/components/mhz19/sensor.py +++ b/homeassistant/components/mhz19/sensor.py @@ -5,7 +5,7 @@ import logging from pmsensor import co2sensor import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_TEMPERATURE, CONCENTRATION_PARTS_PER_MILLION, @@ -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 @@ -69,7 +68,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return True -class MHZ19Sensor(Entity): +class MHZ19Sensor(SensorEntity): """Representation of an CO2 sensor.""" def __init__(self, mhz_client, sensor_type, temp_unit, name): diff --git a/homeassistant/components/miflora/sensor.py b/homeassistant/components/miflora/sensor.py index 8db81ecf5dd..0c22a943bb3 100644 --- a/homeassistant/components/miflora/sensor.py +++ b/homeassistant/components/miflora/sensor.py @@ -8,7 +8,7 @@ from btlewrap import BluetoothBackendException from miflora import miflora_poller import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONDUCTIVITY, CONF_FORCE_UPDATE, @@ -27,7 +27,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util from homeassistant.util.temperature import celsius_to_fahrenheit @@ -130,7 +129,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(devs) -class MiFloraSensor(Entity): +class MiFloraSensor(SensorEntity): """Implementing the MiFlora sensor.""" def __init__( diff --git a/homeassistant/components/min_max/sensor.py b/homeassistant/components/min_max/sensor.py index 5bea9379690..a42291b3f67 100644 --- a/homeassistant/components/min_max/sensor.py +++ b/homeassistant/components/min_max/sensor.py @@ -3,7 +3,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, @@ -13,7 +13,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.reload import async_setup_reload_service @@ -131,7 +130,7 @@ def calc_median(sensor_values, round_digits): return round(median, round_digits) -class MinMaxSensor(Entity): +class MinMaxSensor(SensorEntity): """Representation of a min/max sensor.""" def __init__(self, entity_ids, name, sensor_type, round_digits): diff --git a/homeassistant/components/minecraft_server/sensor.py b/homeassistant/components/minecraft_server/sensor.py index 4cc9e9746bb..ded21f2935f 100644 --- a/homeassistant/components/minecraft_server/sensor.py +++ b/homeassistant/components/minecraft_server/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import TIME_MILLISECONDS from homeassistant.helpers.typing import HomeAssistantType @@ -47,7 +48,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class MinecraftServerSensorEntity(MinecraftServerEntity): +class MinecraftServerSensorEntity(MinecraftServerEntity, SensorEntity): """Representation of a Minecraft Server sensor base entity.""" def __init__( diff --git a/homeassistant/components/mitemp_bt/sensor.py b/homeassistant/components/mitemp_bt/sensor.py index 244a0c410d5..670a6daf3d3 100644 --- a/homeassistant/components/mitemp_bt/sensor.py +++ b/homeassistant/components/mitemp_bt/sensor.py @@ -6,7 +6,7 @@ from btlewrap.base import BluetoothBackendException from mitemp_bt import mitemp_bt_poller import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_FORCE_UPDATE, CONF_MAC, @@ -20,7 +20,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity try: import bluepy.btle # noqa: F401 pylint: disable=unused-import @@ -104,7 +103,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs) -class MiTempBtSensor(Entity): +class MiTempBtSensor(SensorEntity): """Implementing the MiTempBt sensor.""" def __init__(self, poller, parameter, device, name, unit, force_update, median): diff --git a/homeassistant/components/mobile_app/sensor.py b/homeassistant/components/mobile_app/sensor.py index b09ef86453b..3f4c7d56f3f 100644 --- a/homeassistant/components/mobile_app/sensor.py +++ b/homeassistant/components/mobile_app/sensor.py @@ -1,6 +1,7 @@ """Sensor platform for mobile_app.""" from functools import partial +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME, CONF_UNIQUE_ID, CONF_WEBHOOK_ID from homeassistant.core import callback from homeassistant.helpers import entity_registry as er @@ -71,7 +72,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class MobileAppSensor(MobileAppEntity): +class MobileAppSensor(MobileAppEntity, SensorEntity): """Representation of an mobile app sensor.""" @property diff --git a/homeassistant/components/modbus/sensor.py b/homeassistant/components/modbus/sensor.py index d0fad973802..c1f5487bd5d 100644 --- a/homeassistant/components/modbus/sensor.py +++ b/homeassistant/components/modbus/sensor.py @@ -9,7 +9,11 @@ from pymodbus.exceptions import ConnectionException, ModbusException from pymodbus.pdu import ExceptionResponse import voluptuous as vol -from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA, PLATFORM_SCHEMA +from homeassistant.components.sensor import ( + DEVICE_CLASSES_SCHEMA, + PLATFORM_SCHEMA, + SensorEntity, +) from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_NAME, @@ -158,7 +162,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class ModbusRegisterSensor(RestoreEntity): +class ModbusRegisterSensor(RestoreEntity, SensorEntity): """Modbus register sensor.""" def __init__( diff --git a/homeassistant/components/modem_callerid/sensor.py b/homeassistant/components/modem_callerid/sensor.py index f91b6d7a169..080e077a457 100644 --- a/homeassistant/components/modem_callerid/sensor.py +++ b/homeassistant/components/modem_callerid/sensor.py @@ -4,7 +4,7 @@ import logging from basicmodem.basicmodem import BasicModem as bm 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, @@ -12,7 +12,6 @@ from homeassistant.const import ( STATE_IDLE, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Modem CallerID" @@ -44,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([ModemCalleridSensor(hass, name, port, modem)]) -class ModemCalleridSensor(Entity): +class ModemCalleridSensor(SensorEntity): """Implementation of USB modem caller ID sensor.""" def __init__(self, hass, name, port, modem): diff --git a/homeassistant/components/mold_indicator/sensor.py b/homeassistant/components/mold_indicator/sensor.py index 126b57cb412..7bfa161f9ec 100644 --- a/homeassistant/components/mold_indicator/sensor.py +++ b/homeassistant/components/mold_indicator/sensor.py @@ -5,7 +5,7 @@ import math import voluptuous as vol from homeassistant import util -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, @@ -17,7 +17,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change_event _LOGGER = logging.getLogger(__name__) @@ -69,7 +68,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class MoldIndicator(Entity): +class MoldIndicator(SensorEntity): """Represents a MoldIndication sensor.""" def __init__( diff --git a/homeassistant/components/moon/sensor.py b/homeassistant/components/moon/sensor.py index 9e0f8ef51d6..4b373469cc6 100644 --- a/homeassistant/components/moon/sensor.py +++ b/homeassistant/components/moon/sensor.py @@ -2,10 +2,9 @@ from astral import Astral 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 import homeassistant.util.dt as dt_util DEFAULT_NAME = "Moon" @@ -42,7 +41,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([MoonSensor(name)], True) -class MoonSensor(Entity): +class MoonSensor(SensorEntity): """Representation of a Moon sensor.""" def __init__(self, name): diff --git a/homeassistant/components/motion_blinds/sensor.py b/homeassistant/components/motion_blinds/sensor.py index 9f80c85b959..5d7a29bf9da 100644 --- a/homeassistant/components/motion_blinds/sensor.py +++ b/homeassistant/components/motion_blinds/sensor.py @@ -1,13 +1,13 @@ """Support for Motion Blinds sensors.""" from motionblinds import BlindType +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_SIGNAL_STRENGTH, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, ) -from homeassistant.helpers.entity import Entity from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY @@ -39,7 +39,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class MotionBatterySensor(CoordinatorEntity, Entity): +class MotionBatterySensor(CoordinatorEntity, SensorEntity): """ Representation of a Motion Battery Sensor. @@ -144,7 +144,7 @@ class MotionTDBUBatterySensor(MotionBatterySensor): return attributes -class MotionSignalStrengthSensor(CoordinatorEntity, Entity): +class MotionSignalStrengthSensor(CoordinatorEntity, SensorEntity): """Representation of a Motion Signal Strength Sensor.""" def __init__(self, coordinator, device, device_type): diff --git a/homeassistant/components/mqtt/sensor.py b/homeassistant/components/mqtt/sensor.py index b20595922cd..65c9e0550e0 100644 --- a/homeassistant/components/mqtt/sensor.py +++ b/homeassistant/components/mqtt/sensor.py @@ -7,7 +7,7 @@ import functools import voluptuous as vol from homeassistant.components import sensor -from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA +from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA, SensorEntity from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_FORCE_UPDATE, @@ -17,7 +17,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback 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.reload import async_setup_reload_service from homeassistant.helpers.typing import ConfigType, HomeAssistantType @@ -71,7 +70,7 @@ async def _async_setup_entity( async_add_entities([MqttSensor(hass, config, config_entry, discovery_data)]) -class MqttSensor(MqttEntity, Entity): +class MqttSensor(MqttEntity, SensorEntity): """Representation of a sensor that can be updated using MQTT.""" def __init__(self, hass, config, config_entry, discovery_data): diff --git a/homeassistant/components/mqtt_room/sensor.py b/homeassistant/components/mqtt_room/sensor.py index e15dfd179da..e446ab8ba7a 100644 --- a/homeassistant/components/mqtt_room/sensor.py +++ b/homeassistant/components/mqtt_room/sensor.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.components import mqtt from homeassistant.components.mqtt import CONF_STATE_TOPIC -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_DEVICE_ID, ATTR_ID, @@ -18,7 +18,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import dt, slugify _LOGGER = logging.getLogger(__name__) @@ -71,7 +70,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class MQTTRoomSensor(Entity): +class MQTTRoomSensor(SensorEntity): """Representation of a room sensor that is updated via MQTT.""" def __init__(self, name, state_topic, device_id, timeout, consider_home): diff --git a/homeassistant/components/mvglive/sensor.py b/homeassistant/components/mvglive/sensor.py index 15b0d2d218e..16b061a3346 100644 --- a/homeassistant/components/mvglive/sensor.py +++ b/homeassistant/components/mvglive/sensor.py @@ -6,10 +6,9 @@ import logging import MVGLive 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -78,7 +77,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class MVGLiveSensor(Entity): +class MVGLiveSensor(SensorEntity): """Implementation of an MVG Live sensor.""" def __init__( diff --git a/homeassistant/components/mychevy/sensor.py b/homeassistant/components/mychevy/sensor.py index 832f1a03f25..18b5e95d838 100644 --- a/homeassistant/components/mychevy/sensor.py +++ b/homeassistant/components/mychevy/sensor.py @@ -1,10 +1,9 @@ """Support for MyChevy sensors.""" import logging -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity from homeassistant.const import PERCENTAGE from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.util import slugify @@ -46,7 +45,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class MyChevyStatus(Entity): +class MyChevyStatus(SensorEntity): """A string representing the charge mode.""" _name = "MyChevy Status" @@ -109,7 +108,7 @@ class MyChevyStatus(Entity): return False -class EVSensor(Entity): +class EVSensor(SensorEntity): """Base EVSensor class. The only real difference between sensors is which units and what diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index a09f8af1394..a62318aea53 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -4,7 +4,7 @@ from typing import Callable from homeassistant.components import mysensors from homeassistant.components.mysensors import on_unload from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONDUCTIVITY, @@ -87,7 +87,7 @@ async def async_setup_entry( ) -class MySensorsSensor(mysensors.device.MySensorsEntity): +class MySensorsSensor(mysensors.device.MySensorsEntity, SensorEntity): """Representation of a MySensors Sensor child node.""" @property