From 64bc9a81965904040ceb3a3b25b1202212167a72 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 19:54:14 +0100 Subject: [PATCH] Migrate integrations r-s to extend SensorEntity (#48215) --- homeassistant/components/radarr/sensor.py | 5 ++--- homeassistant/components/rainbird/sensor.py | 4 ++-- homeassistant/components/raincloud/sensor.py | 4 ++-- homeassistant/components/rainforest_eagle/sensor.py | 7 +++---- homeassistant/components/rainmachine/sensor.py | 3 ++- homeassistant/components/random/sensor.py | 5 ++--- homeassistant/components/recollect_waste/sensor.py | 4 ++-- homeassistant/components/reddit/sensor.py | 5 ++--- homeassistant/components/rejseplanen/sensor.py | 5 ++--- homeassistant/components/repetier/sensor.py | 4 ++-- homeassistant/components/rest/sensor.py | 8 ++++++-- homeassistant/components/rflink/sensor.py | 4 ++-- homeassistant/components/rfxtrx/sensor.py | 3 ++- homeassistant/components/ring/sensor.py | 4 ++-- homeassistant/components/ripple/sensor.py | 5 ++--- homeassistant/components/risco/sensor.py | 3 ++- homeassistant/components/rmvtransport/sensor.py | 5 ++--- homeassistant/components/roomba/sensor.py | 3 ++- homeassistant/components/rova/sensor.py | 5 ++--- homeassistant/components/rtorrent/sensor.py | 5 ++--- homeassistant/components/sabnzbd/sensor.py | 4 ++-- homeassistant/components/saj/sensor.py | 5 ++--- homeassistant/components/scrape/sensor.py | 5 ++--- homeassistant/components/screenlogic/sensor.py | 10 +++++++--- homeassistant/components/season/sensor.py | 5 ++--- homeassistant/components/sense/sensor.py | 10 +++++----- homeassistant/components/sensehat/sensor.py | 5 ++--- homeassistant/components/serial/sensor.py | 5 ++--- homeassistant/components/serial_pm/sensor.py | 5 ++--- homeassistant/components/seventeentrack/sensor.py | 7 +++---- homeassistant/components/shelly/sensor.py | 7 ++++--- homeassistant/components/shodan/sensor.py | 5 ++--- homeassistant/components/sht31/sensor.py | 5 ++--- homeassistant/components/sigfox/sensor.py | 5 ++--- homeassistant/components/simplisafe/sensor.py | 3 ++- homeassistant/components/simulated/sensor.py | 5 ++--- homeassistant/components/skybeacon/sensor.py | 9 ++++----- homeassistant/components/skybell/sensor.py | 4 ++-- homeassistant/components/sleepiq/sensor.py | 4 +++- homeassistant/components/sma/sensor.py | 5 ++--- homeassistant/components/smappee/sensor.py | 4 ++-- homeassistant/components/smart_meter_texas/sensor.py | 3 ++- homeassistant/components/smartthings/sensor.py | 5 +++-- homeassistant/components/smarttub/sensor.py | 4 +++- homeassistant/components/smarty/sensor.py | 4 ++-- homeassistant/components/sms/sensor.py | 4 ++-- homeassistant/components/snmp/sensor.py | 5 ++--- homeassistant/components/sochain/sensor.py | 5 ++--- homeassistant/components/socialblade/sensor.py | 5 ++--- homeassistant/components/solaredge/sensor.py | 4 ++-- homeassistant/components/solaredge_local/sensor.py | 5 ++--- homeassistant/components/solarlog/sensor.py | 4 ++-- homeassistant/components/solax/sensor.py | 5 ++--- homeassistant/components/soma/sensor.py | 4 ++-- homeassistant/components/somfy/sensor.py | 3 ++- homeassistant/components/sonarr/sensor.py | 3 ++- homeassistant/components/speedtestdotnet/sensor.py | 3 ++- homeassistant/components/spotcrime/sensor.py | 5 ++--- homeassistant/components/sql/sensor.py | 5 ++--- homeassistant/components/srp_energy/sensor.py | 4 ++-- homeassistant/components/starline/sensor.py | 5 ++--- homeassistant/components/starlingbank/sensor.py | 5 ++--- homeassistant/components/startca/sensor.py | 5 ++--- homeassistant/components/statistics/sensor.py | 5 ++--- homeassistant/components/steam_online/sensor.py | 5 ++--- homeassistant/components/streamlabswater/sensor.py | 4 ++-- homeassistant/components/subaru/sensor.py | 4 ++-- homeassistant/components/suez_water/sensor.py | 5 ++--- homeassistant/components/supervisord/sensor.py | 5 ++--- homeassistant/components/surepetcare/sensor.py | 4 ++-- .../components/swiss_hydrological_data/sensor.py | 5 ++--- .../components/swiss_public_transport/sensor.py | 5 ++--- homeassistant/components/syncthru/sensor.py | 5 ++--- homeassistant/components/synology_dsm/sensor.py | 7 ++++--- homeassistant/components/systemmonitor/sensor.py | 5 ++--- 75 files changed, 173 insertions(+), 189 deletions(-) diff --git a/homeassistant/components/radarr/sensor.py b/homeassistant/components/radarr/sensor.py index 9baed6c41c7..542ff285261 100644 --- a/homeassistant/components/radarr/sensor.py +++ b/homeassistant/components/radarr/sensor.py @@ -7,7 +7,7 @@ from pytz import timezone 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_HOST, @@ -26,7 +26,6 @@ from homeassistant.const import ( HTTP_OK, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -95,7 +94,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([RadarrSensor(hass, config, sensor) for sensor in conditions], True) -class RadarrSensor(Entity): +class RadarrSensor(SensorEntity): """Implementation of the Radarr sensor.""" def __init__(self, hass, conf, sensor_type): diff --git a/homeassistant/components/rainbird/sensor.py b/homeassistant/components/rainbird/sensor.py index 501566de682..2c542dc12a9 100644 --- a/homeassistant/components/rainbird/sensor.py +++ b/homeassistant/components/rainbird/sensor.py @@ -3,7 +3,7 @@ import logging from pyrainbird import RainbirdController -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from . import ( DATA_RAINBIRD, @@ -28,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class RainBirdSensor(Entity): +class RainBirdSensor(SensorEntity): """A sensor implementation for Rain Bird device.""" def __init__(self, controller: RainbirdController, sensor_type): diff --git a/homeassistant/components/raincloud/sensor.py b/homeassistant/components/raincloud/sensor.py index b819b51365e..efff3677009 100644 --- a/homeassistant/components/raincloud/sensor.py +++ b/homeassistant/components/raincloud/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 CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv from homeassistant.helpers.icon import icon_for_battery_level @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return True -class RainCloudSensor(RainCloudEntity): +class RainCloudSensor(RainCloudEntity, SensorEntity): """A sensor implementation for raincloud device.""" @property diff --git a/homeassistant/components/rainforest_eagle/sensor.py b/homeassistant/components/rainforest_eagle/sensor.py index 99751e63f5b..80475b4c21b 100644 --- a/homeassistant/components/rainforest_eagle/sensor.py +++ b/homeassistant/components/rainforest_eagle/sensor.py @@ -7,14 +7,13 @@ from requests.exceptions import ConnectionError as ConnectError, HTTPError, Time from uEagle import Eagle as LegacyReader 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, DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle CONF_CLOUD_ID = "cloud_id" @@ -95,7 +94,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class EagleSensor(Entity): +class EagleSensor(SensorEntity): """Implementation of the Rainforest Eagle-200 sensor.""" def __init__(self, eagle_data, sensor_type, name, unit): @@ -160,7 +159,7 @@ class EagleData: return state -class LeagleReader(LegacyReader): +class LeagleReader(LegacyReader, SensorEntity): """Wraps uEagle to make it behave like eagle_reader, offering update().""" def update(self): diff --git a/homeassistant/components/rainmachine/sensor.py b/homeassistant/components/rainmachine/sensor.py index 4533397fb54..20912809cb1 100644 --- a/homeassistant/components/rainmachine/sensor.py +++ b/homeassistant/components/rainmachine/sensor.py @@ -4,6 +4,7 @@ from typing import Callable from regenmaschine.controller import Controller +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS, VOLUME_CUBIC_METERS from homeassistant.core import HomeAssistant, callback @@ -108,7 +109,7 @@ async def async_setup_entry( ) -class RainMachineSensor(RainMachineEntity): +class RainMachineSensor(RainMachineEntity, SensorEntity): """Define a general RainMachine sensor.""" def __init__( diff --git a/homeassistant/components/random/sensor.py b/homeassistant/components/random/sensor.py index 7584fe17405..6465b828be1 100644 --- a/homeassistant/components/random/sensor.py +++ b/homeassistant/components/random/sensor.py @@ -3,7 +3,7 @@ from random import randrange import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_MAXIMUM, CONF_MINIMUM, @@ -11,7 +11,6 @@ from homeassistant.const import ( CONF_UNIT_OF_MEASUREMENT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTR_MAXIMUM = "maximum" ATTR_MINIMUM = "minimum" @@ -42,7 +41,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([RandomSensor(name, minimum, maximum, unit)], True) -class RandomSensor(Entity): +class RandomSensor(SensorEntity): """Representation of a Random number sensor.""" def __init__(self, name, minimum, maximum, unit_of_measurement): diff --git a/homeassistant/components/recollect_waste/sensor.py b/homeassistant/components/recollect_waste/sensor.py index 000d76b54c7..1c3dabc2c87 100644 --- a/homeassistant/components/recollect_waste/sensor.py +++ b/homeassistant/components/recollect_waste/sensor.py @@ -6,7 +6,7 @@ from typing import Callable from aiorecollect.client import PickupType 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 ATTR_ATTRIBUTION, CONF_FRIENDLY_NAME, CONF_NAME from homeassistant.core import HomeAssistant, callback @@ -77,7 +77,7 @@ async def async_setup_entry( async_add_entities([ReCollectWasteSensor(coordinator, entry)]) -class ReCollectWasteSensor(CoordinatorEntity): +class ReCollectWasteSensor(CoordinatorEntity, SensorEntity): """ReCollect Waste Sensor.""" def __init__(self, coordinator: DataUpdateCoordinator, entry: ConfigEntry) -> None: diff --git a/homeassistant/components/reddit/sensor.py b/homeassistant/components/reddit/sensor.py index 153b6636cc4..a88de916009 100644 --- a/homeassistant/components/reddit/sensor.py +++ b/homeassistant/components/reddit/sensor.py @@ -5,7 +5,7 @@ import logging import praw import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ID, CONF_CLIENT_ID, @@ -15,7 +15,6 @@ from homeassistant.const import ( CONF_USERNAME, ) 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, True) -class RedditSensor(Entity): +class RedditSensor(SensorEntity): """Representation of a Reddit sensor.""" def __init__(self, reddit, subreddit: str, limit: int, sort_by: str): diff --git a/homeassistant/components/rejseplanen/sensor.py b/homeassistant/components/rejseplanen/sensor.py index ea55d56b8df..685dc548338 100644 --- a/homeassistant/components/rejseplanen/sensor.py +++ b/homeassistant/components/rejseplanen/sensor.py @@ -11,10 +11,9 @@ from operator import itemgetter import rjpl 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 import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -87,7 +86,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ) -class RejseplanenTransportSensor(Entity): +class RejseplanenTransportSensor(SensorEntity): """Implementation of Rejseplanen transport sensor.""" def __init__(self, data, stop_id, route, direction, name): diff --git a/homeassistant/components/repetier/sensor.py b/homeassistant/components/repetier/sensor.py index a2b86792aa7..77a3c51e9cf 100644 --- a/homeassistant/components/repetier/sensor.py +++ b/homeassistant/components/repetier/sensor.py @@ -3,10 +3,10 @@ from datetime import datetime import logging import time +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TIMESTAMP from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from . import REPETIER_API, SENSOR_TYPES, UPDATE_SIGNAL @@ -46,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class RepetierSensor(Entity): +class RepetierSensor(SensorEntity): """Class to create and populate a Repetier Sensor.""" def __init__(self, api, temp_id, name, printer_id, sensor_type): diff --git a/homeassistant/components/rest/sensor.py b/homeassistant/components/rest/sensor.py index 5ff5e87c3e6..d303f7a57b3 100644 --- a/homeassistant/components/rest/sensor.py +++ b/homeassistant/components/rest/sensor.py @@ -7,7 +7,11 @@ from jsonpath import jsonpath import voluptuous as vol import xmltodict -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, PLATFORM_SCHEMA +from homeassistant.components.sensor import ( + DOMAIN as SENSOR_DOMAIN, + PLATFORM_SCHEMA, + SensorEntity, +) from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_FORCE_UPDATE, @@ -81,7 +85,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class RestSensor(RestEntity): +class RestSensor(RestEntity, SensorEntity): """Implementation of a REST sensor.""" def __init__( diff --git a/homeassistant/components/rflink/sensor.py b/homeassistant/components/rflink/sensor.py index 1a616c2ed90..497c9b8cee6 100644 --- a/homeassistant/components/rflink/sensor.py +++ b/homeassistant/components/rflink/sensor.py @@ -2,7 +2,7 @@ from rflink.parser import PACKET_FIELDS, UNITS 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_DEVICES, @@ -98,7 +98,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= hass.data[DATA_DEVICE_REGISTER][EVENT_KEY_SENSOR] = add_new_device -class RflinkSensor(RflinkDevice): +class RflinkSensor(RflinkDevice, SensorEntity): """Representation of a Rflink sensor.""" def __init__( diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index c897e164119..72cd9f6bbf6 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -8,6 +8,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_TEMPERATURE, + SensorEntity, ) from homeassistant.const import ( CONF_DEVICES, @@ -129,7 +130,7 @@ async def async_setup_entry( connect_auto_add(hass, discovery_info, sensor_update) -class RfxtrxSensor(RfxtrxEntity): +class RfxtrxSensor(RfxtrxEntity, SensorEntity): """Representation of a RFXtrx sensor.""" def __init__(self, device, device_id, data_type, event=None): diff --git a/homeassistant/components/ring/sensor.py b/homeassistant/components/ring/sensor.py index 276d3839438..a20d484d3fe 100644 --- a/homeassistant/components/ring/sensor.py +++ b/homeassistant/components/ring/sensor.py @@ -1,7 +1,7 @@ """This component provides HA sensor support for Ring Door Bell/Chimes.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level from . import DOMAIN @@ -32,7 +32,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors) -class RingSensor(RingEntityMixin, Entity): +class RingSensor(RingEntityMixin, SensorEntity): """A sensor implementation for Ring device.""" def __init__(self, config_entry_id, device, sensor_type): diff --git a/homeassistant/components/ripple/sensor.py b/homeassistant/components/ripple/sensor.py index 97cf8b4a794..f36e2c58ec8 100644 --- a/homeassistant/components/ripple/sensor.py +++ b/homeassistant/components/ripple/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta from pyripple 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTRIBUTION = "Data provided by ripple.com" @@ -31,7 +30,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([RippleSensor(name, address)], True) -class RippleSensor(Entity): +class RippleSensor(SensorEntity): """Representation of an Ripple.com sensor.""" def __init__(self, name, address): diff --git a/homeassistant/components/risco/sensor.py b/homeassistant/components/risco/sensor.py index 846444e5fbd..b39655949b2 100644 --- a/homeassistant/components/risco/sensor.py +++ b/homeassistant/components/risco/sensor.py @@ -1,5 +1,6 @@ """Sensor for Risco Events.""" from homeassistant.components.binary_sensor import DOMAIN as BS_DOMAIN +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TIMESTAMP from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -42,7 +43,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors) -class RiscoSensor(CoordinatorEntity): +class RiscoSensor(CoordinatorEntity, SensorEntity): """Sensor for Risco events.""" def __init__(self, coordinator, category_id, excludes, name, entry_id) -> None: diff --git a/homeassistant/components/rmvtransport/sensor.py b/homeassistant/components/rmvtransport/sensor.py index 555f545d0c7..d85dae53303 100644 --- a/homeassistant/components/rmvtransport/sensor.py +++ b/homeassistant/components/rmvtransport/sensor.py @@ -10,11 +10,10 @@ from RMVtransport.rmvtransport import ( ) 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, CONF_TIMEOUT, TIME_MINUTES 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__) @@ -104,7 +103,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors) -class RMVDepartureSensor(Entity): +class RMVDepartureSensor(SensorEntity): """Implementation of an RMV departure sensor.""" def __init__( diff --git a/homeassistant/components/roomba/sensor.py b/homeassistant/components/roomba/sensor.py index f2d08f08772..4a99d9f71af 100644 --- a/homeassistant/components/roomba/sensor.py +++ b/homeassistant/components/roomba/sensor.py @@ -1,4 +1,5 @@ """Sensor for checking the battery level of Roomba.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.components.vacuum import STATE_DOCKED from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.helpers.icon import icon_for_battery_level @@ -16,7 +17,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities([roomba_vac], True) -class RoombaBattery(IRobotEntity): +class RoombaBattery(IRobotEntity, SensorEntity): """Class to hold Roomba Sensor basic info.""" @property diff --git a/homeassistant/components/rova/sensor.py b/homeassistant/components/rova/sensor.py index a2dafae9317..13f8fffb8d1 100644 --- a/homeassistant/components/rova/sensor.py +++ b/homeassistant/components/rova/sensor.py @@ -7,14 +7,13 @@ from requests.exceptions import ConnectTimeout, HTTPError from rova.rova import Rova 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, DEVICE_CLASS_TIMESTAMP, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle # Config for rova requests. @@ -80,7 +79,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class RovaSensor(Entity): +class RovaSensor(SensorEntity): """Representation of a Rova sensor.""" def __init__(self, platform_name, sensor_key, data_service): diff --git a/homeassistant/components/rtorrent/sensor.py b/homeassistant/components/rtorrent/sensor.py index 3976d8985cd..4c02f49d86a 100644 --- a/homeassistant/components/rtorrent/sensor.py +++ b/homeassistant/components/rtorrent/sensor.py @@ -4,7 +4,7 @@ import xmlrpc.client 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, @@ -14,7 +14,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__) @@ -75,7 +74,7 @@ def format_speed(speed): return round(kb_spd, 2 if kb_spd < 0.1 else 1) -class RTorrentSensor(Entity): +class RTorrentSensor(SensorEntity): """Representation of an rtorrent sensor.""" def __init__(self, sensor_type, rtorrent_client, client_name): diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py index 5e437c41b23..c0930f2c114 100644 --- a/homeassistant/components/sabnzbd/sensor.py +++ b/homeassistant/components/sabnzbd/sensor.py @@ -1,6 +1,6 @@ """Support for monitoring an SABnzbd NZB client.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from . import DATA_SABNZBD, SENSOR_TYPES, SIGNAL_SABNZBD_UPDATED @@ -18,7 +18,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class SabnzbdSensor(Entity): +class SabnzbdSensor(SensorEntity): """Representation of an SABnzbd sensor.""" def __init__(self, sensor_type, sabnzbd_api_data, client_name): diff --git a/homeassistant/components/saj/sensor.py b/homeassistant/components/saj/sensor.py index 1e7b3dd5061..ef69513db43 100644 --- a/homeassistant/components/saj/sensor.py +++ b/homeassistant/components/saj/sensor.py @@ -5,7 +5,7 @@ import logging import pysaj 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, @@ -26,7 +26,6 @@ from homeassistant.const import ( from homeassistant.core import CALLBACK_TYPE, callback from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_call_later _LOGGER = logging.getLogger(__name__) @@ -160,7 +159,7 @@ def async_track_time_interval_backoff(hass, action) -> CALLBACK_TYPE: return remove_listener -class SAJsensor(Entity): +class SAJsensor(SensorEntity): """Representation of a SAJ sensor.""" def __init__(self, serialnumber, pysaj_sensor, inverter_name=None): diff --git a/homeassistant/components/scrape/sensor.py b/homeassistant/components/scrape/sensor.py index e8b6fcfd2c3..3bf070a7d79 100644 --- a/homeassistant/components/scrape/sensor.py +++ b/homeassistant/components/scrape/sensor.py @@ -6,7 +6,7 @@ from requests.auth import HTTPBasicAuth, HTTPDigestAuth import voluptuous as vol from homeassistant.components.rest.data import RestData -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_AUTHENTICATION, CONF_HEADERS, @@ -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 _LOGGER = logging.getLogger(__name__) @@ -89,7 +88,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class ScrapeSensor(Entity): +class ScrapeSensor(SensorEntity): """Representation of a web scrape sensor.""" def __init__(self, rest, name, select, attr, index, value_template, unit): diff --git a/homeassistant/components/screenlogic/sensor.py b/homeassistant/components/screenlogic/sensor.py index c9c66a75681..38bde2afd76 100644 --- a/homeassistant/components/screenlogic/sensor.py +++ b/homeassistant/components/screenlogic/sensor.py @@ -3,7 +3,11 @@ import logging from screenlogicpy.const import DEVICE_TYPE -from homeassistant.components.sensor import DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE +from homeassistant.components.sensor import ( + DEVICE_CLASS_POWER, + DEVICE_CLASS_TEMPERATURE, + SensorEntity, +) from . import ScreenlogicEntity from .const import DOMAIN @@ -34,7 +38,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class ScreenLogicSensor(ScreenlogicEntity): +class ScreenLogicSensor(ScreenlogicEntity, SensorEntity): """Representation of a ScreenLogic sensor entity.""" @property @@ -65,7 +69,7 @@ class ScreenLogicSensor(ScreenlogicEntity): return self.coordinator.data["sensors"][self._data_key] -class ScreenLogicPumpSensor(ScreenlogicEntity): +class ScreenLogicPumpSensor(ScreenlogicEntity, SensorEntity): """Representation of a ScreenLogic pump sensor entity.""" def __init__(self, coordinator, pump, key): diff --git a/homeassistant/components/season/sensor.py b/homeassistant/components/season/sensor.py index e116fb0e861..165920dd8e5 100644 --- a/homeassistant/components/season/sensor.py +++ b/homeassistant/components/season/sensor.py @@ -6,10 +6,9 @@ import ephem 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 CONF_NAME, CONF_TYPE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util.dt import utcnow _LOGGER = logging.getLogger(__name__) @@ -109,7 +108,7 @@ def get_season(date, hemisphere, season_tracking_type): return HEMISPHERE_SEASON_SWAP.get(season) -class Season(Entity): +class Season(SensorEntity): """Representation of the current season.""" def __init__(self, hass, hemisphere, season_tracking_type, name): diff --git a/homeassistant/components/sense/sensor.py b/homeassistant/components/sense/sensor.py index 7b6e415d4a3..0af64f3f17d 100644 --- a/homeassistant/components/sense/sensor.py +++ b/homeassistant/components/sense/sensor.py @@ -1,4 +1,5 @@ """Support for monitoring a Sense energy sensor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, DEVICE_CLASS_POWER, @@ -8,7 +9,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 ( ACTIVE_NAME, @@ -118,7 +118,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(devices) -class SenseActiveSensor(Entity): +class SenseActiveSensor(SensorEntity): """Implementation of a Sense energy sensor.""" def __init__( @@ -207,7 +207,7 @@ class SenseActiveSensor(Entity): self.async_write_ha_state() -class SenseVoltageSensor(Entity): +class SenseVoltageSensor(SensorEntity): """Implementation of a Sense energy voltage sensor.""" def __init__( @@ -287,7 +287,7 @@ class SenseVoltageSensor(Entity): self.async_write_ha_state() -class SenseTrendsSensor(Entity): +class SenseTrendsSensor(SensorEntity): """Implementation of a Sense energy sensor.""" def __init__( @@ -370,7 +370,7 @@ class SenseTrendsSensor(Entity): self.async_on_remove(self._coordinator.async_add_listener(self._async_update)) -class SenseEnergyDevice(Entity): +class SenseEnergyDevice(SensorEntity): """Implementation of a Sense energy device.""" def __init__(self, sense_devices_data, device, sense_monitor_id): diff --git a/homeassistant/components/sensehat/sensor.py b/homeassistant/components/sensehat/sensor.py index 67beb021d89..6ba00baae77 100644 --- a/homeassistant/components/sensehat/sensor.py +++ b/homeassistant/components/sensehat/sensor.py @@ -6,7 +6,7 @@ from pathlib import Path from sense_hat import SenseHat 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 ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -68,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class SenseHatSensor(Entity): +class SenseHatSensor(SensorEntity): """Representation of a Sense HAT sensor.""" def __init__(self, data, sensor_types): diff --git a/homeassistant/components/serial/sensor.py b/homeassistant/components/serial/sensor.py index 02590ccfe8f..1e73ae9ac83 100644 --- a/homeassistant/components/serial/sensor.py +++ b/homeassistant/components/serial/sensor.py @@ -7,11 +7,10 @@ from serial import SerialException import serial_asyncio 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_VALUE_TEMPLATE, EVENT_HOMEASSISTANT_STOP from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -103,7 +102,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([sensor], True) -class SerialSensor(Entity): +class SerialSensor(SensorEntity): """Representation of a Serial sensor.""" def __init__( diff --git a/homeassistant/components/serial_pm/sensor.py b/homeassistant/components/serial_pm/sensor.py index 2e7604ee97d..b81c60e0a19 100644 --- a/homeassistant/components/serial_pm/sensor.py +++ b/homeassistant/components/serial_pm/sensor.py @@ -4,10 +4,9 @@ import logging from pmsensor import serial_pm as pm import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONF_NAME 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(dev) -class ParticulateMatterSensor(Entity): +class ParticulateMatterSensor(SensorEntity): """Representation of an Particulate matter sensor.""" def __init__(self, pmDataCollector, name, pmname): diff --git a/homeassistant/components/seventeentrack/sensor.py b/homeassistant/components/seventeentrack/sensor.py index 223844dc9c7..e856f71b008 100644 --- a/homeassistant/components/seventeentrack/sensor.py +++ b/homeassistant/components/seventeentrack/sensor.py @@ -6,7 +6,7 @@ from py17track import Client as SeventeenTrackClient from py17track.errors import SeventeenTrackError 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_FRIENDLY_NAME, @@ -16,7 +16,6 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.helpers import aiohttp_client, config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_call_later from homeassistant.util import Throttle, slugify @@ -95,7 +94,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= await data.async_update() -class SeventeenTrackSummarySensor(Entity): +class SeventeenTrackSummarySensor(SensorEntity): """Define a summary sensor.""" def __init__(self, data, status, initial_state): @@ -166,7 +165,7 @@ class SeventeenTrackSummarySensor(Entity): self._state = self._data.summary.get(self._status) -class SeventeenTrackPackageSensor(Entity): +class SeventeenTrackPackageSensor(SensorEntity): """Define an individual package sensor.""" def __init__(self, data, package): diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index aac5ec81ec3..ae9e2d740d3 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -1,5 +1,6 @@ """Sensor for Shelly.""" from homeassistant.components import sensor +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEGREE, @@ -203,7 +204,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class ShellySensor(ShellyBlockAttributeEntity): +class ShellySensor(ShellyBlockAttributeEntity, SensorEntity): """Represent a shelly sensor.""" @property @@ -212,7 +213,7 @@ class ShellySensor(ShellyBlockAttributeEntity): return self.attribute_value -class ShellyRestSensor(ShellyRestAttributeEntity): +class ShellyRestSensor(ShellyRestAttributeEntity, SensorEntity): """Represent a shelly REST sensor.""" @property @@ -221,7 +222,7 @@ class ShellyRestSensor(ShellyRestAttributeEntity): return self.attribute_value -class ShellySleepingSensor(ShellySleepingBlockAttributeEntity): +class ShellySleepingSensor(ShellySleepingBlockAttributeEntity, SensorEntity): """Represent a shelly sleeping sensor.""" @property diff --git a/homeassistant/components/shodan/sensor.py b/homeassistant/components/shodan/sensor.py index 397e05a35ca..fa0fc2d3906 100644 --- a/homeassistant/components/shodan/sensor.py +++ b/homeassistant/components/shodan/sensor.py @@ -5,10 +5,9 @@ import logging import shodan 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, CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -47,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([ShodanSensor(data, name)], True) -class ShodanSensor(Entity): +class ShodanSensor(SensorEntity): """Representation of the Shodan sensor.""" def __init__(self, data, name): diff --git a/homeassistant/components/sht31/sensor.py b/homeassistant/components/sht31/sensor.py index 277039b3ba6..fd5506ee513 100644 --- a/homeassistant/components/sht31/sensor.py +++ b/homeassistant/components/sht31/sensor.py @@ -7,7 +7,7 @@ import math from Adafruit_SHT31 import SHT31 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, @@ -16,7 +16,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.temperature import display_temp from homeassistant.util import Throttle @@ -93,7 +92,7 @@ class SHTClient: self.humidity = humidity -class SHTSensor(Entity): +class SHTSensor(SensorEntity): """An abstract SHTSensor, can be either temperature or humidity.""" def __init__(self, sensor, name): diff --git a/homeassistant/components/sigfox/sensor.py b/homeassistant/components/sigfox/sensor.py index 3bf0f084e51..75c2a4f0f63 100644 --- a/homeassistant/components/sigfox/sensor.py +++ b/homeassistant/components/sigfox/sensor.py @@ -7,10 +7,9 @@ from urllib.parse import urljoin 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, HTTP_UNAUTHORIZED import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -109,7 +108,7 @@ class SigfoxAPI: return self._devices -class SigfoxDevice(Entity): +class SigfoxDevice(SensorEntity): """Class for single sigfox device.""" def __init__(self, device_id, auth, name): diff --git a/homeassistant/components/simplisafe/sensor.py b/homeassistant/components/simplisafe/sensor.py index 7e927ee942e..9f93a6f9e87 100644 --- a/homeassistant/components/simplisafe/sensor.py +++ b/homeassistant/components/simplisafe/sensor.py @@ -1,6 +1,7 @@ """Support for SimpliSafe freeze sensor.""" from simplipy.entity import EntityTypes +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_FAHRENHEIT from homeassistant.core import callback @@ -25,7 +26,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors) -class SimplisafeFreezeSensor(SimpliSafeBaseSensor): +class SimplisafeFreezeSensor(SimpliSafeBaseSensor, SensorEntity): """Define a SimpliSafe freeze sensor entity.""" def __init__(self, simplisafe, system, sensor): diff --git a/homeassistant/components/simulated/sensor.py b/homeassistant/components/simulated/sensor.py index dc4872cb2aa..3fe7aedfbb0 100644 --- a/homeassistant/components/simulated/sensor.py +++ b/homeassistant/components/simulated/sensor.py @@ -5,10 +5,9 @@ from random import Random 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 CONF_AMP = "amplitude" @@ -67,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([sensor], True) -class SimulatedSensor(Entity): +class SimulatedSensor(SensorEntity): """Class for simulated sensor.""" def __init__( diff --git a/homeassistant/components/skybeacon/sensor.py b/homeassistant/components/skybeacon/sensor.py index 3308ec80b8f..3fdd2e55b0d 100644 --- a/homeassistant/components/skybeacon/sensor.py +++ b/homeassistant/components/skybeacon/sensor.py @@ -8,7 +8,7 @@ from pygatt.backends import Characteristic, GATTToolBackend from pygatt.exceptions import BLEError, NotConnectedError, NotificationTimeout import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_MAC, CONF_NAME, @@ -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__) @@ -62,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): mon.start() -class SkybeaconHumid(Entity): +class SkybeaconHumid(SensorEntity): """Representation of a Skybeacon humidity sensor.""" def __init__(self, name, mon): @@ -91,7 +90,7 @@ class SkybeaconHumid(Entity): return {ATTR_DEVICE: "SKYBEACON", ATTR_MODEL: 1} -class SkybeaconTemp(Entity): +class SkybeaconTemp(SensorEntity): """Representation of a Skybeacon temperature sensor.""" def __init__(self, name, mon): @@ -120,7 +119,7 @@ class SkybeaconTemp(Entity): return {ATTR_DEVICE: "SKYBEACON", ATTR_MODEL: 1} -class Monitor(threading.Thread): +class Monitor(threading.Thread, SensorEntity): """Connection handling.""" def __init__(self, hass, mac, name): diff --git a/homeassistant/components/skybell/sensor.py b/homeassistant/components/skybell/sensor.py index 09a7400a035..8dc13814c67 100644 --- a/homeassistant/components/skybell/sensor.py +++ b/homeassistant/components/skybell/sensor.py @@ -3,7 +3,7 @@ from datetime import timedelta import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class SkybellSensor(SkybellDevice): +class SkybellSensor(SkybellDevice, SensorEntity): """A sensor implementation for Skybell devices.""" def __init__(self, device, sensor_type): diff --git a/homeassistant/components/sleepiq/sensor.py b/homeassistant/components/sleepiq/sensor.py index ae48c059bb8..8f5c17dad89 100644 --- a/homeassistant/components/sleepiq/sensor.py +++ b/homeassistant/components/sleepiq/sensor.py @@ -1,4 +1,6 @@ """Support for SleepIQ sensors.""" +from homeassistant.components.sensor import SensorEntity + from . import SleepIQSensor from .const import DOMAIN, SENSOR_TYPES, SIDES, SLEEP_NUMBER @@ -21,7 +23,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev) -class SleepNumberSensor(SleepIQSensor): +class SleepNumberSensor(SleepIQSensor, SensorEntity): """Implementation of a SleepIQ sensor.""" def __init__(self, sleepiq_data, bed_id, side): diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index bc4457e2838..2290f3a330f 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -5,7 +5,7 @@ import logging import pysma 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, @@ -19,7 +19,6 @@ from homeassistant.const import ( from homeassistant.core import callback from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval _LOGGER = logging.getLogger(__name__) @@ -169,7 +168,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_track_time_interval(hass, async_sma, interval) -class SMAsensor(Entity): +class SMAsensor(SensorEntity): """Representation of a SMA sensor.""" def __init__(self, pysma_sensor, sub_sensors): diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index 41041c1a002..43483dbdb1e 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -1,6 +1,6 @@ """Support for monitoring a Smappee energy sensor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_POWER, ENERGY_WATT_HOUR, POWER_WATT, VOLT -from homeassistant.helpers.entity import Entity from .const import DOMAIN @@ -239,7 +239,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class SmappeeSensor(Entity): +class SmappeeSensor(SensorEntity): """Implementation of a Smappee sensor.""" def __init__(self, smappee_base, service_location, sensor, attributes): diff --git a/homeassistant/components/smart_meter_texas/sensor.py b/homeassistant/components/smart_meter_texas/sensor.py index 42084fff836..54e5969f8ea 100644 --- a/homeassistant/components/smart_meter_texas/sensor.py +++ b/homeassistant/components/smart_meter_texas/sensor.py @@ -1,6 +1,7 @@ """Support for Smart Meter Texas sensors.""" from smart_meter_texas import Meter +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_ADDRESS, ENERGY_KILO_WATT_HOUR from homeassistant.core import callback from homeassistant.helpers.restore_state import RestoreEntity @@ -29,7 +30,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class SmartMeterTexasSensor(CoordinatorEntity, RestoreEntity): +class SmartMeterTexasSensor(CoordinatorEntity, RestoreEntity, SensorEntity): """Representation of an Smart Meter Texas sensor.""" def __init__(self, meter: Meter, coordinator: DataUpdateCoordinator): diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index 4f924786e49..86377e32e23 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -6,6 +6,7 @@ from typing import Sequence from pysmartthings import Attribute, Capability +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( AREA_SQUARE_METERS, CONCENTRATION_PARTS_PER_MILLION, @@ -306,7 +307,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None: ] -class SmartThingsSensor(SmartThingsEntity): +class SmartThingsSensor(SmartThingsEntity, SensorEntity): """Define a SmartThings Sensor.""" def __init__( @@ -346,7 +347,7 @@ class SmartThingsSensor(SmartThingsEntity): return UNITS.get(unit, unit) if unit else self._default_unit -class SmartThingsThreeAxisSensor(SmartThingsEntity): +class SmartThingsThreeAxisSensor(SmartThingsEntity, SensorEntity): """Define a SmartThings Three Axis Sensor.""" def __init__(self, device, index): diff --git a/homeassistant/components/smarttub/sensor.py b/homeassistant/components/smarttub/sensor.py index 99b2e80262d..ea803c9862b 100644 --- a/homeassistant/components/smarttub/sensor.py +++ b/homeassistant/components/smarttub/sensor.py @@ -2,6 +2,8 @@ from enum import Enum import logging +from homeassistant.components.sensor import SensorEntity + from .const import DOMAIN, SMARTTUB_CONTROLLER from .entity import SmartTubSensorBase @@ -44,7 +46,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class SmartTubSensor(SmartTubSensorBase): +class SmartTubSensor(SmartTubSensorBase, SensorEntity): """Generic class for SmartTub status sensors.""" @property diff --git a/homeassistant/components/smarty/sensor.py b/homeassistant/components/smarty/sensor.py index f5cd1fbb404..b958185f9bd 100644 --- a/homeassistant/components/smarty/sensor.py +++ b/homeassistant/components/smarty/sensor.py @@ -3,6 +3,7 @@ import datetime as dt import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TIMESTAMP, @@ -10,7 +11,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util from . import DOMAIN, SIGNAL_UPDATE_SMARTY @@ -35,7 +35,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors, True) -class SmartySensor(Entity): +class SmartySensor(SensorEntity): """Representation of a Smarty Sensor.""" def __init__( diff --git a/homeassistant/components/sms/sensor.py b/homeassistant/components/sms/sensor.py index 660b1a70c01..fc2310426e3 100644 --- a/homeassistant/components/sms/sensor.py +++ b/homeassistant/components/sms/sensor.py @@ -3,8 +3,8 @@ import logging import gammu # pylint: disable=import-error +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_SIGNAL_STRENGTH, SIGNAL_STRENGTH_DECIBELS -from homeassistant.helpers.entity import Entity from .const import DOMAIN, SMS_GATEWAY @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class GSMSignalSensor(Entity): +class GSMSignalSensor(SensorEntity): """Implementation of a GSM Signal sensor.""" def __init__( diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py index a60183a1a0f..7de2bfb91e2 100644 --- a/homeassistant/components/snmp/sensor.py +++ b/homeassistant/components/snmp/sensor.py @@ -15,7 +15,7 @@ from pysnmp.hlapi.asyncio import ( ) 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, @@ -26,7 +26,6 @@ from homeassistant.const import ( STATE_UNKNOWN, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from .const import ( CONF_ACCEPT_ERRORS, @@ -139,7 +138,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([SnmpSensor(data, name, unit, value_template)], True) -class SnmpSensor(Entity): +class SnmpSensor(SensorEntity): """Representation of a SNMP sensor.""" def __init__(self, data, name, unit_of_measurement, value_template): diff --git a/homeassistant/components/sochain/sensor.py b/homeassistant/components/sochain/sensor.py index 5acc8e8432a..1f735da4995 100644 --- a/homeassistant/components/sochain/sensor.py +++ b/homeassistant/components/sochain/sensor.py @@ -4,11 +4,10 @@ from datetime import timedelta from pysochain import ChainSo 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 from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity ATTRIBUTION = "Data provided by chain.so" @@ -40,7 +39,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([SochainSensor(name, network.upper(), chainso)], True) -class SochainSensor(Entity): +class SochainSensor(SensorEntity): """Representation of a Sochain sensor.""" def __init__(self, name, unit_of_measurement, chainso): diff --git a/homeassistant/components/socialblade/sensor.py b/homeassistant/components/socialblade/sensor.py index 3d3331f8af2..e38c45d10b4 100644 --- a/homeassistant/components/socialblade/sensor.py +++ b/homeassistant/components/socialblade/sensor.py @@ -5,10 +5,9 @@ import logging import socialbladeclient 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.helpers import config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -42,7 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([social_blade]) -class SocialBladeSensor(Entity): +class SocialBladeSensor(SensorEntity): """Representation of a Social Blade Sensor.""" def __init__(self, case, name): diff --git a/homeassistant/components/solaredge/sensor.py b/homeassistant/components/solaredge/sensor.py index 24932618195..7835fa9aee4 100644 --- a/homeassistant/components/solaredge/sensor.py +++ b/homeassistant/components/solaredge/sensor.py @@ -7,10 +7,10 @@ from requests.exceptions import ConnectTimeout, HTTPError import solaredge from stringcase import snakecase +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_API_KEY, DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER from homeassistant.core import callback from homeassistant.exceptions import ConfigEntryNotReady -from homeassistant.helpers.entity import Entity from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -117,7 +117,7 @@ class SolarEdgeSensorFactory: return sensor_class(self.platform_name, sensor_key, service) -class SolarEdgeSensor(CoordinatorEntity, Entity): +class SolarEdgeSensor(CoordinatorEntity, SensorEntity): """Abstract class for a solaredge sensor.""" def __init__(self, platform_name, sensor_key, data_service): diff --git a/homeassistant/components/solaredge_local/sensor.py b/homeassistant/components/solaredge_local/sensor.py index 9d5eca149cf..a34fb5a3afc 100644 --- a/homeassistant/components/solaredge_local/sensor.py +++ b/homeassistant/components/solaredge_local/sensor.py @@ -8,7 +8,7 @@ from requests.exceptions import ConnectTimeout, HTTPError from solaredge_local import SolarEdge 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_NAME, @@ -21,7 +21,6 @@ from homeassistant.const import ( VOLT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle DOMAIN = "solaredge_local" @@ -231,7 +230,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class SolarEdgeSensor(Entity): +class SolarEdgeSensor(SensorEntity): """Representation of an SolarEdge Monitoring API sensor.""" def __init__(self, platform_name, data, json_key, name, unit, icon, attr): diff --git a/homeassistant/components/solarlog/sensor.py b/homeassistant/components/solarlog/sensor.py index 6073d12815b..85a1531090d 100644 --- a/homeassistant/components/solarlog/sensor.py +++ b/homeassistant/components/solarlog/sensor.py @@ -5,8 +5,8 @@ from urllib.parse import ParseResult, urlparse from requests.exceptions import HTTPError, Timeout from sunwatcher.solarlog.solarlog import SolarLog +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_HOST -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from .const import DOMAIN, SCAN_INTERVAL, SENSOR_TYPES @@ -55,7 +55,7 @@ async def async_setup_entry(hass, entry, async_add_entities): return True -class SolarlogSensor(Entity): +class SolarlogSensor(SensorEntity): """Representation of a Sensor.""" def __init__(self, entry_id, device_name, sensor_key, data): diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index bca507c4391..e47f5c57802 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -6,11 +6,10 @@ from solax import real_time_api from solax.inverter import InverterError 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_PORT, TEMP_CELSIUS from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval DEFAULT_PORT = 80 @@ -73,7 +72,7 @@ class RealTimeDataEndpoint: sensor.async_schedule_update_ha_state() -class Inverter(Entity): +class Inverter(SensorEntity): """Class for a sensor.""" def __init__(self, uid, serial, key, unit): diff --git a/homeassistant/components/soma/sensor.py b/homeassistant/components/soma/sensor.py index 9430a929e1e..436a92a1087 100644 --- a/homeassistant/components/soma/sensor.py +++ b/homeassistant/components/soma/sensor.py @@ -4,8 +4,8 @@ import logging from requests import RequestException +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from . import DEVICES, SomaEntity @@ -26,7 +26,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class SomaSensor(SomaEntity, Entity): +class SomaSensor(SomaEntity, SensorEntity): """Representation of a Soma cover device.""" @property diff --git a/homeassistant/components/somfy/sensor.py b/homeassistant/components/somfy/sensor.py index 996a95348a4..34283a1271c 100644 --- a/homeassistant/components/somfy/sensor.py +++ b/homeassistant/components/somfy/sensor.py @@ -3,6 +3,7 @@ from pymfy.api.devices.category import Category from pymfy.api.devices.thermostat import Thermostat +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from . import SomfyEntity @@ -26,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors) -class SomfyThermostatBatterySensor(SomfyEntity): +class SomfyThermostatBatterySensor(SomfyEntity, SensorEntity): """Representation of a Somfy thermostat battery.""" def __init__(self, coordinator, device_id, api): diff --git a/homeassistant/components/sonarr/sensor.py b/homeassistant/components/sonarr/sensor.py index 017d9b0f0d0..3446130433e 100644 --- a/homeassistant/components/sonarr/sensor.py +++ b/homeassistant/components/sonarr/sensor.py @@ -7,6 +7,7 @@ from typing import Any, Callable from sonarr import Sonarr, SonarrConnectionError, SonarrError +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DATA_GIGABYTES from homeassistant.helpers.entity import Entity @@ -65,7 +66,7 @@ def sonarr_exception_handler(func): return handler -class SonarrSensor(SonarrEntity): +class SonarrSensor(SonarrEntity, SensorEntity): """Implementation of the Sonarr sensor.""" def __init__( diff --git a/homeassistant/components/speedtestdotnet/sensor.py b/homeassistant/components/speedtestdotnet/sensor.py index 6f0cb4124fe..c49a5691cec 100644 --- a/homeassistant/components/speedtestdotnet/sensor.py +++ b/homeassistant/components/speedtestdotnet/sensor.py @@ -1,4 +1,5 @@ """Support for Speedtest.net internet speed testing sensor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import callback from homeassistant.helpers.restore_state import RestoreEntity @@ -30,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class SpeedtestSensor(CoordinatorEntity, RestoreEntity): +class SpeedtestSensor(CoordinatorEntity, RestoreEntity, SensorEntity): """Implementation of a speedtest.net sensor.""" def __init__(self, coordinator, sensor_type): diff --git a/homeassistant/components/spotcrime/sensor.py b/homeassistant/components/spotcrime/sensor.py index e44bd81ed51..72a6fec84e9 100644 --- a/homeassistant/components/spotcrime/sensor.py +++ b/homeassistant/components/spotcrime/sensor.py @@ -6,7 +6,7 @@ from datetime import timedelta import spotcrime 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_LATITUDE, @@ -20,7 +20,6 @@ from homeassistant.const import ( CONF_RADIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import slugify CONF_DAYS = "days" @@ -66,7 +65,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class SpotCrimeSensor(Entity): +class SpotCrimeSensor(SensorEntity): """Representation of a Spot Crime Sensor.""" def __init__( diff --git a/homeassistant/components/sql/sensor.py b/homeassistant/components/sql/sensor.py index ccec918832e..a537b160d0b 100644 --- a/homeassistant/components/sql/sensor.py +++ b/homeassistant/components/sql/sensor.py @@ -8,10 +8,9 @@ from sqlalchemy.orm import scoped_session, sessionmaker import voluptuous as vol from homeassistant.components.recorder import CONF_DB_URL, DEFAULT_DB_FILE, DEFAULT_URL -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_NAME, CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -90,7 +89,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(queries, True) -class SQLSensor(Entity): +class SQLSensor(SensorEntity): """Representation of an SQL sensor.""" def __init__(self, name, sessmaker, query, column, unit, value_template): diff --git a/homeassistant/components/srp_energy/sensor.py b/homeassistant/components/srp_energy/sensor.py index cc39bf0b898..6973c58600e 100644 --- a/homeassistant/components/srp_energy/sensor.py +++ b/homeassistant/components/srp_energy/sensor.py @@ -5,8 +5,8 @@ import logging import async_timeout from requests.exceptions import ConnectionError as ConnectError, HTTPError, Timeout +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION, ENERGY_KILO_WATT_HOUR -from homeassistant.helpers import entity from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import ( @@ -71,7 +71,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities([SrpEntity(coordinator)]) -class SrpEntity(entity.Entity): +class SrpEntity(SensorEntity): """Implementation of a Srp Energy Usage sensor.""" def __init__(self, coordinator): diff --git a/homeassistant/components/starline/sensor.py b/homeassistant/components/starline/sensor.py index a8782a87892..29deacee428 100644 --- a/homeassistant/components/starline/sensor.py +++ b/homeassistant/components/starline/sensor.py @@ -1,5 +1,5 @@ """Reads vehicle status from StarLine API.""" -from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE +from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE, SensorEntity from homeassistant.const import ( LENGTH_KILOMETERS, PERCENTAGE, @@ -7,7 +7,6 @@ from homeassistant.const import ( VOLT, VOLUME_LITERS, ) -from homeassistant.helpers.entity import Entity from homeassistant.helpers.icon import icon_for_battery_level, icon_for_signal_level from .account import StarlineAccount, StarlineDevice @@ -38,7 +37,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class StarlineSensor(StarlineEntity, Entity): +class StarlineSensor(StarlineEntity, SensorEntity): """Representation of a StarLine sensor.""" def __init__( diff --git a/homeassistant/components/starlingbank/sensor.py b/homeassistant/components/starlingbank/sensor.py index 20fa646ce41..77f5ab307cb 100644 --- a/homeassistant/components/starlingbank/sensor.py +++ b/homeassistant/components/starlingbank/sensor.py @@ -5,10 +5,9 @@ import requests from starlingbank import StarlingAccount 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -62,7 +61,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(sensors, True) -class StarlingBalanceSensor(Entity): +class StarlingBalanceSensor(SensorEntity): """Representation of a Starling balance sensor.""" def __init__(self, starling_account, account_name, balance_data_type): diff --git a/homeassistant/components/startca/sensor.py b/homeassistant/components/startca/sensor.py index f6867d83212..661e00ed494 100644 --- a/homeassistant/components/startca/sensor.py +++ b/homeassistant/components/startca/sensor.py @@ -7,7 +7,7 @@ import async_timeout import voluptuous as vol import xmltodict -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_API_KEY, CONF_MONITORED_VARIABLES, @@ -18,7 +18,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 _LOGGER = logging.getLogger(__name__) @@ -75,7 +74,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors, True) -class StartcaSensor(Entity): +class StartcaSensor(SensorEntity): """Representation of Start.ca Bandwidth sensor.""" def __init__(self, startcadata, sensor_type, name): diff --git a/homeassistant/components/statistics/sensor.py b/homeassistant/components/statistics/sensor.py index 3bf70060da9..e32ae0debaf 100644 --- a/homeassistant/components/statistics/sensor.py +++ b/homeassistant/components/statistics/sensor.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.components.recorder.models import States from homeassistant.components.recorder.util import execute, session_scope -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_UNIT_OF_MEASUREMENT, CONF_ENTITY_ID, @@ -18,7 +18,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback from homeassistant.helpers import config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import ( async_track_point_in_utc_time, async_track_state_change_event, @@ -85,7 +84,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return True -class StatisticsSensor(Entity): +class StatisticsSensor(SensorEntity): """Representation of a Statistics sensor.""" def __init__(self, entity_id, name, sampling_size, max_age, precision): diff --git a/homeassistant/components/steam_online/sensor.py b/homeassistant/components/steam_online/sensor.py index e62922c67f4..45ae1a6c70a 100644 --- a/homeassistant/components/steam_online/sensor.py +++ b/homeassistant/components/steam_online/sensor.py @@ -6,11 +6,10 @@ from time import mktime import steam 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 from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import track_time_interval from homeassistant.util.dt import utc_from_timestamp @@ -71,7 +70,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): track_time_interval(hass, do_update, BASE_INTERVAL) -class SteamSensor(Entity): +class SteamSensor(SensorEntity): """A class for the Steam account.""" def __init__(self, account, steamod): diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index e7168f8ec0b..ba722d0a4f2 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -2,9 +2,9 @@ from datetime import timedelta +from homeassistant.components.sensor import SensorEntity from homeassistant.components.streamlabswater import DOMAIN as STREAMLABSWATER_DOMAIN from homeassistant.const import VOLUME_GALLONS -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle DEPENDENCIES = ["streamlabswater"] @@ -67,7 +67,7 @@ class StreamlabsUsageData: return self._this_year -class StreamLabsDailyUsage(Entity): +class StreamLabsDailyUsage(SensorEntity): """Monitors the daily water usage.""" def __init__(self, location_name, streamlabs_usage_data): diff --git a/homeassistant/components/subaru/sensor.py b/homeassistant/components/subaru/sensor.py index 594d18028e6..b8362202a3d 100644 --- a/homeassistant/components/subaru/sensor.py +++ b/homeassistant/components/subaru/sensor.py @@ -1,7 +1,7 @@ """Support for Subaru sensors.""" import subarulink.const as sc -from homeassistant.components.sensor import DEVICE_CLASSES +from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_TEMPERATURE, @@ -170,7 +170,7 @@ def create_vehicle_sensors(vehicle_info, coordinator): ] -class SubaruSensor(SubaruEntity): +class SubaruSensor(SubaruEntity, SensorEntity): """Class for Subaru sensors.""" def __init__( diff --git a/homeassistant/components/suez_water/sensor.py b/homeassistant/components/suez_water/sensor.py index 53f6b3e9c14..7170e0b8a67 100644 --- a/homeassistant/components/suez_water/sensor.py +++ b/homeassistant/components/suez_water/sensor.py @@ -6,10 +6,9 @@ from pysuez import SuezClient from pysuez.client import PySuezError 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, VOLUME_LITERS import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) CONF_COUNTER_ID = "counter_id" @@ -47,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([SuezSensor(client)], True) -class SuezSensor(Entity): +class SuezSensor(SensorEntity): """Representation of a Sensor.""" def __init__(self, client): diff --git a/homeassistant/components/supervisord/sensor.py b/homeassistant/components/supervisord/sensor.py index 0817f10ed5c..f701df2d6c3 100644 --- a/homeassistant/components/supervisord/sensor.py +++ b/homeassistant/components/supervisord/sensor.py @@ -4,10 +4,9 @@ import xmlrpc.client import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_URL import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -36,7 +35,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class SupervisorProcessSensor(Entity): +class SupervisorProcessSensor(SensorEntity): """Representation of a supervisor-monitored process.""" def __init__(self, info, server): diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index 92f90faff2c..0a49781767b 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -6,6 +6,7 @@ from typing import Any from surepy import SureLockStateID, SurepyProduct +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_VOLTAGE, CONF_ID, @@ -15,7 +16,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 SurePetcareAPI from .const import ( @@ -54,7 +54,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(entities, True) -class SurePetcareSensor(Entity): +class SurePetcareSensor(SensorEntity): """A binary sensor implementation for Sure Petcare Entities.""" def __init__(self, _id: int, sure_type: SurepyProduct, spc: SurePetcareAPI): diff --git a/homeassistant/components/swiss_hydrological_data/sensor.py b/homeassistant/components/swiss_hydrological_data/sensor.py index 27071afd112..47a8d3e5589 100644 --- a/homeassistant/components/swiss_hydrological_data/sensor.py +++ b/homeassistant/components/swiss_hydrological_data/sensor.py @@ -5,10 +5,9 @@ import logging from swisshydrodata import SwissHydroData 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -83,7 +82,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class SwissHydrologicalDataSensor(Entity): +class SwissHydrologicalDataSensor(SensorEntity): """Implementation of a Swiss hydrological sensor.""" def __init__(self, hydro_data, station, condition): diff --git a/homeassistant/components/swiss_public_transport/sensor.py b/homeassistant/components/swiss_public_transport/sensor.py index 1a7b97ce439..a971524c22b 100644 --- a/homeassistant/components/swiss_public_transport/sensor.py +++ b/homeassistant/components/swiss_public_transport/sensor.py @@ -6,11 +6,10 @@ from opendata_transport import OpendataTransport from opendata_transport.exceptions import OpendataTransportError 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 import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -68,7 +67,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([SwissPublicTransportSensor(opendata, start, destination, name)]) -class SwissPublicTransportSensor(Entity): +class SwissPublicTransportSensor(SensorEntity): """Implementation of an Swiss public transport sensor.""" def __init__(self, opendata, start, destination, name): diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index edec503bc25..8277bd69467 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -5,11 +5,10 @@ import logging from pysyncthru import SYNCTHRU_STATE_HUMAN, SyncThru 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 from homeassistant.const import CONF_NAME, CONF_RESOURCE, CONF_URL, PERCENTAGE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from . import device_identifiers from .const import DEFAULT_MODEL, DEFAULT_NAME_TEMPLATE, DOMAIN @@ -81,7 +80,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(devices, True) -class SyncThruSensor(Entity): +class SyncThruSensor(SensorEntity): """Implementation of an abstract Samsung Printer sensor platform.""" def __init__(self, syncthru, name): diff --git a/homeassistant/components/synology_dsm/sensor.py b/homeassistant/components/synology_dsm/sensor.py index 8cfab92975c..56eb56df07d 100644 --- a/homeassistant/components/synology_dsm/sensor.py +++ b/homeassistant/components/synology_dsm/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations from datetime import timedelta +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_DISKS, @@ -86,7 +87,7 @@ async def async_setup_entry( async_add_entities(entities) -class SynoDSMUtilSensor(SynologyDSMBaseEntity): +class SynoDSMUtilSensor(SynologyDSMBaseEntity, SensorEntity): """Representation a Synology Utilisation sensor.""" @property @@ -118,7 +119,7 @@ class SynoDSMUtilSensor(SynologyDSMBaseEntity): return bool(self._api.utilisation) -class SynoDSMStorageSensor(SynologyDSMDeviceEntity): +class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SensorEntity): """Representation a Synology Storage sensor.""" @property @@ -139,7 +140,7 @@ class SynoDSMStorageSensor(SynologyDSMDeviceEntity): return attr -class SynoDSMInfoSensor(SynologyDSMBaseEntity): +class SynoDSMInfoSensor(SynologyDSMBaseEntity, SensorEntity): """Representation a Synology information sensor.""" def __init__( diff --git a/homeassistant/components/systemmonitor/sensor.py b/homeassistant/components/systemmonitor/sensor.py index 805ffcdba5d..3e69939cbf3 100644 --- a/homeassistant/components/systemmonitor/sensor.py +++ b/homeassistant/components/systemmonitor/sensor.py @@ -7,7 +7,7 @@ import sys import psutil import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_RESOURCES, CONF_TYPE, @@ -20,7 +20,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import slugify import homeassistant.util.dt as dt_util @@ -182,7 +181,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class SystemMonitorSensor(Entity): +class SystemMonitorSensor(SensorEntity): """Implementation of a system monitor sensor.""" def __init__(self, sensor_type, argument=""):