From 339a56e434c466f4dc814f667358ae11ff89ff30 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 19:45:17 +0100 Subject: [PATCH] Migrate integrations f-h to extend SensorEntity (#48212) --- homeassistant/components/fail2ban/sensor.py | 5 ++--- homeassistant/components/fastdotcom/sensor.py | 3 ++- homeassistant/components/fibaro/sensor.py | 5 ++--- homeassistant/components/fido/sensor.py | 5 ++--- homeassistant/components/file/sensor.py | 5 ++--- homeassistant/components/filesize/sensor.py | 5 ++--- homeassistant/components/filter/sensor.py | 16 ++++++++-------- homeassistant/components/fints/sensor.py | 7 +++---- .../components/fireservicerota/sensor.py | 3 ++- homeassistant/components/firmata/sensor.py | 4 ++-- homeassistant/components/fitbit/sensor.py | 5 ++--- homeassistant/components/fixer/sensor.py | 5 ++--- .../components/flick_electric/sensor.py | 4 ++-- homeassistant/components/flo/sensor.py | 15 ++++++++------- homeassistant/components/flume/sensor.py | 4 ++-- homeassistant/components/flunearyou/sensor.py | 3 ++- homeassistant/components/folder/sensor.py | 5 ++--- homeassistant/components/foobot/sensor.py | 3 ++- homeassistant/components/freebox/sensor.py | 4 ++-- homeassistant/components/fritzbox/sensor.py | 4 ++-- .../components/fritzbox_callmonitor/sensor.py | 5 ++--- .../components/fritzbox_netmonitor/sensor.py | 5 ++--- homeassistant/components/fronius/sensor.py | 5 ++--- .../components/garmin_connect/sensor.py | 4 ++-- homeassistant/components/gdacs/sensor.py | 4 ++-- homeassistant/components/geizhals/sensor.py | 5 ++--- homeassistant/components/geniushub/sensor.py | 5 +++-- .../components/geo_rss_events/sensor.py | 5 ++--- .../components/geonetnz_quakes/sensor.py | 4 ++-- .../components/geonetnz_volcano/sensor.py | 4 ++-- homeassistant/components/github/sensor.py | 5 ++--- homeassistant/components/gitlab_ci/sensor.py | 5 ++--- homeassistant/components/gitter/sensor.py | 5 ++--- homeassistant/components/glances/sensor.py | 4 ++-- homeassistant/components/gogogate2/sensor.py | 5 +++-- .../components/google_travel_time/sensor.py | 5 ++--- .../components/google_wifi/sensor.py | 5 ++--- homeassistant/components/gpsd/sensor.py | 5 ++--- .../components/greeneye_monitor/sensor.py | 4 ++-- .../components/growatt_server/sensor.py | 5 ++--- homeassistant/components/gtfs/sensor.py | 5 ++--- homeassistant/components/guardian/sensor.py | 5 +++-- homeassistant/components/habitica/sensor.py | 6 +++--- homeassistant/components/hassio/sensor.py | 5 +++-- .../components/haveibeenpwned/sensor.py | 5 ++--- homeassistant/components/hddtemp/sensor.py | 5 ++--- .../components/here_travel_time/sensor.py | 5 ++--- .../components/history_stats/sensor.py | 5 ++--- homeassistant/components/hive/sensor.py | 5 ++--- .../components/home_connect/sensor.py | 3 ++- .../components/homekit_controller/sensor.py | 13 +++++++------ homeassistant/components/homematic/sensor.py | 3 ++- .../components/homematicip_cloud/sensor.py | 19 ++++++++++--------- homeassistant/components/hp_ilo/sensor.py | 5 ++--- homeassistant/components/htu21d/sensor.py | 5 ++--- homeassistant/components/huawei_lte/sensor.py | 3 ++- homeassistant/components/hue/sensor.py | 6 +++--- homeassistant/components/huisbaasje/sensor.py | 3 ++- .../hunterdouglas_powerview/sensor.py | 3 ++- .../components/hvv_departures/sensor.py | 4 ++-- homeassistant/components/hydrawise/sensor.py | 4 ++-- 61 files changed, 154 insertions(+), 167 deletions(-) diff --git a/homeassistant/components/fail2ban/sensor.py b/homeassistant/components/fail2ban/sensor.py index 30aa0c69838..87a8460f149 100644 --- a/homeassistant/components/fail2ban/sensor.py +++ b/homeassistant/components/fail2ban/sensor.py @@ -6,10 +6,9 @@ import re import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_FILE_PATH, CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -45,7 +44,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(device_list, True) -class BanSensor(Entity): +class BanSensor(SensorEntity): """Implementation of a fail2ban sensor.""" def __init__(self, name, jail, log_parser): diff --git a/homeassistant/components/fastdotcom/sensor.py b/homeassistant/components/fastdotcom/sensor.py index ad3711b1319..b4406a4de95 100644 --- a/homeassistant/components/fastdotcom/sensor.py +++ b/homeassistant/components/fastdotcom/sensor.py @@ -1,4 +1,5 @@ """Support for Fast.com internet speed testing sensor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DATA_RATE_MEGABITS_PER_SECOND from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -14,7 +15,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([SpeedtestSensor(hass.data[FASTDOTCOM_DOMAIN])]) -class SpeedtestSensor(RestoreEntity): +class SpeedtestSensor(RestoreEntity, SensorEntity): """Implementation of a FAst.com sensor.""" def __init__(self, speedtest_data): diff --git a/homeassistant/components/fibaro/sensor.py b/homeassistant/components/fibaro/sensor.py index 40a843bc7bb..fd25a3ce7eb 100644 --- a/homeassistant/components/fibaro/sensor.py +++ b/homeassistant/components/fibaro/sensor.py @@ -1,5 +1,5 @@ """Support for Fibaro sensors.""" -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEVICE_CLASS_CO2, @@ -11,7 +11,6 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, ) -from homeassistant.helpers.entity import Entity from . import FIBARO_DEVICES, FibaroDevice @@ -55,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class FibaroSensor(FibaroDevice, Entity): +class FibaroSensor(FibaroDevice, SensorEntity): """Representation of a Fibaro Sensor.""" def __init__(self, fibaro_device): diff --git a/homeassistant/components/fido/sensor.py b/homeassistant/components/fido/sensor.py index fe9c60c85a6..55ec455d8f1 100644 --- a/homeassistant/components/fido/sensor.py +++ b/homeassistant/components/fido/sensor.py @@ -11,7 +11,7 @@ from pyfido import FidoClient from pyfido.client import PyFidoError 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, @@ -21,7 +21,6 @@ from homeassistant.const import ( TIME_MINUTES, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -90,7 +89,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(sensors, True) -class FidoSensor(Entity): +class FidoSensor(SensorEntity): """Implementation of a Fido sensor.""" def __init__(self, fido_data, sensor_type, name, number): diff --git a/homeassistant/components/file/sensor.py b/homeassistant/components/file/sensor.py index 3368bd878d5..5d8a9475235 100644 --- a/homeassistant/components/file/sensor.py +++ b/homeassistant/components/file/sensor.py @@ -4,7 +4,7 @@ import os import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_FILE_PATH, CONF_NAME, @@ -12,7 +12,6 @@ from homeassistant.const import ( CONF_VALUE_TEMPLATE, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -46,7 +45,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= _LOGGER.error("'%s' is not an allowed directory", file_path) -class FileSensor(Entity): +class FileSensor(SensorEntity): """Implementation of a file sensor.""" def __init__(self, name, file_path, unit_of_measurement, value_template): diff --git a/homeassistant/components/filesize/sensor.py b/homeassistant/components/filesize/sensor.py index 312805e4942..856b29364ae 100644 --- a/homeassistant/components/filesize/sensor.py +++ b/homeassistant/components/filesize/sensor.py @@ -5,10 +5,9 @@ import os import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import DATA_MEGABYTES import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.reload import setup_reload_service from . import DOMAIN, PLATFORMS @@ -40,7 +39,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class Filesize(Entity): +class Filesize(SensorEntity): """Encapsulates file size information.""" def __init__(self, path): diff --git a/homeassistant/components/filter/sensor.py b/homeassistant/components/filter/sensor.py index d74491dd9c6..2f1705f5f4d 100644 --- a/homeassistant/components/filter/sensor.py +++ b/homeassistant/components/filter/sensor.py @@ -18,6 +18,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASSES as SENSOR_DEVICE_CLASSES, DOMAIN as SENSOR_DOMAIN, PLATFORM_SCHEMA, + SensorEntity, ) from homeassistant.const import ( ATTR_DEVICE_CLASS, @@ -31,7 +32,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 from homeassistant.util.decorator import Registry @@ -179,7 +179,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([SensorFilter(name, entity_id, filters)]) -class SensorFilter(Entity): +class SensorFilter(SensorEntity): """Representation of a Filter Sensor.""" def __init__(self, name, entity_id, filters): @@ -454,7 +454,7 @@ class Filter: @FILTERS.register(FILTER_NAME_RANGE) -class RangeFilter(Filter): +class RangeFilter(Filter, SensorEntity): """Range filter. Determines if new state is in the range of upper_bound and lower_bound. @@ -509,7 +509,7 @@ class RangeFilter(Filter): @FILTERS.register(FILTER_NAME_OUTLIER) -class OutlierFilter(Filter): +class OutlierFilter(Filter, SensorEntity): """BASIC outlier filter. Determines if new state is in a band around the median. @@ -547,7 +547,7 @@ class OutlierFilter(Filter): @FILTERS.register(FILTER_NAME_LOWPASS) -class LowPassFilter(Filter): +class LowPassFilter(Filter, SensorEntity): """BASIC Low Pass Filter.""" def __init__(self, window_size, precision, entity, time_constant: int): @@ -571,7 +571,7 @@ class LowPassFilter(Filter): @FILTERS.register(FILTER_NAME_TIME_SMA) -class TimeSMAFilter(Filter): +class TimeSMAFilter(Filter, SensorEntity): """Simple Moving Average (SMA) Filter. The window_size is determined by time, and SMA is time weighted. @@ -617,7 +617,7 @@ class TimeSMAFilter(Filter): @FILTERS.register(FILTER_NAME_THROTTLE) -class ThrottleFilter(Filter): +class ThrottleFilter(Filter, SensorEntity): """Throttle Filter. One sample per window. @@ -640,7 +640,7 @@ class ThrottleFilter(Filter): @FILTERS.register(FILTER_NAME_TIME_THROTTLE) -class TimeThrottleFilter(Filter): +class TimeThrottleFilter(Filter, SensorEntity): """Time Throttle Filter. One sample per time period. diff --git a/homeassistant/components/fints/sensor.py b/homeassistant/components/fints/sensor.py index 96d6ecc2166..e7faff46155 100644 --- a/homeassistant/components/fints/sensor.py +++ b/homeassistant/components/fints/sensor.py @@ -8,10 +8,9 @@ from fints.client import FinTS3PinTanClient from fints.dialog import FinTSDialogError 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_PIN, CONF_URL, CONF_USERNAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -154,7 +153,7 @@ class FinTsClient: return balance_accounts, holdings_accounts -class FinTsAccount(Entity): +class FinTsAccount(SensorEntity): """Sensor for a FinTS balance account. A balance account contains an amount of money (=balance). The amount may @@ -206,7 +205,7 @@ class FinTsAccount(Entity): return ICON -class FinTsHoldingsAccount(Entity): +class FinTsHoldingsAccount(SensorEntity): """Sensor for a FinTS holdings account. A holdings account does not contain money but rather some financial diff --git a/homeassistant/components/fireservicerota/sensor.py b/homeassistant/components/fireservicerota/sensor.py index 7dc8f546c98..04d8c97a4a5 100644 --- a/homeassistant/components/fireservicerota/sensor.py +++ b/homeassistant/components/fireservicerota/sensor.py @@ -1,6 +1,7 @@ """Sensor platform for FireServiceRota integration.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -21,7 +22,7 @@ async def async_setup_entry( async_add_entities([IncidentsSensor(client)]) -class IncidentsSensor(RestoreEntity): +class IncidentsSensor(RestoreEntity, SensorEntity): """Representation of FireServiceRota incidents sensor.""" def __init__(self, client): diff --git a/homeassistant/components/firmata/sensor.py b/homeassistant/components/firmata/sensor.py index cb9db1f11e5..fedac6f76d9 100644 --- a/homeassistant/components/firmata/sensor.py +++ b/homeassistant/components/firmata/sensor.py @@ -2,10 +2,10 @@ import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, CONF_PIN from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity import Entity from .const import CONF_DIFFERENTIAL, CONF_PIN_MODE, DOMAIN from .entity import FirmataPinEntity @@ -42,7 +42,7 @@ async def async_setup_entry( async_add_entities(new_entities) -class FirmataSensor(FirmataPinEntity, Entity): +class FirmataSensor(FirmataPinEntity, SensorEntity): """Representation of a sensor on a Firmata board.""" async def async_added_to_hass(self) -> None: diff --git a/homeassistant/components/fitbit/sensor.py b/homeassistant/components/fitbit/sensor.py index b90d33adaff..8571d31bc8a 100644 --- a/homeassistant/components/fitbit/sensor.py +++ b/homeassistant/components/fitbit/sensor.py @@ -10,7 +10,7 @@ from oauthlib.oauth2.rfc6749.errors import MismatchingStateError, MissingTokenEr import voluptuous as vol from homeassistant.components.http import HomeAssistantView -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_CLIENT_ID, @@ -25,7 +25,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.icon import icon_for_battery_level from homeassistant.helpers.network import get_url from homeassistant.util.json import load_json, save_json @@ -403,7 +402,7 @@ class FitbitAuthCallbackView(HomeAssistantView): return html_response -class FitbitSensor(Entity): +class FitbitSensor(SensorEntity): """Implementation of a Fitbit sensor.""" def __init__( diff --git a/homeassistant/components/fixer/sensor.py b/homeassistant/components/fixer/sensor.py index 9641f596e61..9214dd6907e 100644 --- a/homeassistant/components/fixer/sensor.py +++ b/homeassistant/components/fixer/sensor.py @@ -6,10 +6,9 @@ from fixerio import Fixerio from fixerio.exceptions import FixerioException 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, CONF_TARGET import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -49,7 +48,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([ExchangeRateSensor(data, name, target)], True) -class ExchangeRateSensor(Entity): +class ExchangeRateSensor(SensorEntity): """Representation of a Exchange sensor.""" def __init__(self, data, name, target): diff --git a/homeassistant/components/flick_electric/sensor.py b/homeassistant/components/flick_electric/sensor.py index 4f152c54e3c..e6880600212 100644 --- a/homeassistant/components/flick_electric/sensor.py +++ b/homeassistant/components/flick_electric/sensor.py @@ -5,10 +5,10 @@ import logging import async_timeout from pyflick import FlickAPI, FlickPrice +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION, ATTR_FRIENDLY_NAME from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity import Entity from homeassistant.util.dt import utcnow from .const import ATTR_COMPONENTS, ATTR_END_AT, ATTR_START_AT, DOMAIN @@ -33,7 +33,7 @@ async def async_setup_entry( async_add_entities([FlickPricingSensor(api)], True) -class FlickPricingSensor(Entity): +class FlickPricingSensor(SensorEntity): """Entity object for Flick Electric sensor.""" def __init__(self, api: FlickAPI): diff --git a/homeassistant/components/flo/sensor.py b/homeassistant/components/flo/sensor.py index 18ee067af5a..1e362e75f8c 100644 --- a/homeassistant/components/flo/sensor.py +++ b/homeassistant/components/flo/sensor.py @@ -1,6 +1,7 @@ """Support for Flo Water Monitor sensors.""" from __future__ import annotations +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, @@ -56,7 +57,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class FloDailyUsageSensor(FloEntity): +class FloDailyUsageSensor(FloEntity, SensorEntity): """Monitors the daily water usage.""" def __init__(self, device): @@ -82,7 +83,7 @@ class FloDailyUsageSensor(FloEntity): return VOLUME_GALLONS -class FloSystemModeSensor(FloEntity): +class FloSystemModeSensor(FloEntity, SensorEntity): """Monitors the current Flo system mode.""" def __init__(self, device): @@ -98,7 +99,7 @@ class FloSystemModeSensor(FloEntity): return self._device.current_system_mode -class FloCurrentFlowRateSensor(FloEntity): +class FloCurrentFlowRateSensor(FloEntity, SensorEntity): """Monitors the current water flow rate.""" def __init__(self, device): @@ -124,7 +125,7 @@ class FloCurrentFlowRateSensor(FloEntity): return "gpm" -class FloTemperatureSensor(FloEntity): +class FloTemperatureSensor(FloEntity, SensorEntity): """Monitors the temperature.""" def __init__(self, name, device): @@ -150,7 +151,7 @@ class FloTemperatureSensor(FloEntity): return DEVICE_CLASS_TEMPERATURE -class FloHumiditySensor(FloEntity): +class FloHumiditySensor(FloEntity, SensorEntity): """Monitors the humidity.""" def __init__(self, device): @@ -176,7 +177,7 @@ class FloHumiditySensor(FloEntity): return DEVICE_CLASS_HUMIDITY -class FloPressureSensor(FloEntity): +class FloPressureSensor(FloEntity, SensorEntity): """Monitors the water pressure.""" def __init__(self, device): @@ -202,7 +203,7 @@ class FloPressureSensor(FloEntity): return DEVICE_CLASS_PRESSURE -class FloBatterySensor(FloEntity): +class FloBatterySensor(FloEntity, SensorEntity): """Monitors the battery level for battery-powered leak detectors.""" def __init__(self, device): diff --git a/homeassistant/components/flume/sensor.py b/homeassistant/components/flume/sensor.py index 65584239910..d890443d238 100644 --- a/homeassistant/components/flume/sensor.py +++ b/homeassistant/components/flume/sensor.py @@ -6,7 +6,7 @@ from numbers import Number from pyflume import FlumeData 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_CLIENT_ID, @@ -108,7 +108,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(flume_entity_list) -class FlumeSensor(CoordinatorEntity): +class FlumeSensor(CoordinatorEntity, SensorEntity): """Representation of the Flume sensor.""" def __init__(self, coordinator, flume_device, flume_query_sensor, name, device_id): diff --git a/homeassistant/components/flunearyou/sensor.py b/homeassistant/components/flunearyou/sensor.py index 225ed15d98b..066126c390e 100644 --- a/homeassistant/components/flunearyou/sensor.py +++ b/homeassistant/components/flunearyou/sensor.py @@ -1,4 +1,5 @@ """Support for user- and CDC-based flu info sensors from Flu Near You.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_STATE, @@ -85,7 +86,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors) -class FluNearYouSensor(CoordinatorEntity): +class FluNearYouSensor(CoordinatorEntity, SensorEntity): """Define a base Flu Near You sensor.""" def __init__(self, coordinator, config_entry, sensor_type, name, icon, unit): diff --git a/homeassistant/components/folder/sensor.py b/homeassistant/components/folder/sensor.py index a6dccf57602..707f22f98ba 100644 --- a/homeassistant/components/folder/sensor.py +++ b/homeassistant/components/folder/sensor.py @@ -6,10 +6,9 @@ import os import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import DATA_MEGABYTES import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -51,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([folder], True) -class Folder(Entity): +class Folder(SensorEntity): """Representation of a folder.""" ICON = "mdi:folder" diff --git a/homeassistant/components/foobot/sensor.py b/homeassistant/components/foobot/sensor.py index 9ca265ba9ef..996ac1b1049 100644 --- a/homeassistant/components/foobot/sensor.py +++ b/homeassistant/components/foobot/sensor.py @@ -7,6 +7,7 @@ import aiohttp from foobot_async import FoobotClient import voluptuous as vol +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_TEMPERATURE, ATTR_TIME, @@ -91,7 +92,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(dev, True) -class FoobotSensor(Entity): +class FoobotSensor(SensorEntity): """Implementation of a Foobot sensor.""" def __init__(self, data, device, sensor_type): diff --git a/homeassistant/components/freebox/sensor.py b/homeassistant/components/freebox/sensor.py index 9f125ff69bc..fd0685f7667 100644 --- a/homeassistant/components/freebox/sensor.py +++ b/homeassistant/components/freebox/sensor.py @@ -3,11 +3,11 @@ from __future__ import annotations import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import DATA_RATE_KILOBYTES_PER_SECOND from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import HomeAssistantType import homeassistant.util.dt as dt_util @@ -74,7 +74,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class FreeboxSensor(Entity): +class FreeboxSensor(SensorEntity): """Representation of a Freebox sensor.""" def __init__( diff --git a/homeassistant/components/fritzbox/sensor.py b/homeassistant/components/fritzbox/sensor.py index 470d110429c..4d9c1693c1f 100644 --- a/homeassistant/components/fritzbox/sensor.py +++ b/homeassistant/components/fritzbox/sensor.py @@ -1,8 +1,8 @@ """Support for AVM Fritz!Box smarthome temperature sensor only devices.""" import requests +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_DEVICES, TEMP_CELSIUS -from homeassistant.helpers.entity import Entity from .const import ( ATTR_STATE_DEVICE_LOCKED, @@ -32,7 +32,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class FritzBoxTempSensor(Entity): +class FritzBoxTempSensor(SensorEntity): """The entity class for Fritzbox temperature sensors.""" def __init__(self, device, fritz): diff --git a/homeassistant/components/fritzbox_callmonitor/sensor.py b/homeassistant/components/fritzbox_callmonitor/sensor.py index 82ce075268b..a325c0ca71d 100644 --- a/homeassistant/components/fritzbox_callmonitor/sensor.py +++ b/homeassistant/components/fritzbox_callmonitor/sensor.py @@ -8,7 +8,7 @@ from time import sleep from fritzconnection.core.fritzmonitor import FritzMonitor 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_HOST, @@ -19,7 +19,6 @@ from homeassistant.const import ( EVENT_HOMEASSISTANT_STOP, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from .const import ( ATTR_PREFIXES, @@ -102,7 +101,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities([sensor]) -class FritzBoxCallSensor(Entity): +class FritzBoxCallSensor(SensorEntity): """Implementation of a Fritz!Box call monitor.""" def __init__(self, name, unique_id, fritzbox_phonebook, prefixes, host, port): diff --git a/homeassistant/components/fritzbox_netmonitor/sensor.py b/homeassistant/components/fritzbox_netmonitor/sensor.py index 320144ae163..3c37de7664c 100644 --- a/homeassistant/components/fritzbox_netmonitor/sensor.py +++ b/homeassistant/components/fritzbox_netmonitor/sensor.py @@ -7,10 +7,9 @@ from fritzconnection.lib.fritzstatus import FritzStatus from requests.exceptions import RequestException 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, STATE_UNAVAILABLE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -62,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([FritzboxMonitorSensor(name, fstatus)], True) -class FritzboxMonitorSensor(Entity): +class FritzboxMonitorSensor(SensorEntity): """Implementation of a fritzbox monitor sensor.""" def __init__(self, name, fstatus): diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index 7e578701e2c..a908f2605f8 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -8,7 +8,7 @@ import logging from pyfronius import Fronius 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_MONITORED_CONDITIONS, @@ -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.helpers.event import async_track_time_interval _LOGGER = logging.getLogger(__name__) @@ -252,7 +251,7 @@ class FroniusPowerFlow(FroniusAdapter): return await self.bridge.current_power_flow() -class FroniusTemplateSensor(Entity): +class FroniusTemplateSensor(SensorEntity): """Sensor for the single values (e.g. pv power, ac power).""" def __init__(self, parent: FroniusAdapter, name): diff --git a/homeassistant/components/garmin_connect/sensor.py b/homeassistant/components/garmin_connect/sensor.py index ba43a894cfe..46db6e615f1 100644 --- a/homeassistant/components/garmin_connect/sensor.py +++ b/homeassistant/components/garmin_connect/sensor.py @@ -10,9 +10,9 @@ from garminconnect import ( GarminConnectTooManyRequestsError, ) +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION, CONF_ID -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import HomeAssistantType from .alarm_util import calculate_next_active_alarms @@ -70,7 +70,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class GarminConnectSensor(Entity): +class GarminConnectSensor(SensorEntity): """Representation of a Garmin Connect Sensor.""" def __init__( diff --git a/homeassistant/components/gdacs/sensor.py b/homeassistant/components/gdacs/sensor.py index 7ab63fd6c6a..2e4759088fc 100644 --- a/homeassistant/components/gdacs/sensor.py +++ b/homeassistant/components/gdacs/sensor.py @@ -3,9 +3,9 @@ from __future__ import annotations import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from homeassistant.util import dt from .const import DEFAULT_ICON, DOMAIN, FEED @@ -34,7 +34,7 @@ async def async_setup_entry(hass, entry, async_add_entities): _LOGGER.debug("Sensor setup done") -class GdacsSensor(Entity): +class GdacsSensor(SensorEntity): """This is a status sensor for the GDACS integration.""" def __init__(self, config_entry_id, config_unique_id, config_title, manager): diff --git a/homeassistant/components/geizhals/sensor.py b/homeassistant/components/geizhals/sensor.py index 5f11ae7d0ca..04267e696ea 100644 --- a/homeassistant/components/geizhals/sensor.py +++ b/homeassistant/components/geizhals/sensor.py @@ -4,10 +4,9 @@ from datetime import timedelta from geizhals import Device, Geizhals 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 from homeassistant.util import Throttle CONF_DESCRIPTION = "description" @@ -38,7 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([Geizwatch(name, description, product_id, domain)], True) -class Geizwatch(Entity): +class Geizwatch(SensorEntity): """Implementation of Geizwatch.""" def __init__(self, name, description, product_id, domain): diff --git a/homeassistant/components/geniushub/sensor.py b/homeassistant/components/geniushub/sensor.py index 10c53994529..3234ccd577f 100644 --- a/homeassistant/components/geniushub/sensor.py +++ b/homeassistant/components/geniushub/sensor.py @@ -4,6 +4,7 @@ from __future__ import annotations from datetime import timedelta from typing import Any +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.helpers.typing import ConfigType, HomeAssistantType import homeassistant.util.dt as dt_util @@ -38,7 +39,7 @@ async def async_setup_platform( async_add_entities(sensors + issues, update_before_add=True) -class GeniusBattery(GeniusDevice): +class GeniusBattery(GeniusDevice, SensorEntity): """Representation of a Genius Hub sensor.""" def __init__(self, broker, device, state_attr) -> None: @@ -88,7 +89,7 @@ class GeniusBattery(GeniusDevice): return level if level != 255 else 0 -class GeniusIssue(GeniusEntity): +class GeniusIssue(GeniusEntity, SensorEntity): """Representation of a Genius Hub sensor.""" def __init__(self, broker, level) -> None: diff --git a/homeassistant/components/geo_rss_events/sensor.py b/homeassistant/components/geo_rss_events/sensor.py index 00ff63982fd..df5f11850fd 100644 --- a/homeassistant/components/geo_rss_events/sensor.py +++ b/homeassistant/components/geo_rss_events/sensor.py @@ -12,7 +12,7 @@ from georss_client import UPDATE_OK, UPDATE_OK_NO_DATA from georss_generic_client import GenericFeed import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, @@ -23,7 +23,6 @@ from homeassistant.const import ( LENGTH_KILOMETERS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -96,7 +95,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class GeoRssServiceSensor(Entity): +class GeoRssServiceSensor(SensorEntity): """Representation of a Sensor.""" def __init__( diff --git a/homeassistant/components/geonetnz_quakes/sensor.py b/homeassistant/components/geonetnz_quakes/sensor.py index 565e022f036..94c7965663a 100644 --- a/homeassistant/components/geonetnz_quakes/sensor.py +++ b/homeassistant/components/geonetnz_quakes/sensor.py @@ -3,9 +3,9 @@ from __future__ import annotations import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from homeassistant.util import dt from .const import DOMAIN, FEED @@ -35,7 +35,7 @@ async def async_setup_entry(hass, entry, async_add_entities): _LOGGER.debug("Sensor setup done") -class GeonetnzQuakesSensor(Entity): +class GeonetnzQuakesSensor(SensorEntity): """This is a status sensor for the GeoNet NZ Quakes integration.""" def __init__(self, config_entry_id, config_unique_id, config_title, manager): diff --git a/homeassistant/components/geonetnz_volcano/sensor.py b/homeassistant/components/geonetnz_volcano/sensor.py index 2ec4940f88d..c0cc6801437 100644 --- a/homeassistant/components/geonetnz_volcano/sensor.py +++ b/homeassistant/components/geonetnz_volcano/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_LATITUDE, @@ -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 homeassistant.util import dt from homeassistant.util.unit_system import IMPERIAL_SYSTEM @@ -54,7 +54,7 @@ async def async_setup_entry(hass, entry, async_add_entities): _LOGGER.debug("Sensor setup done") -class GeonetnzVolcanoSensor(Entity): +class GeonetnzVolcanoSensor(SensorEntity): """This represents an external event with GeoNet NZ Volcano feed data.""" def __init__(self, config_entry_id, feed_manager, external_id, unit_system): diff --git a/homeassistant/components/github/sensor.py b/homeassistant/components/github/sensor.py index f5f40c270a8..c7812fa621d 100644 --- a/homeassistant/components/github/sensor.py +++ b/homeassistant/components/github/sensor.py @@ -5,7 +5,7 @@ import logging import github 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_ACCESS_TOKEN, @@ -14,7 +14,6 @@ from homeassistant.const import ( CONF_URL, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -72,7 +71,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class GitHubSensor(Entity): +class GitHubSensor(SensorEntity): """Representation of a GitHub sensor.""" def __init__(self, github_data): diff --git a/homeassistant/components/gitlab_ci/sensor.py b/homeassistant/components/gitlab_ci/sensor.py index 5eaa62e601d..0b619853348 100644 --- a/homeassistant/components/gitlab_ci/sensor.py +++ b/homeassistant/components/gitlab_ci/sensor.py @@ -5,7 +5,7 @@ import logging from gitlab import Gitlab, GitlabAuthenticationError, GitlabGetError 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, @@ -14,7 +14,6 @@ from homeassistant.const import ( CONF_URL, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -66,7 +65,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([GitLabSensor(_gitlab_data, _name)], True) -class GitLabSensor(Entity): +class GitLabSensor(SensorEntity): """Representation of a GitLab sensor.""" def __init__(self, gitlab_data, name): diff --git a/homeassistant/components/gitter/sensor.py b/homeassistant/components/gitter/sensor.py index 3f7888d8593..20b68b2e5a9 100644 --- a/homeassistant/components/gitter/sensor.py +++ b/homeassistant/components/gitter/sensor.py @@ -5,10 +5,9 @@ from gitterpy.client import GitterClient from gitterpy.errors import GitterRoomError, GitterTokenError 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_NAME, CONF_ROOM 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([GitterSensor(gitter, room, name, username)], True) -class GitterSensor(Entity): +class GitterSensor(SensorEntity): """Representation of a Gitter sensor.""" def __init__(self, data, room, name, username): diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index 006333b321a..3e663621625 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -1,8 +1,8 @@ """Support gathering system information of hosts which are running glances.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME, STATE_UNAVAILABLE from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES @@ -60,7 +60,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(dev, True) -class GlancesSensor(Entity): +class GlancesSensor(SensorEntity): """Implementation of a Glances sensor.""" def __init__( diff --git a/homeassistant/components/gogogate2/sensor.py b/homeassistant/components/gogogate2/sensor.py index 2bdb1b3170c..9062bc0b352 100644 --- a/homeassistant/components/gogogate2/sensor.py +++ b/homeassistant/components/gogogate2/sensor.py @@ -6,6 +6,7 @@ from typing import Callable from gogogate2_api.common import AbstractDoor, get_configured_doors +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_BATTERY, @@ -48,7 +49,7 @@ async def async_setup_entry( async_add_entities(sensors) -class DoorSensorBattery(GoGoGate2Entity): +class DoorSensorBattery(GoGoGate2Entity, SensorEntity): """Battery sensor entity for gogogate2 door sensor.""" def __init__( @@ -86,7 +87,7 @@ class DoorSensorBattery(GoGoGate2Entity): return None -class DoorSensorTemperature(GoGoGate2Entity): +class DoorSensorTemperature(GoGoGate2Entity, SensorEntity): """Temperature sensor entity for gogogate2 door sensor.""" def __init__( diff --git a/homeassistant/components/google_travel_time/sensor.py b/homeassistant/components/google_travel_time/sensor.py index 109b65a4225..11bfb871a1b 100644 --- a/homeassistant/components/google_travel_time/sensor.py +++ b/homeassistant/components/google_travel_time/sensor.py @@ -5,7 +5,7 @@ import logging import googlemaps 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, @@ -18,7 +18,6 @@ from homeassistant.const import ( ) from homeassistant.helpers import location import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -180,7 +179,7 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None): hass.bus.listen_once(EVENT_HOMEASSISTANT_START, run_setup) -class GoogleTravelTimeSensor(Entity): +class GoogleTravelTimeSensor(SensorEntity): """Representation of a Google travel time sensor.""" def __init__(self, hass, name, api_key, origin, destination, options): diff --git a/homeassistant/components/google_wifi/sensor.py b/homeassistant/components/google_wifi/sensor.py index 9dfa26fab75..cf5a804e5a5 100644 --- a/homeassistant/components/google_wifi/sensor.py +++ b/homeassistant/components/google_wifi/sensor.py @@ -5,7 +5,7 @@ import logging import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_HOST, CONF_MONITORED_CONDITIONS, @@ -14,7 +14,6 @@ from homeassistant.const import ( TIME_DAYS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle, dt _LOGGER = logging.getLogger(__name__) @@ -71,7 +70,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class GoogleWifiSensor(Entity): +class GoogleWifiSensor(SensorEntity): """Representation of a Google Wifi sensor.""" def __init__(self, api, name, variable): diff --git a/homeassistant/components/gpsd/sensor.py b/homeassistant/components/gpsd/sensor.py index 978589e9a74..2f97f62337c 100644 --- a/homeassistant/components/gpsd/sensor.py +++ b/homeassistant/components/gpsd/sensor.py @@ -5,7 +5,7 @@ import socket from gps3.agps3threaded import AGPS3mechanism import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_LATITUDE, ATTR_LONGITUDE, @@ -15,7 +15,6 @@ from homeassistant.const import ( CONF_PORT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -65,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([GpsdSensor(hass, name, host, port)]) -class GpsdSensor(Entity): +class GpsdSensor(SensorEntity): """Representation of a GPS receiver available via GPSD.""" def __init__(self, hass, name, host, port): diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index 84352328312..4e792bf56e4 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -1,4 +1,5 @@ """Support for the sensors in a GreenEye Monitor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONF_NAME, CONF_SENSOR_TYPE, @@ -9,7 +10,6 @@ from homeassistant.const import ( TIME_SECONDS, VOLT, ) -from homeassistant.helpers.entity import Entity from . import ( CONF_COUNTED_QUANTITY, @@ -85,7 +85,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(entities) -class GEMSensor(Entity): +class GEMSensor(SensorEntity): """Base class for GreenEye Monitor sensors.""" def __init__(self, monitor_serial_number, name, sensor_type, number): diff --git a/homeassistant/components/growatt_server/sensor.py b/homeassistant/components/growatt_server/sensor.py index 50d269207de..86b88872a8a 100644 --- a/homeassistant/components/growatt_server/sensor.py +++ b/homeassistant/components/growatt_server/sensor.py @@ -7,7 +7,7 @@ import re import growattServer 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, @@ -28,7 +28,6 @@ from homeassistant.const import ( VOLT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -416,7 +415,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class GrowattInverter(Entity): +class GrowattInverter(SensorEntity): """Representation of a Growatt Sensor.""" def __init__(self, probe, name, sensor, unique_id): diff --git a/homeassistant/components/gtfs/sensor.py b/homeassistant/components/gtfs/sensor.py index 737348548a8..46a31f464a1 100644 --- a/homeassistant/components/gtfs/sensor.py +++ b/homeassistant/components/gtfs/sensor.py @@ -11,7 +11,7 @@ import pygtfs from sqlalchemy.sql import text 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, @@ -20,7 +20,6 @@ from homeassistant.const import ( STATE_UNKNOWN, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ( ConfigType, DiscoveryInfoType, @@ -519,7 +518,7 @@ def setup_platform( ) -class GTFSDepartureSensor(Entity): +class GTFSDepartureSensor(SensorEntity): """Implementation of a GTFS departure sensor.""" def __init__( diff --git a/homeassistant/components/guardian/sensor.py b/homeassistant/components/guardian/sensor.py index 9b778128d19..48807c9cfeb 100644 --- a/homeassistant/components/guardian/sensor.py +++ b/homeassistant/components/guardian/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Callable +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_BATTERY, @@ -110,7 +111,7 @@ async def async_setup_entry( async_add_entities(sensors) -class PairedSensorSensor(PairedSensorEntity): +class PairedSensorSensor(PairedSensorEntity, SensorEntity): """Define a binary sensor related to a Guardian valve controller.""" def __init__( @@ -153,7 +154,7 @@ class PairedSensorSensor(PairedSensorEntity): self._state = self.coordinator.data["temperature"] -class ValveControllerSensor(ValveControllerEntity): +class ValveControllerSensor(ValveControllerEntity, SensorEntity): """Define a generic Guardian sensor.""" def __init__( diff --git a/homeassistant/components/habitica/sensor.py b/homeassistant/components/habitica/sensor.py index dd17243cc9c..52748ddadad 100644 --- a/homeassistant/components/habitica/sensor.py +++ b/homeassistant/components/habitica/sensor.py @@ -5,8 +5,8 @@ import logging from aiohttp import ClientResponseError +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME, HTTP_TOO_MANY_REQUESTS -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from .const import DOMAIN @@ -125,7 +125,7 @@ class HabitipyData: ) -class HabitipySensor(Entity): +class HabitipySensor(SensorEntity): """A generic Habitica sensor.""" def __init__(self, name, sensor_name, updater): @@ -165,7 +165,7 @@ class HabitipySensor(Entity): return self._sensor_type.unit -class HabitipyTaskSensor(Entity): +class HabitipyTaskSensor(SensorEntity): """A Habitica task sensor.""" def __init__(self, name, task_name, updater): diff --git a/homeassistant/components/hassio/sensor.py b/homeassistant/components/hassio/sensor.py index ae2bd20d6ed..c41c0dc5090 100644 --- a/homeassistant/components/hassio/sensor.py +++ b/homeassistant/components/hassio/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Callable +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import Entity @@ -36,7 +37,7 @@ async def async_setup_entry( async_add_entities(entities) -class HassioAddonSensor(HassioAddonEntity): +class HassioAddonSensor(HassioAddonEntity, SensorEntity): """Sensor to track a Hass.io add-on attribute.""" @property @@ -45,7 +46,7 @@ class HassioAddonSensor(HassioAddonEntity): return self.addon_info[self.attribute_name] -class HassioOSSensor(HassioOSEntity): +class HassioOSSensor(HassioOSEntity, SensorEntity): """Sensor to track a Hass.io add-on attribute.""" @property diff --git a/homeassistant/components/haveibeenpwned/sensor.py b/homeassistant/components/haveibeenpwned/sensor.py index 5aa336905e9..55b369c2fde 100644 --- a/homeassistant/components/haveibeenpwned/sensor.py +++ b/homeassistant/components/haveibeenpwned/sensor.py @@ -6,7 +6,7 @@ from aiohttp.hdrs import USER_AGENT import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_API_KEY, @@ -15,7 +15,6 @@ from homeassistant.const import ( HTTP_OK, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import track_point_in_time from homeassistant.util import Throttle import homeassistant.util.dt as dt_util @@ -54,7 +53,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class HaveIBeenPwnedSensor(Entity): +class HaveIBeenPwnedSensor(SensorEntity): """Implementation of a HaveIBeenPwned sensor.""" def __init__(self, data, email): diff --git a/homeassistant/components/hddtemp/sensor.py b/homeassistant/components/hddtemp/sensor.py index e5f6621defe..4376c7f1289 100644 --- a/homeassistant/components/hddtemp/sensor.py +++ b/homeassistant/components/hddtemp/sensor.py @@ -6,7 +6,7 @@ from telnetlib import Telnet import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_DISKS, CONF_HOST, @@ -16,7 +16,6 @@ from homeassistant.const import ( TEMP_FAHRENHEIT, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -60,7 +59,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class HddTempSensor(Entity): +class HddTempSensor(SensorEntity): """Representation of a HDDTemp sensor.""" def __init__(self, name, disk, hddtemp): diff --git a/homeassistant/components/here_travel_time/sensor.py b/homeassistant/components/here_travel_time/sensor.py index 976c591f810..e4fbc0b2a89 100644 --- a/homeassistant/components/here_travel_time/sensor.py +++ b/homeassistant/components/here_travel_time/sensor.py @@ -8,7 +8,7 @@ from typing import Callable import herepy 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, @@ -26,7 +26,6 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant, State, callback from homeassistant.helpers import location import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import DiscoveryInfoType import homeassistant.util.dt as dt @@ -215,7 +214,7 @@ def _are_valid_client_credentials(here_client: herepy.RoutingApi) -> bool: return True -class HERETravelTimeSensor(Entity): +class HERETravelTimeSensor(SensorEntity): """Representation of a HERE travel time sensor.""" def __init__( diff --git a/homeassistant/components/history_stats/sensor.py b/homeassistant/components/history_stats/sensor.py index 7658146d102..b8d3dc39187 100644 --- a/homeassistant/components/history_stats/sensor.py +++ b/homeassistant/components/history_stats/sensor.py @@ -6,7 +6,7 @@ import math import voluptuous as vol from homeassistant.components import history -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_ENTITY_ID, CONF_NAME, @@ -19,7 +19,6 @@ from homeassistant.const import ( from homeassistant.core import CoreState, callback from homeassistant.exceptions import TemplateError 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 setup_reload_service import homeassistant.util.dt as dt_util @@ -102,7 +101,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return True -class HistoryStatsSensor(Entity): +class HistoryStatsSensor(SensorEntity): """Representation of a HistoryStats sensor.""" def __init__( diff --git a/homeassistant/components/hive/sensor.py b/homeassistant/components/hive/sensor.py index 53cc643250c..518f3286231 100644 --- a/homeassistant/components/hive/sensor.py +++ b/homeassistant/components/hive/sensor.py @@ -2,8 +2,7 @@ from datetime import timedelta -from homeassistant.components.sensor import DEVICE_CLASS_BATTERY -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, SensorEntity from . import HiveEntity from .const import DOMAIN @@ -27,7 +26,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities, True) -class HiveSensorEntity(HiveEntity, Entity): +class HiveSensorEntity(HiveEntity, SensorEntity): """Hive Sensor Entity.""" @property diff --git a/homeassistant/components/home_connect/sensor.py b/homeassistant/components/home_connect/sensor.py index 064ae033fb0..463de6cda51 100644 --- a/homeassistant/components/home_connect/sensor.py +++ b/homeassistant/components/home_connect/sensor.py @@ -3,6 +3,7 @@ from datetime import timedelta import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_ENTITIES, DEVICE_CLASS_TIMESTAMP import homeassistant.util.dt as dt_util @@ -27,7 +28,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(await hass.async_add_executor_job(get_entities), True) -class HomeConnectSensor(HomeConnectEntity): +class HomeConnectSensor(HomeConnectEntity, SensorEntity): """Sensor class for Home Connect.""" def __init__(self, device, desc, key, unit, icon, device_class, sign=1): diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index 094d0a500d1..2ae264fabb9 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -2,6 +2,7 @@ from aiohomekit.model.characteristics import CharacteristicsTypes from aiohomekit.model.services import ServicesTypes +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEVICE_CLASS_BATTERY, @@ -39,7 +40,7 @@ SIMPLE_SENSOR = { } -class HomeKitHumiditySensor(HomeKitEntity): +class HomeKitHumiditySensor(HomeKitEntity, SensorEntity): """Representation of a Homekit humidity sensor.""" def get_characteristic_types(self): @@ -72,7 +73,7 @@ class HomeKitHumiditySensor(HomeKitEntity): return self.service.value(CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT) -class HomeKitTemperatureSensor(HomeKitEntity): +class HomeKitTemperatureSensor(HomeKitEntity, SensorEntity): """Representation of a Homekit temperature sensor.""" def get_characteristic_types(self): @@ -105,7 +106,7 @@ class HomeKitTemperatureSensor(HomeKitEntity): return self.service.value(CharacteristicsTypes.TEMPERATURE_CURRENT) -class HomeKitLightSensor(HomeKitEntity): +class HomeKitLightSensor(HomeKitEntity, SensorEntity): """Representation of a Homekit light level sensor.""" def get_characteristic_types(self): @@ -138,7 +139,7 @@ class HomeKitLightSensor(HomeKitEntity): return self.service.value(CharacteristicsTypes.LIGHT_LEVEL_CURRENT) -class HomeKitCarbonDioxideSensor(HomeKitEntity): +class HomeKitCarbonDioxideSensor(HomeKitEntity, SensorEntity): """Representation of a Homekit Carbon Dioxide sensor.""" def get_characteristic_types(self): @@ -166,7 +167,7 @@ class HomeKitCarbonDioxideSensor(HomeKitEntity): return self.service.value(CharacteristicsTypes.CARBON_DIOXIDE_LEVEL) -class HomeKitBatterySensor(HomeKitEntity): +class HomeKitBatterySensor(HomeKitEntity, SensorEntity): """Representation of a Homekit battery sensor.""" def get_characteristic_types(self): @@ -233,7 +234,7 @@ class HomeKitBatterySensor(HomeKitEntity): return self.service.value(CharacteristicsTypes.BATTERY_LEVEL) -class SimpleSensor(CharacteristicEntity): +class SimpleSensor(CharacteristicEntity, SensorEntity): """ A simple sensor for a single characteristic. diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index e6439c451c1..4525d5a48fc 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -1,6 +1,7 @@ """Support for HomeMatic sensors.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEGREE, DEVICE_CLASS_HUMIDITY, @@ -97,7 +98,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class HMSensor(HMDevice): +class HMSensor(HMDevice, SensorEntity): """Representation of a HomeMatic sensor.""" @property diff --git a/homeassistant/components/homematicip_cloud/sensor.py b/homeassistant/components/homematicip_cloud/sensor.py index 6f4acc6137a..9e6e96232b4 100644 --- a/homeassistant/components/homematicip_cloud/sensor.py +++ b/homeassistant/components/homematicip_cloud/sensor.py @@ -26,6 +26,7 @@ from homematicip.aio.device import ( ) from homematicip.base.enums import ValveState +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, @@ -123,7 +124,7 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipAccesspointDutyCycle(HomematicipGenericEntity): +class HomematicipAccesspointDutyCycle(HomematicipGenericEntity, SensorEntity): """Representation of then HomeMaticIP access point.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -146,7 +147,7 @@ class HomematicipAccesspointDutyCycle(HomematicipGenericEntity): return PERCENTAGE -class HomematicipHeatingThermostat(HomematicipGenericEntity): +class HomematicipHeatingThermostat(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP heating thermostat.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -175,7 +176,7 @@ class HomematicipHeatingThermostat(HomematicipGenericEntity): return PERCENTAGE -class HomematicipHumiditySensor(HomematicipGenericEntity): +class HomematicipHumiditySensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP humidity sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -198,7 +199,7 @@ class HomematicipHumiditySensor(HomematicipGenericEntity): return PERCENTAGE -class HomematicipTemperatureSensor(HomematicipGenericEntity): +class HomematicipTemperatureSensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP thermometer.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -235,7 +236,7 @@ class HomematicipTemperatureSensor(HomematicipGenericEntity): return state_attr -class HomematicipIlluminanceSensor(HomematicipGenericEntity): +class HomematicipIlluminanceSensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP Illuminance sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -273,7 +274,7 @@ class HomematicipIlluminanceSensor(HomematicipGenericEntity): return state_attr -class HomematicipPowerSensor(HomematicipGenericEntity): +class HomematicipPowerSensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP power measuring sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -296,7 +297,7 @@ class HomematicipPowerSensor(HomematicipGenericEntity): return POWER_WATT -class HomematicipWindspeedSensor(HomematicipGenericEntity): +class HomematicipWindspeedSensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP wind speed sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -329,7 +330,7 @@ class HomematicipWindspeedSensor(HomematicipGenericEntity): return state_attr -class HomematicipTodayRainSensor(HomematicipGenericEntity): +class HomematicipTodayRainSensor(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP rain counter of a day sensor.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -347,7 +348,7 @@ class HomematicipTodayRainSensor(HomematicipGenericEntity): return LENGTH_MILLIMETERS -class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity): +class HomematicipPassageDetectorDeltaCounter(HomematicipGenericEntity, SensorEntity): """Representation of the HomematicIP passage detector delta counter.""" @property diff --git a/homeassistant/components/hp_ilo/sensor.py b/homeassistant/components/hp_ilo/sensor.py index 0126ab780ce..297bfa5264f 100644 --- a/homeassistant/components/hp_ilo/sensor.py +++ b/homeassistant/components/hp_ilo/sensor.py @@ -5,7 +5,7 @@ import logging import hpilo import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_HOST, CONF_MONITORED_VARIABLES, @@ -18,7 +18,6 @@ from homeassistant.const import ( CONF_VALUE_TEMPLATE, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -100,7 +99,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class HpIloSensor(Entity): +class HpIloSensor(SensorEntity): """Representation of a HP iLO sensor.""" def __init__( diff --git a/homeassistant/components/htu21d/sensor.py b/homeassistant/components/htu21d/sensor.py index 615177ed6af..d32eebf6d5f 100644 --- a/homeassistant/components/htu21d/sensor.py +++ b/homeassistant/components/htu21d/sensor.py @@ -7,10 +7,9 @@ from i2csense.htu21d import HTU21D # pylint: disable=import-error import smbus 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, PERCENTAGE, 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 @@ -70,7 +69,7 @@ class HTU21DHandler: self.sensor.update() -class HTU21DSensor(Entity): +class HTU21DSensor(SensorEntity): """Implementation of the HTU21D sensor.""" def __init__(self, htu21d_client, name, variable, unit): diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index c0773fdf808..c6cb93f0e67 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -12,6 +12,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_SIGNAL_STRENGTH, DOMAIN as SENSOR_DOMAIN, + SensorEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -373,7 +374,7 @@ def format_default(value: StateType) -> tuple[StateType, str | None]: @attr.s -class HuaweiLteSensor(HuaweiLteBaseEntity): +class HuaweiLteSensor(HuaweiLteBaseEntity, SensorEntity): """Huawei LTE sensor entity.""" key: str = attr.ib() diff --git a/homeassistant/components/hue/sensor.py b/homeassistant/components/hue/sensor.py index a3c5fcc3fa7..6ac8d134327 100644 --- a/homeassistant/components/hue/sensor.py +++ b/homeassistant/components/hue/sensor.py @@ -6,6 +6,7 @@ from aiohue.sensors import ( TYPE_ZLL_TEMPERATURE, ) +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, @@ -14,7 +15,6 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, ) -from homeassistant.helpers.entity import Entity from .const import DOMAIN as HUE_DOMAIN from .sensor_base import SENSOR_CONFIG_MAP, GenericHueSensor, GenericZLLSensor @@ -31,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ].sensor_manager.async_register_component("sensor", async_add_entities) -class GenericHueGaugeSensorEntity(GenericZLLSensor, Entity): +class GenericHueGaugeSensorEntity(GenericZLLSensor, SensorEntity): """Parent class for all 'gauge' Hue device sensors.""" async def _async_update_ha_state(self, *args, **kwargs): @@ -88,7 +88,7 @@ class HueTemperature(GenericHueGaugeSensorEntity): return self.sensor.temperature / 100 -class HueBattery(GenericHueSensor): +class HueBattery(GenericHueSensor, SensorEntity): """Battery class for when a batt-powered device is only represented as an event.""" @property diff --git a/homeassistant/components/huisbaasje/sensor.py b/homeassistant/components/huisbaasje/sensor.py index e84052fe029..3acf39a140d 100644 --- a/homeassistant/components/huisbaasje/sensor.py +++ b/homeassistant/components/huisbaasje/sensor.py @@ -1,4 +1,5 @@ """Platform for sensor integration.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_ID, POWER_WATT from homeassistant.core import HomeAssistant @@ -23,7 +24,7 @@ async def async_setup_entry( ) -class HuisbaasjeSensor(CoordinatorEntity): +class HuisbaasjeSensor(CoordinatorEntity, SensorEntity): """Defines a Huisbaasje sensor.""" def __init__( diff --git a/homeassistant/components/hunterdouglas_powerview/sensor.py b/homeassistant/components/hunterdouglas_powerview/sensor.py index 130e8dd507a..d66671fe1ea 100644 --- a/homeassistant/components/hunterdouglas_powerview/sensor.py +++ b/homeassistant/components/hunterdouglas_powerview/sensor.py @@ -1,6 +1,7 @@ """Support for hunterdouglass_powerview sensors.""" from aiopvapi.resources.shade import factory as PvShade +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.core import callback @@ -45,7 +46,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class PowerViewShadeBatterySensor(ShadeEntity): +class PowerViewShadeBatterySensor(ShadeEntity, SensorEntity): """Representation of an shade battery charge sensor.""" @property diff --git a/homeassistant/components/hvv_departures/sensor.py b/homeassistant/components/hvv_departures/sensor.py index bbabb1b8caa..35fc137a0f0 100644 --- a/homeassistant/components/hvv_departures/sensor.py +++ b/homeassistant/components/hvv_departures/sensor.py @@ -6,9 +6,9 @@ from aiohttp import ClientConnectorError from pygti.exceptions import InvalidAuth from pytz import timezone +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ID, DEVICE_CLASS_TIMESTAMP from homeassistant.helpers import aiohttp_client -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.util.dt import utcnow @@ -43,7 +43,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices): async_add_devices([sensor], True) -class HVVDepartureSensor(Entity): +class HVVDepartureSensor(SensorEntity): """HVVDepartureSensor class.""" def __init__(self, hass, config_entry, session, hub): diff --git a/homeassistant/components/hydrawise/sensor.py b/homeassistant/components/hydrawise/sensor.py index 6a0c6ab0d80..7cd521296f6 100644 --- a/homeassistant/components/hydrawise/sensor.py +++ b/homeassistant/components/hydrawise/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.util import dt @@ -36,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class HydrawiseSensor(HydrawiseEntity): +class HydrawiseSensor(HydrawiseEntity, SensorEntity): """A sensor implementation for Hydrawise device.""" @property