From c900e3030b81ed25859911c3c3100713b24cf52b Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 19:46:46 +0100 Subject: [PATCH] Migrate integrations n-q to extend SensorEntity (#48214) --- homeassistant/components/n26/sensor.py | 8 ++++---- homeassistant/components/neato/sensor.py | 5 ++--- .../components/nederlandse_spoorwegen/sensor.py | 5 ++--- homeassistant/components/nest/legacy/sensor.py | 5 +++-- homeassistant/components/netatmo/sensor.py | 5 +++-- homeassistant/components/netdata/sensor.py | 7 +++---- homeassistant/components/netgear_lte/sensor.py | 4 ++-- homeassistant/components/neurio_energy/sensor.py | 5 ++--- homeassistant/components/nexia/sensor.py | 5 +++-- homeassistant/components/nextbus/sensor.py | 5 ++--- homeassistant/components/nextcloud/sensor.py | 4 ++-- homeassistant/components/nightscout/sensor.py | 3 ++- homeassistant/components/nissan_leaf/sensor.py | 5 +++-- homeassistant/components/nmbs/sensor.py | 7 +++---- homeassistant/components/noaa_tides/sensor.py | 5 ++--- homeassistant/components/notion/sensor.py | 3 ++- homeassistant/components/nsw_fuel_station/sensor.py | 5 ++--- homeassistant/components/numato/sensor.py | 4 ++-- homeassistant/components/nut/sensor.py | 3 ++- homeassistant/components/nzbget/sensor.py | 3 ++- homeassistant/components/oasa_telematics/sensor.py | 5 ++--- homeassistant/components/obihai/sensor.py | 5 ++--- homeassistant/components/octoprint/sensor.py | 4 ++-- homeassistant/components/ohmconnect/sensor.py | 5 ++--- homeassistant/components/ombi/sensor.py | 4 ++-- homeassistant/components/omnilogic/sensor.py | 4 ++-- homeassistant/components/ondilo_ico/sensor.py | 3 ++- homeassistant/components/onewire/sensor.py | 8 ++++---- homeassistant/components/onvif/sensor.py | 3 ++- homeassistant/components/openerz/sensor.py | 4 ++-- homeassistant/components/openevse/sensor.py | 5 ++--- homeassistant/components/openexchangerates/sensor.py | 5 ++--- homeassistant/components/openhardwaremonitor/sensor.py | 5 ++--- homeassistant/components/opensky/sensor.py | 5 ++--- homeassistant/components/opentherm_gw/sensor.py | 6 +++--- homeassistant/components/openuv/sensor.py | 3 ++- .../components/openweathermap/abstract_owm_sensor.py | 4 ++-- homeassistant/components/oru/sensor.py | 5 ++--- homeassistant/components/otp/sensor.py | 5 ++--- homeassistant/components/ovo_energy/sensor.py | 3 ++- homeassistant/components/ozw/sensor.py | 3 ++- homeassistant/components/pi_hole/sensor.py | 3 ++- homeassistant/components/pilight/sensor.py | 5 ++--- homeassistant/components/plaato/sensor.py | 4 ++-- homeassistant/components/plex/sensor.py | 4 ++-- homeassistant/components/plugwise/sensor.py | 10 +++++----- homeassistant/components/pocketcasts/sensor.py | 5 ++--- homeassistant/components/point/sensor.py | 4 ++-- homeassistant/components/poolsense/sensor.py | 4 ++-- homeassistant/components/powerwall/sensor.py | 5 +++-- homeassistant/components/pushbullet/sensor.py | 5 ++--- homeassistant/components/pvoutput/sensor.py | 5 ++--- homeassistant/components/pvpc_hourly_pricing/sensor.py | 3 ++- homeassistant/components/pyload/sensor.py | 5 ++--- homeassistant/components/qbittorrent/sensor.py | 5 ++--- homeassistant/components/qnap/sensor.py | 5 ++--- homeassistant/components/qwikswitch/sensor.py | 3 ++- 57 files changed, 129 insertions(+), 136 deletions(-) diff --git a/homeassistant/components/n26/sensor.py b/homeassistant/components/n26/sensor.py index df687d9689a..98d86194b86 100644 --- a/homeassistant/components/n26/sensor.py +++ b/homeassistant/components/n26/sensor.py @@ -1,5 +1,5 @@ """Support for N26 bank account sensors.""" -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from . import DEFAULT_SCAN_INTERVAL, DOMAIN, timestamp_ms_to_date from .const import DATA @@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensor_entities) -class N26Account(Entity): +class N26Account(SensorEntity): """Sensor for a N26 balance account. A balance account contains an amount of money (=balance). The amount may @@ -117,7 +117,7 @@ class N26Account(Entity): return ICON_ACCOUNT -class N26Card(Entity): +class N26Card(SensorEntity): """Sensor for a N26 card.""" def __init__(self, api_data, card) -> None: @@ -186,7 +186,7 @@ class N26Card(Entity): return ICON_CARD -class N26Space(Entity): +class N26Space(SensorEntity): """Sensor for a N26 space.""" def __init__(self, api_data, space) -> None: diff --git a/homeassistant/components/neato/sensor.py b/homeassistant/components/neato/sensor.py index 50af42e7007..83add4ff3f7 100644 --- a/homeassistant/components/neato/sensor.py +++ b/homeassistant/components/neato/sensor.py @@ -4,9 +4,8 @@ import logging from pybotvac.exceptions import NeatoRobotException -from homeassistant.components.sensor import DEVICE_CLASS_BATTERY +from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, SensorEntity from homeassistant.const import PERCENTAGE -from homeassistant.helpers.entity import Entity from .const import NEATO_DOMAIN, NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES @@ -31,7 +30,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(dev, True) -class NeatoSensor(Entity): +class NeatoSensor(SensorEntity): """Neato sensor.""" def __init__(self, neato, robot): diff --git a/homeassistant/components/nederlandse_spoorwegen/sensor.py b/homeassistant/components/nederlandse_spoorwegen/sensor.py index 7d90c2c3c0d..de8a85f44fd 100644 --- a/homeassistant/components/nederlandse_spoorwegen/sensor.py +++ b/homeassistant/components/nederlandse_spoorwegen/sensor.py @@ -7,11 +7,10 @@ from ns_api import RequestParametersError 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, CONF_NAME 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__) @@ -94,7 +93,7 @@ def valid_stations(stations, given_stations): return True -class NSDepartureSensor(Entity): +class NSDepartureSensor(SensorEntity): """Implementation of a NS Departure Sensor.""" def __init__(self, nsapi, name, departure, heading, via, time): diff --git a/homeassistant/components/nest/legacy/sensor.py b/homeassistant/components/nest/legacy/sensor.py index 34f525ca7a6..9bea3b34ad4 100644 --- a/homeassistant/components/nest/legacy/sensor.py +++ b/homeassistant/components/nest/legacy/sensor.py @@ -1,6 +1,7 @@ """Support for Nest Thermostat sensors for the legacy API.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONF_MONITORED_CONDITIONS, CONF_SENSORS, @@ -149,7 +150,7 @@ async def async_setup_legacy_entry(hass, entry, async_add_entities): async_add_entities(await hass.async_add_executor_job(get_sensors), True) -class NestBasicSensor(NestSensorDevice): +class NestBasicSensor(NestSensorDevice, SensorEntity): """Representation a basic Nest sensor.""" @property @@ -179,7 +180,7 @@ class NestBasicSensor(NestSensorDevice): self._state = getattr(self.device, self.variable) -class NestTempSensor(NestSensorDevice): +class NestTempSensor(NestSensorDevice, SensorEntity): """Representation of a Nest Temperature sensor.""" @property diff --git a/homeassistant/components/netatmo/sensor.py b/homeassistant/components/netatmo/sensor.py index ac86e86b960..cccd3865e54 100644 --- a/homeassistant/components/netatmo/sensor.py +++ b/homeassistant/components/netatmo/sensor.py @@ -1,6 +1,7 @@ """Support for the Netatmo Weather Service.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_LATITUDE, @@ -260,7 +261,7 @@ async def async_config_entry_updated(hass: HomeAssistant, entry: ConfigEntry) -> async_dispatcher_send(hass, f"signal-{DOMAIN}-public-update-{entry.entry_id}") -class NetatmoSensor(NetatmoBase): +class NetatmoSensor(NetatmoBase, SensorEntity): """Implementation of a Netatmo sensor.""" def __init__(self, data_handler, data_class_name, module_info, sensor_type): @@ -489,7 +490,7 @@ def process_wifi(strength): return "Full" -class NetatmoPublicSensor(NetatmoBase): +class NetatmoPublicSensor(NetatmoBase, SensorEntity): """Represent a single sensor in a Netatmo.""" def __init__(self, data_handler, area, sensor_type): diff --git a/homeassistant/components/netdata/sensor.py b/homeassistant/components/netdata/sensor.py index 64c8d789fc7..21e4cd1b005 100644 --- a/homeassistant/components/netdata/sensor.py +++ b/homeassistant/components/netdata/sensor.py @@ -6,7 +6,7 @@ from netdata import Netdata from netdata.exceptions import NetdataError 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_ICON, @@ -18,7 +18,6 @@ from homeassistant.const import ( from homeassistant.exceptions import PlatformNotReady 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__) @@ -97,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(dev, True) -class NetdataSensor(Entity): +class NetdataSensor(SensorEntity): """Implementation of a Netdata sensor.""" def __init__(self, netdata, name, sensor, sensor_name, element, icon, unit, invert): @@ -146,7 +145,7 @@ class NetdataSensor(Entity): ) -class NetdataAlarms(Entity): +class NetdataAlarms(SensorEntity): """Implementation of a Netdata alarm sensor.""" def __init__(self, netdata, name, host, port): diff --git a/homeassistant/components/netgear_lte/sensor.py b/homeassistant/components/netgear_lte/sensor.py index abbedf79d64..c8f07301e98 100644 --- a/homeassistant/components/netgear_lte/sensor.py +++ b/homeassistant/components/netgear_lte/sensor.py @@ -1,5 +1,5 @@ """Support for Netgear LTE sensors.""" -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.exceptions import PlatformNotReady from . import CONF_MONITORED_CONDITIONS, DATA_KEY, LTEEntity @@ -33,7 +33,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info) async_add_entities(sensors) -class LTESensor(LTEEntity): +class LTESensor(LTEEntity, SensorEntity): """Base LTE sensor entity.""" @property diff --git a/homeassistant/components/neurio_energy/sensor.py b/homeassistant/components/neurio_energy/sensor.py index 264d7508347..2bc17fbecb2 100644 --- a/homeassistant/components/neurio_energy/sensor.py +++ b/homeassistant/components/neurio_energy/sensor.py @@ -6,10 +6,9 @@ import neurio import requests.exceptions 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, ENERGY_KILO_WATT_HOUR, POWER_WATT import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle import homeassistant.util.dt as dt_util @@ -123,7 +122,7 @@ class NeurioData: self._daily_usage = round(kwh, 2) -class NeurioEnergy(Entity): +class NeurioEnergy(SensorEntity): """Implementation of a Neurio energy sensor.""" def __init__(self, data, name, sensor_type, update_call): diff --git a/homeassistant/components/nexia/sensor.py b/homeassistant/components/nexia/sensor.py index eff15d443bc..a14931e41ee 100644 --- a/homeassistant/components/nexia/sensor.py +++ b/homeassistant/components/nexia/sensor.py @@ -2,6 +2,7 @@ from nexia.const import UNIT_CELSIUS +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, @@ -149,7 +150,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class NexiaThermostatSensor(NexiaThermostatEntity): +class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity): """Provides Nexia thermostat sensor support.""" def __init__( @@ -196,7 +197,7 @@ class NexiaThermostatSensor(NexiaThermostatEntity): return self._unit_of_measurement -class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity): +class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity): """Nexia Zone Sensor Support.""" def __init__( diff --git a/homeassistant/components/nextbus/sensor.py b/homeassistant/components/nextbus/sensor.py index 3357d84fd69..67d0a4a81d7 100644 --- a/homeassistant/components/nextbus/sensor.py +++ b/homeassistant/components/nextbus/sensor.py @@ -5,10 +5,9 @@ import logging from py_nextbus import NextBusClient 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, DEVICE_CLASS_TIMESTAMP import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util.dt import utc_from_timestamp _LOGGER = logging.getLogger(__name__) @@ -104,7 +103,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([NextBusDepartureSensor(client, agency, route, stop, name)], True) -class NextBusDepartureSensor(Entity): +class NextBusDepartureSensor(SensorEntity): """Sensor class that displays upcoming NextBus times. To function, this requires knowing the agency tag as well as the tags for diff --git a/homeassistant/components/nextcloud/sensor.py b/homeassistant/components/nextcloud/sensor.py index e0be9dde69e..5cd02f124e9 100644 --- a/homeassistant/components/nextcloud/sensor.py +++ b/homeassistant/components/nextcloud/sensor.py @@ -1,5 +1,5 @@ """Summary data from Nextcoud.""" -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from . import DOMAIN, SENSORS @@ -15,7 +15,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class NextcloudSensor(Entity): +class NextcloudSensor(SensorEntity): """Represents a Nextcloud sensor.""" def __init__(self, item): diff --git a/homeassistant/components/nightscout/sensor.py b/homeassistant/components/nightscout/sensor.py index d190da48a16..ea2ea549cec 100644 --- a/homeassistant/components/nightscout/sensor.py +++ b/homeassistant/components/nightscout/sensor.py @@ -9,6 +9,7 @@ from typing import Callable from aiohttp import ClientError from py_nightscout import Api as NightscoutAPI +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_DATE from homeassistant.core import HomeAssistant @@ -33,7 +34,7 @@ async def async_setup_entry( async_add_entities([NightscoutSensor(api, "Blood Sugar", entry.unique_id)], True) -class NightscoutSensor(Entity): +class NightscoutSensor(SensorEntity): """Implementation of a Nightscout sensor.""" def __init__(self, api: NightscoutAPI, name, unique_id): diff --git a/homeassistant/components/nissan_leaf/sensor.py b/homeassistant/components/nissan_leaf/sensor.py index 368db17ab4b..936d607a84e 100644 --- a/homeassistant/components/nissan_leaf/sensor.py +++ b/homeassistant/components/nissan_leaf/sensor.py @@ -1,6 +1,7 @@ """Battery Charge and Range Support for the Nissan Leaf.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.util.distance import LENGTH_KILOMETERS, LENGTH_MILES @@ -35,7 +36,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(devices, True) -class LeafBatterySensor(LeafEntity): +class LeafBatterySensor(LeafEntity, SensorEntity): """Nissan Leaf Battery Sensor.""" @property @@ -65,7 +66,7 @@ class LeafBatterySensor(LeafEntity): return icon_for_battery_level(battery_level=self.state, charging=chargestate) -class LeafRangeSensor(LeafEntity): +class LeafRangeSensor(LeafEntity, SensorEntity): """Nissan Leaf Range Sensor.""" def __init__(self, car, ac_on): diff --git a/homeassistant/components/nmbs/sensor.py b/homeassistant/components/nmbs/sensor.py index ac6753ce0d6..32e4fd87e29 100644 --- a/homeassistant/components/nmbs/sensor.py +++ b/homeassistant/components/nmbs/sensor.py @@ -4,7 +4,7 @@ import logging from pyrail import iRail 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, @@ -14,7 +14,6 @@ from homeassistant.const import ( 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__) @@ -88,7 +87,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class NMBSLiveBoard(Entity): +class NMBSLiveBoard(SensorEntity): """Get the next train from a station's liveboard.""" def __init__(self, api_client, live_station, station_from, station_to): @@ -164,7 +163,7 @@ class NMBSLiveBoard(Entity): ) -class NMBSSensor(Entity): +class NMBSSensor(SensorEntity): """Get the the total travel time for a given connection.""" def __init__( diff --git a/homeassistant/components/noaa_tides/sensor.py b/homeassistant/components/noaa_tides/sensor.py index b6771d9293a..e637e953173 100644 --- a/homeassistant/components/noaa_tides/sensor.py +++ b/homeassistant/components/noaa_tides/sensor.py @@ -6,7 +6,7 @@ import noaa_coops as coops import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_NAME, @@ -15,7 +15,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__) @@ -72,7 +71,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([noaa_sensor], True) -class NOAATidesAndCurrentsSensor(Entity): +class NOAATidesAndCurrentsSensor(SensorEntity): """Representation of a NOAA Tides and Currents sensor.""" def __init__(self, name, station_id, timezone, unit_system, station): diff --git a/homeassistant/components/notion/sensor.py b/homeassistant/components/notion/sensor.py index 978e0aac46a..4f034408fe2 100644 --- a/homeassistant/components/notion/sensor.py +++ b/homeassistant/components/notion/sensor.py @@ -1,6 +1,7 @@ """Support for Notion sensors.""" from typing import Callable +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import TEMP_CELSIUS from homeassistant.core import HomeAssistant, callback @@ -42,7 +43,7 @@ async def async_setup_entry( async_add_entities(sensor_list) -class NotionSensor(NotionEntity): +class NotionSensor(NotionEntity, SensorEntity): """Define a Notion sensor.""" def __init__( diff --git a/homeassistant/components/nsw_fuel_station/sensor.py b/homeassistant/components/nsw_fuel_station/sensor.py index 92a071ec439..6c8061294e9 100644 --- a/homeassistant/components/nsw_fuel_station/sensor.py +++ b/homeassistant/components/nsw_fuel_station/sensor.py @@ -7,10 +7,9 @@ import logging from nsw_fuel import FuelCheckClient, FuelCheckError 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, CURRENCY_CENT, VOLUME_LITERS import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -146,7 +145,7 @@ class StationPriceData: return self._station_name -class StationPriceSensor(Entity): +class StationPriceSensor(SensorEntity): """Implementation of a sensor that reports the fuel price for a station.""" def __init__(self, station_data: StationPriceData, fuel_type: str): diff --git a/homeassistant/components/numato/sensor.py b/homeassistant/components/numato/sensor.py index e268d32a293..19372de5258 100644 --- a/homeassistant/components/numato/sensor.py +++ b/homeassistant/components/numato/sensor.py @@ -3,8 +3,8 @@ import logging from numato_gpio import NumatoGpioError +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_ID, CONF_NAME, CONF_SENSORS -from homeassistant.helpers.entity import Entity from . import ( CONF_DEVICES, @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class NumatoGpioAdc(Entity): +class NumatoGpioAdc(SensorEntity): """Represents an ADC port of a Numato USB GPIO expander.""" def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api): diff --git a/homeassistant/components/nut/sensor.py b/homeassistant/components/nut/sensor.py index d4fdd03adc8..2e3826935fe 100644 --- a/homeassistant/components/nut/sensor.py +++ b/homeassistant/components/nut/sensor.py @@ -1,6 +1,7 @@ """Provides a sensor to track various status aspects of a UPS.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_STATE, CONF_RESOURCES, STATE_UNKNOWN from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -76,7 +77,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class NUTSensor(CoordinatorEntity): +class NUTSensor(CoordinatorEntity, SensorEntity): """Representation of a sensor entity for NUT status values.""" def __init__( diff --git a/homeassistant/components/nzbget/sensor.py b/homeassistant/components/nzbget/sensor.py index a8870db52a3..54a88c89f53 100644 --- a/homeassistant/components/nzbget/sensor.py +++ b/homeassistant/components/nzbget/sensor.py @@ -5,6 +5,7 @@ from datetime import timedelta import logging from typing import Callable +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_NAME, @@ -66,7 +67,7 @@ async def async_setup_entry( async_add_entities(sensors) -class NZBGetSensor(NZBGetEntity): +class NZBGetSensor(NZBGetEntity, SensorEntity): """Representation of a NZBGet sensor.""" def __init__( diff --git a/homeassistant/components/oasa_telematics/sensor.py b/homeassistant/components/oasa_telematics/sensor.py index 8af74b5cd0e..71af8dacba2 100644 --- a/homeassistant/components/oasa_telematics/sensor.py +++ b/homeassistant/components/oasa_telematics/sensor.py @@ -6,10 +6,9 @@ from operator import itemgetter import oasatelematics 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, DEVICE_CLASS_TIMESTAMP import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([OASATelematicsSensor(data, stop_id, route_id, name)], True) -class OASATelematicsSensor(Entity): +class OASATelematicsSensor(SensorEntity): """Implementation of the OASA Telematics sensor.""" def __init__(self, data, stop_id, route_id, name): diff --git a/homeassistant/components/obihai/sensor.py b/homeassistant/components/obihai/sensor.py index c105b91971d..9aacaa84193 100644 --- a/homeassistant/components/obihai/sensor.py +++ b/homeassistant/components/obihai/sensor.py @@ -5,7 +5,7 @@ import logging from pyobihai import PyObihai 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, @@ -13,7 +13,6 @@ from homeassistant.const import ( DEVICE_CLASS_TIMESTAMP, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -69,7 +68,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class ObihaiServiceSensors(Entity): +class ObihaiServiceSensors(SensorEntity): """Get the status of each Obihai Lines.""" def __init__(self, pyobihai, serial, service_name): diff --git a/homeassistant/components/octoprint/sensor.py b/homeassistant/components/octoprint/sensor.py index 921f355edbe..f2c5c56c58a 100644 --- a/homeassistant/components/octoprint/sensor.py +++ b/homeassistant/components/octoprint/sensor.py @@ -3,8 +3,8 @@ import logging import requests +from homeassistant.components.sensor import SensorEntity from homeassistant.const import PERCENTAGE, TEMP_CELSIUS -from homeassistant.helpers.entity import Entity from . import DOMAIN as COMPONENT_DOMAIN, SENSOR_TYPES @@ -71,7 +71,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class OctoPrintSensor(Entity): +class OctoPrintSensor(SensorEntity): """Representation of an OctoPrint sensor.""" def __init__( diff --git a/homeassistant/components/ohmconnect/sensor.py b/homeassistant/components/ohmconnect/sensor.py index 6c7c04b25cb..b53c35e17b5 100644 --- a/homeassistant/components/ohmconnect/sensor.py +++ b/homeassistant/components/ohmconnect/sensor.py @@ -6,10 +6,9 @@ import defusedxml.ElementTree as ET 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_ID, CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -34,7 +33,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([OhmconnectSensor(name, ohmid)], True) -class OhmconnectSensor(Entity): +class OhmconnectSensor(SensorEntity): """Representation of a OhmConnect sensor.""" def __init__(self, name, ohmid): diff --git a/homeassistant/components/ombi/sensor.py b/homeassistant/components/ombi/sensor.py index 2a2f50532b4..8c08b026b28 100644 --- a/homeassistant/components/ombi/sensor.py +++ b/homeassistant/components/ombi/sensor.py @@ -4,7 +4,7 @@ import logging from pyombi import OmbiError -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from .const import DOMAIN, SENSOR_TYPES @@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class OmbiSensor(Entity): +class OmbiSensor(SensorEntity): """Representation of an Ombi sensor.""" def __init__(self, label, sensor_type, ombi, icon): diff --git a/homeassistant/components/omnilogic/sensor.py b/homeassistant/components/omnilogic/sensor.py index e1b4b387a46..25457224e9f 100644 --- a/homeassistant/components/omnilogic/sensor.py +++ b/homeassistant/components/omnilogic/sensor.py @@ -1,5 +1,5 @@ """Definition and setup of the Omnilogic Sensors for Home Assistant.""" -from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE +from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE, SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, MASS_GRAMS, @@ -59,7 +59,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class OmnilogicSensor(OmniLogicEntity): +class OmnilogicSensor(OmniLogicEntity, SensorEntity): """Defines an Omnilogic sensor entity.""" def __init__( diff --git a/homeassistant/components/ondilo_ico/sensor.py b/homeassistant/components/ondilo_ico/sensor.py index b34ee4eae35..3af2bb7c326 100644 --- a/homeassistant/components/ondilo_ico/sensor.py +++ b/homeassistant/components/ondilo_ico/sensor.py @@ -4,6 +4,7 @@ import logging from ondilo import OndiloError +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEVICE_CLASS_BATTERY, @@ -83,7 +84,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class OndiloICO(CoordinatorEntity): +class OndiloICO(CoordinatorEntity, SensorEntity): """Representation of a Sensor.""" def __init__( diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index 4888383fa42..ba988aba226 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -6,7 +6,7 @@ import os from pi1wire import InvalidCRCException, UnsupportResponseException 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, CONF_PORT, CONF_TYPE import homeassistant.helpers.config_validation as cv @@ -394,7 +394,7 @@ def get_entities(onewirehub: OneWireHub, config): return entities -class OneWireProxySensor(OneWireProxyEntity): +class OneWireProxySensor(OneWireProxyEntity, SensorEntity): """Implementation of a 1-Wire sensor connected through owserver.""" @property @@ -403,7 +403,7 @@ class OneWireProxySensor(OneWireProxyEntity): return self._state -class OneWireDirectSensor(OneWireBaseEntity): +class OneWireDirectSensor(OneWireBaseEntity, SensorEntity): """Implementation of a 1-Wire sensor directly connected to RPI GPIO.""" def __init__(self, name, device_file, device_info, owsensor): @@ -431,7 +431,7 @@ class OneWireDirectSensor(OneWireBaseEntity): self._state = value -class OneWireOWFSSensor(OneWireBaseEntity): # pragma: no cover +class OneWireOWFSSensor(OneWireBaseEntity, SensorEntity): # pragma: no cover """Implementation of a 1-Wire sensor through owfs. This part of the implementation does not conform to policy regarding 3rd-party libraries, and will not longer be updated. diff --git a/homeassistant/components/onvif/sensor.py b/homeassistant/components/onvif/sensor.py index 3895e8a4abb..1c5766e3969 100644 --- a/homeassistant/components/onvif/sensor.py +++ b/homeassistant/components/onvif/sensor.py @@ -1,6 +1,7 @@ """Support for ONVIF binary sensors.""" from __future__ import annotations +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from .base import ONVIFBaseEntity @@ -33,7 +34,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): return True -class ONVIFSensor(ONVIFBaseEntity): +class ONVIFSensor(ONVIFBaseEntity, SensorEntity): """Representation of a ONVIF sensor event.""" def __init__(self, uid, device): diff --git a/homeassistant/components/openerz/sensor.py b/homeassistant/components/openerz/sensor.py index 9a5bf3a9813..33305b677de 100644 --- a/homeassistant/components/openerz/sensor.py +++ b/homeassistant/components/openerz/sensor.py @@ -4,9 +4,9 @@ from datetime import timedelta from openerz_api.main import OpenERZConnector import voluptuous as vol +from homeassistant.components.sensor import SensorEntity import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import PLATFORM_SCHEMA -from homeassistant.helpers.entity import Entity SCAN_INTERVAL = timedelta(hours=12) @@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([OpenERZSensor(api_connector, config.get(CONF_NAME))], True) -class OpenERZSensor(Entity): +class OpenERZSensor(SensorEntity): """Representation of a Sensor.""" def __init__(self, api_connector, name): diff --git a/homeassistant/components/openevse/sensor.py b/homeassistant/components/openevse/sensor.py index e0f21f6946d..d7d4149e26d 100644 --- a/homeassistant/components/openevse/sensor.py +++ b/homeassistant/components/openevse/sensor.py @@ -5,7 +5,7 @@ import openevsewifi from requests 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_MONITORED_VARIABLES, @@ -14,7 +14,6 @@ from homeassistant.const import ( TIME_MINUTES, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class OpenEVSESensor(Entity): +class OpenEVSESensor(SensorEntity): """Implementation of an OpenEVSE sensor.""" def __init__(self, sensor_type, charger): diff --git a/homeassistant/components/openexchangerates/sensor.py b/homeassistant/components/openexchangerates/sensor.py index f3f0d825ff6..8474cdab131 100644 --- a/homeassistant/components/openexchangerates/sensor.py +++ b/homeassistant/components/openexchangerates/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 ( 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.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -58,7 +57,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([OpenexchangeratesSensor(rest, name, quote)], True) -class OpenexchangeratesSensor(Entity): +class OpenexchangeratesSensor(SensorEntity): """Representation of an Open Exchange Rates sensor.""" def __init__(self, rest, name, quote): diff --git a/homeassistant/components/openhardwaremonitor/sensor.py b/homeassistant/components/openhardwaremonitor/sensor.py index 3254f0824f1..70d0d36176c 100644 --- a/homeassistant/components/openhardwaremonitor/sensor.py +++ b/homeassistant/components/openhardwaremonitor/sensor.py @@ -5,11 +5,10 @@ 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_PORT from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.util.dt import utcnow @@ -44,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(data.devices, True) -class OpenHardwareMonitorDevice(Entity): +class OpenHardwareMonitorDevice(SensorEntity): """Device used to display information from OpenHardwareMonitor.""" def __init__(self, data, name, path, unit_of_measurement): diff --git a/homeassistant/components/opensky/sensor.py b/homeassistant/components/opensky/sensor.py index e5ffb2384f5..122388b85b7 100644 --- a/homeassistant/components/opensky/sensor.py +++ b/homeassistant/components/opensky/sensor.py @@ -4,7 +4,7 @@ from datetime import timedelta import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_LATITUDE, @@ -17,7 +17,6 @@ from homeassistant.const import ( LENGTH_METERS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import distance as util_distance, location as util_location CONF_ALTITUDE = "altitude" @@ -87,7 +86,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class OpenSkySensor(Entity): +class OpenSkySensor(SensorEntity): """Open Sky Network Sensor.""" def __init__(self, hass, name, latitude, longitude, radius, altitude): diff --git a/homeassistant/components/opentherm_gw/sensor.py b/homeassistant/components/opentherm_gw/sensor.py index 4a20aa651cd..1d9904ea59f 100644 --- a/homeassistant/components/opentherm_gw/sensor.py +++ b/homeassistant/components/opentherm_gw/sensor.py @@ -2,11 +2,11 @@ import logging from pprint import pformat -from homeassistant.components.sensor import ENTITY_ID_FORMAT +from homeassistant.components.sensor import ENTITY_ID_FORMAT, SensorEntity from homeassistant.const import CONF_ID from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity, async_generate_entity_id +from homeassistant.helpers.entity import async_generate_entity_id from homeassistant.helpers.entity_registry import async_get_registry from . import DOMAIN @@ -77,7 +77,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors) -class OpenThermSensor(Entity): +class OpenThermSensor(SensorEntity): """Representation of an OpenTherm Gateway sensor.""" def __init__(self, gw_dev, var, source, device_class, unit, friendly_name_format): diff --git a/homeassistant/components/openuv/sensor.py b/homeassistant/components/openuv/sensor.py index b9c73023c11..654a89cfcf9 100644 --- a/homeassistant/components/openuv/sensor.py +++ b/homeassistant/components/openuv/sensor.py @@ -1,4 +1,5 @@ """Support for OpenUV sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import TIME_MINUTES, UV_INDEX from homeassistant.core import callback from homeassistant.util.dt import as_local, parse_datetime @@ -87,7 +88,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors, True) -class OpenUvSensor(OpenUvEntity): +class OpenUvSensor(OpenUvEntity, SensorEntity): """Define a binary sensor for OpenUV.""" def __init__(self, openuv, sensor_type, name, icon, unit, entry_id): diff --git a/homeassistant/components/openweathermap/abstract_owm_sensor.py b/homeassistant/components/openweathermap/abstract_owm_sensor.py index a69f542589b..30a21a057f0 100644 --- a/homeassistant/components/openweathermap/abstract_owm_sensor.py +++ b/homeassistant/components/openweathermap/abstract_owm_sensor.py @@ -1,12 +1,12 @@ """Abstraction form OWM sensors.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ATTR_ATTRIBUTION -from homeassistant.helpers.entity import Entity from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from .const import ATTRIBUTION, SENSOR_DEVICE_CLASS, SENSOR_NAME, SENSOR_UNIT -class AbstractOpenWeatherMapSensor(Entity): +class AbstractOpenWeatherMapSensor(SensorEntity): """Abstract class for an OpenWeatherMap sensor.""" def __init__( diff --git a/homeassistant/components/oru/sensor.py b/homeassistant/components/oru/sensor.py index d6620ed39e5..063c0c6169d 100644 --- a/homeassistant/components/oru/sensor.py +++ b/homeassistant/components/oru/sensor.py @@ -5,10 +5,9 @@ import logging from oru import Meter, MeterError import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ENERGY_KILO_WATT_HOUR import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -39,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): _LOGGER.debug("Oru meter_number = %s", meter_number) -class CurrentEnergyUsageSensor(Entity): +class CurrentEnergyUsageSensor(SensorEntity): """Representation of the sensor.""" def __init__(self, meter): diff --git a/homeassistant/components/otp/sensor.py b/homeassistant/components/otp/sensor.py index 9f23f5ae6fa..7aee9d99208 100644 --- a/homeassistant/components/otp/sensor.py +++ b/homeassistant/components/otp/sensor.py @@ -4,11 +4,10 @@ import time import pyotp 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_TOKEN from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity DEFAULT_NAME = "OTP Sensor" @@ -34,7 +33,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= # Only TOTP supported at the moment, HOTP might be added later -class TOTPSensor(Entity): +class TOTPSensor(SensorEntity): """Representation of a TOTP sensor.""" def __init__(self, name, token): diff --git a/homeassistant/components/ovo_energy/sensor.py b/homeassistant/components/ovo_energy/sensor.py index 3171b3231dc..d03f7c49f96 100644 --- a/homeassistant/components/ovo_energy/sensor.py +++ b/homeassistant/components/ovo_energy/sensor.py @@ -4,6 +4,7 @@ from datetime import timedelta from ovoenergy import OVODailyUsage from ovoenergy.ovoenergy import OVOEnergy +from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -53,7 +54,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class OVOEnergySensor(OVOEnergyDeviceEntity): +class OVOEnergySensor(OVOEnergyDeviceEntity, SensorEntity): """Defines a OVO Energy sensor.""" def __init__( diff --git a/homeassistant/components/ozw/sensor.py b/homeassistant/components/ozw/sensor.py index db695bcf6bc..3c3d4c3ca36 100644 --- a/homeassistant/components/ozw/sensor.py +++ b/homeassistant/components/ozw/sensor.py @@ -12,6 +12,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, DOMAIN as SENSOR_DOMAIN, + SensorEntity, ) from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.core import callback @@ -57,7 +58,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class ZwaveSensorBase(ZWaveDeviceEntity): +class ZwaveSensorBase(ZWaveDeviceEntity, SensorEntity): """Basic Representation of a Z-Wave sensor.""" @property diff --git a/homeassistant/components/pi_hole/sensor.py b/homeassistant/components/pi_hole/sensor.py index 4bd4c7b7f6f..517e8cfcf17 100644 --- a/homeassistant/components/pi_hole/sensor.py +++ b/homeassistant/components/pi_hole/sensor.py @@ -1,5 +1,6 @@ """Support for getting statistical data from a Pi-hole system.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME from . import PiHoleEntity @@ -30,7 +31,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(sensors, True) -class PiHoleSensor(PiHoleEntity): +class PiHoleSensor(PiHoleEntity, SensorEntity): """Representation of a Pi-hole sensor.""" def __init__(self, api, coordinator, name, sensor_name, server_unique_id): diff --git a/homeassistant/components/pilight/sensor.py b/homeassistant/components/pilight/sensor.py index e8c7b4bd4b6..97458acd5fc 100644 --- a/homeassistant/components/pilight/sensor.py +++ b/homeassistant/components/pilight/sensor.py @@ -4,10 +4,9 @@ import logging import voluptuous as vol from homeassistant.components import pilight -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_NAME, CONF_PAYLOAD, CONF_UNIT_OF_MEASUREMENT import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -39,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class PilightSensor(Entity): +class PilightSensor(SensorEntity): """Representation of a sensor that can be updated using Pilight.""" def __init__(self, hass, name, variable, payload, unit_of_measurement): diff --git a/homeassistant/components/plaato/sensor.py b/homeassistant/components/plaato/sensor.py index c2c59d347f3..0812a2fd585 100644 --- a/homeassistant/components/plaato/sensor.py +++ b/homeassistant/components/plaato/sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from pyplaato.models.device import PlaatoDevice from pyplaato.plaato import PlaatoKeg -from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE +from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE, SensorEntity from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send, @@ -59,7 +59,7 @@ async def async_setup_entry(hass, entry, async_add_entities): ) -class PlaatoSensor(PlaatoEntity): +class PlaatoSensor(PlaatoEntity, SensorEntity): """Representation of a Plaato Sensor.""" @property diff --git a/homeassistant/components/plex/sensor.py b/homeassistant/components/plex/sensor.py index 47dd05a557b..d79c4120dc7 100644 --- a/homeassistant/components/plex/sensor.py +++ b/homeassistant/components/plex/sensor.py @@ -1,9 +1,9 @@ """Support for Plex media server monitoring.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.dispatcher import async_dispatcher_connect -from homeassistant.helpers.entity import Entity from .const import ( CONF_SERVER_IDENTIFIER, @@ -25,7 +25,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities([sensor]) -class PlexSensor(Entity): +class PlexSensor(SensorEntity): """Representation of a Plex now playing sensor.""" def __init__(self, hass, plex_server): diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index f57ff2b2a91..4152f9fdabd 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -2,6 +2,7 @@ import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, @@ -17,7 +18,6 @@ from homeassistant.const import ( VOLUME_CUBIC_METERS, ) from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from .const import ( COOL_ICON, @@ -236,7 +236,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class SmileSensor(SmileGateway): +class SmileSensor(SmileGateway, SensorEntity): """Represent Smile Sensors.""" def __init__(self, api, coordinator, name, dev_id, sensor): @@ -282,7 +282,7 @@ class SmileSensor(SmileGateway): return self._unit_of_measurement -class PwThermostatSensor(SmileSensor, Entity): +class PwThermostatSensor(SmileSensor): """Thermostat (or generic) sensor devices.""" def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type): @@ -311,7 +311,7 @@ class PwThermostatSensor(SmileSensor, Entity): self.async_write_ha_state() -class PwAuxDeviceSensor(SmileSensor, Entity): +class PwAuxDeviceSensor(SmileSensor): """Auxiliary Device Sensors.""" def __init__(self, api, coordinator, name, dev_id, sensor): @@ -348,7 +348,7 @@ class PwAuxDeviceSensor(SmileSensor, Entity): self.async_write_ha_state() -class PwPowerSensor(SmileSensor, Entity): +class PwPowerSensor(SmileSensor): """Power sensor entities.""" def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type, model): diff --git a/homeassistant/components/pocketcasts/sensor.py b/homeassistant/components/pocketcasts/sensor.py index 19f7e265438..55ae4a524fc 100644 --- a/homeassistant/components/pocketcasts/sensor.py +++ b/homeassistant/components/pocketcasts/sensor.py @@ -5,10 +5,9 @@ import logging from pycketcasts import pocketcasts 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 import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -37,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return False -class PocketCastsSensor(Entity): +class PocketCastsSensor(SensorEntity): """Representation of a pocket casts sensor.""" def __init__(self, api): diff --git a/homeassistant/components/point/sensor.py b/homeassistant/components/point/sensor.py index 87f9a8ab2fe..338ed275f50 100644 --- a/homeassistant/components/point/sensor.py +++ b/homeassistant/components/point/sensor.py @@ -1,7 +1,7 @@ """Support for Minut Point sensors.""" import logging -from homeassistant.components.sensor import DOMAIN +from homeassistant.components.sensor import DOMAIN, SensorEntity from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE, @@ -47,7 +47,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class MinutPointSensor(MinutPointEntity): +class MinutPointSensor(MinutPointEntity, SensorEntity): """The platform class required by Home Assistant.""" def __init__(self, point_client, device_id, device_class): diff --git a/homeassistant/components/poolsense/sensor.py b/homeassistant/components/poolsense/sensor.py index bf5c3eb0163..ca79fde6b08 100644 --- a/homeassistant/components/poolsense/sensor.py +++ b/homeassistant/components/poolsense/sensor.py @@ -1,4 +1,5 @@ """Sensor platform for the PoolSense sensor.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_EMAIL, @@ -8,7 +9,6 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, ) -from homeassistant.helpers.entity import Entity from . import PoolSenseEntity from .const import ATTRIBUTION, DOMAIN @@ -79,7 +79,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(sensors_list, False) -class PoolSenseSensor(PoolSenseEntity, Entity): +class PoolSenseSensor(PoolSenseEntity, SensorEntity): """Sensor representing poolsense data.""" @property diff --git a/homeassistant/components/powerwall/sensor.py b/homeassistant/components/powerwall/sensor.py index 3b4d7918cf7..36f803e66d7 100644 --- a/homeassistant/components/powerwall/sensor.py +++ b/homeassistant/components/powerwall/sensor.py @@ -3,6 +3,7 @@ import logging from tesla_powerwall import MeterType +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER, PERCENTAGE from .const import ( @@ -59,7 +60,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class PowerWallChargeSensor(PowerWallEntity): +class PowerWallChargeSensor(PowerWallEntity, SensorEntity): """Representation of an Powerwall charge sensor.""" @property @@ -88,7 +89,7 @@ class PowerWallChargeSensor(PowerWallEntity): return round(self.coordinator.data[POWERWALL_API_CHARGE]) -class PowerWallEnergySensor(PowerWallEntity): +class PowerWallEnergySensor(PowerWallEntity, SensorEntity): """Representation of an Powerwall Energy sensor.""" def __init__( diff --git a/homeassistant/components/pushbullet/sensor.py b/homeassistant/components/pushbullet/sensor.py index f7aaa693c67..4f8ec6a1700 100644 --- a/homeassistant/components/pushbullet/sensor.py +++ b/homeassistant/components/pushbullet/sensor.py @@ -5,10 +5,9 @@ import threading from pushbullet import InvalidKeyError, Listener, PushBullet 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_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class PushBulletNotificationSensor(Entity): +class PushBulletNotificationSensor(SensorEntity): """Representation of a Pushbullet Sensor.""" def __init__(self, pb, element): diff --git a/homeassistant/components/pvoutput/sensor.py b/homeassistant/components/pvoutput/sensor.py index 9e88cb0a664..eb461061dcc 100644 --- a/homeassistant/components/pvoutput/sensor.py +++ b/homeassistant/components/pvoutput/sensor.py @@ -6,7 +6,7 @@ import logging 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 ( ATTR_DATE, ATTR_TEMPERATURE, @@ -17,7 +17,6 @@ from homeassistant.const import ( ) from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _ENDPOINT = "http://pvoutput.org/service/r2/getstatus.jsp" @@ -64,7 +63,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([PvoutputSensor(rest, name)]) -class PvoutputSensor(Entity): +class PvoutputSensor(SensorEntity): """Representation of a PVOutput sensor.""" def __init__(self, rest, name): diff --git a/homeassistant/components/pvpc_hourly_pricing/sensor.py b/homeassistant/components/pvpc_hourly_pricing/sensor.py index 3aca4db67e7..5fe65e3dc65 100644 --- a/homeassistant/components/pvpc_hourly_pricing/sensor.py +++ b/homeassistant/components/pvpc_hourly_pricing/sensor.py @@ -7,6 +7,7 @@ from random import randint from aiopvpc import PVPCData from homeassistant import config_entries +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_NAME, CURRENCY_EURO, ENERGY_KILO_WATT_HOUR from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -42,7 +43,7 @@ async def async_setup_entry( ) -class ElecPriceSensor(RestoreEntity): +class ElecPriceSensor(RestoreEntity, SensorEntity): """Class to hold the prices of electricity as a sensor.""" unit_of_measurement = UNIT diff --git a/homeassistant/components/pyload/sensor.py b/homeassistant/components/pyload/sensor.py index 6539479d2cd..c439d5181be 100644 --- a/homeassistant/components/pyload/sensor.py +++ b/homeassistant/components/pyload/sensor.py @@ -6,7 +6,7 @@ from aiohttp.hdrs import CONTENT_TYPE 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_VARIABLES, @@ -19,7 +19,6 @@ from homeassistant.const import ( DATA_RATE_MEGABYTES_PER_SECOND, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -77,7 +76,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class PyLoadSensor(Entity): +class PyLoadSensor(SensorEntity): """Representation of a pyLoad sensor.""" def __init__(self, api, sensor_type, client_name): diff --git a/homeassistant/components/qbittorrent/sensor.py b/homeassistant/components/qbittorrent/sensor.py index cd67355d883..251407099b1 100644 --- a/homeassistant/components/qbittorrent/sensor.py +++ b/homeassistant/components/qbittorrent/sensor.py @@ -5,7 +5,7 @@ from qbittorrent.client import Client, LoginRequired 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_NAME, CONF_PASSWORD, @@ -16,7 +16,6 @@ from homeassistant.const import ( ) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -71,7 +70,7 @@ def format_speed(speed): return round(kb_spd, 2 if kb_spd < 0.1 else 1) -class QBittorrentSensor(Entity): +class QBittorrentSensor(SensorEntity): """Representation of an qBittorrent sensor.""" def __init__(self, sensor_type, qbittorrent_client, client_name, exception): diff --git a/homeassistant/components/qnap/sensor.py b/homeassistant/components/qnap/sensor.py index 5f7695e5a60..5759713e80c 100644 --- a/homeassistant/components/qnap/sensor.py +++ b/homeassistant/components/qnap/sensor.py @@ -5,7 +5,7 @@ import logging from qnapstats import QNAPStats 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_HOST, @@ -23,7 +23,6 @@ from homeassistant.const import ( ) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -200,7 +199,7 @@ class QNAPStatsAPI: _LOGGER.exception("Failed to fetch QNAP stats from the NAS") -class QNAPSensor(Entity): +class QNAPSensor(SensorEntity): """Base class for a QNAP sensor.""" def __init__(self, api, variable, variable_info, monitor_device=None): diff --git a/homeassistant/components/qwikswitch/sensor.py b/homeassistant/components/qwikswitch/sensor.py index 53cf68ccdba..f6d0ce7ec28 100644 --- a/homeassistant/components/qwikswitch/sensor.py +++ b/homeassistant/components/qwikswitch/sensor.py @@ -3,6 +3,7 @@ import logging from pyqwikswitch.qwikswitch import SENSORS +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from . import DOMAIN as QWIKSWITCH, QSEntity @@ -21,7 +22,7 @@ async def async_setup_platform(hass, _, add_entities, discovery_info=None): add_entities(devs) -class QSSensor(QSEntity): +class QSSensor(QSEntity, SensorEntity): """Sensor based on a Qwikswitch relay/dimmer module.""" _val = None