Migrate integrations n-q to extend SensorEntity (#48214)

This commit is contained in:
Erik Montnemery 2021-03-22 19:46:46 +01:00 committed by GitHub
parent 339a56e434
commit c900e3030b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 129 additions and 136 deletions

View File

@ -1,5 +1,5 @@
"""Support for N26 bank account sensors.""" """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 . import DEFAULT_SCAN_INTERVAL, DOMAIN, timestamp_ms_to_date
from .const import DATA from .const import DATA
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensor_entities) add_entities(sensor_entities)
class N26Account(Entity): class N26Account(SensorEntity):
"""Sensor for a N26 balance account. """Sensor for a N26 balance account.
A balance account contains an amount of money (=balance). The amount may A balance account contains an amount of money (=balance). The amount may
@ -117,7 +117,7 @@ class N26Account(Entity):
return ICON_ACCOUNT return ICON_ACCOUNT
class N26Card(Entity): class N26Card(SensorEntity):
"""Sensor for a N26 card.""" """Sensor for a N26 card."""
def __init__(self, api_data, card) -> None: def __init__(self, api_data, card) -> None:
@ -186,7 +186,7 @@ class N26Card(Entity):
return ICON_CARD return ICON_CARD
class N26Space(Entity): class N26Space(SensorEntity):
"""Sensor for a N26 space.""" """Sensor for a N26 space."""
def __init__(self, api_data, space) -> None: def __init__(self, api_data, space) -> None:

View File

@ -4,9 +4,8 @@ import logging
from pybotvac.exceptions import NeatoRobotException 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.const import PERCENTAGE
from homeassistant.helpers.entity import Entity
from .const import NEATO_DOMAIN, NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES 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) async_add_entities(dev, True)
class NeatoSensor(Entity): class NeatoSensor(SensorEntity):
"""Neato sensor.""" """Neato sensor."""
def __init__(self, neato, robot): def __init__(self, neato, robot):

View File

@ -7,11 +7,10 @@ from ns_api import RequestParametersError
import requests import requests
import voluptuous as vol 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.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -94,7 +93,7 @@ def valid_stations(stations, given_stations):
return True return True
class NSDepartureSensor(Entity): class NSDepartureSensor(SensorEntity):
"""Implementation of a NS Departure Sensor.""" """Implementation of a NS Departure Sensor."""
def __init__(self, nsapi, name, departure, heading, via, time): def __init__(self, nsapi, name, departure, heading, via, time):

View File

@ -1,6 +1,7 @@
"""Support for Nest Thermostat sensors for the legacy API.""" """Support for Nest Thermostat sensors for the legacy API."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_MONITORED_CONDITIONS, CONF_MONITORED_CONDITIONS,
CONF_SENSORS, 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) async_add_entities(await hass.async_add_executor_job(get_sensors), True)
class NestBasicSensor(NestSensorDevice): class NestBasicSensor(NestSensorDevice, SensorEntity):
"""Representation a basic Nest sensor.""" """Representation a basic Nest sensor."""
@property @property
@ -179,7 +180,7 @@ class NestBasicSensor(NestSensorDevice):
self._state = getattr(self.device, self.variable) self._state = getattr(self.device, self.variable)
class NestTempSensor(NestSensorDevice): class NestTempSensor(NestSensorDevice, SensorEntity):
"""Representation of a Nest Temperature sensor.""" """Representation of a Nest Temperature sensor."""
@property @property

View File

@ -1,6 +1,7 @@
"""Support for the Netatmo Weather Service.""" """Support for the Netatmo Weather Service."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_LATITUDE, 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}") async_dispatcher_send(hass, f"signal-{DOMAIN}-public-update-{entry.entry_id}")
class NetatmoSensor(NetatmoBase): class NetatmoSensor(NetatmoBase, SensorEntity):
"""Implementation of a Netatmo sensor.""" """Implementation of a Netatmo sensor."""
def __init__(self, data_handler, data_class_name, module_info, sensor_type): def __init__(self, data_handler, data_class_name, module_info, sensor_type):
@ -489,7 +490,7 @@ def process_wifi(strength):
return "Full" return "Full"
class NetatmoPublicSensor(NetatmoBase): class NetatmoPublicSensor(NetatmoBase, SensorEntity):
"""Represent a single sensor in a Netatmo.""" """Represent a single sensor in a Netatmo."""
def __init__(self, data_handler, area, sensor_type): def __init__(self, data_handler, area, sensor_type):

View File

@ -6,7 +6,7 @@ from netdata import Netdata
from netdata.exceptions import NetdataError from netdata.exceptions import NetdataError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_ICON, CONF_ICON,
@ -18,7 +18,6 @@ from homeassistant.const import (
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _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) async_add_entities(dev, True)
class NetdataSensor(Entity): class NetdataSensor(SensorEntity):
"""Implementation of a Netdata sensor.""" """Implementation of a Netdata sensor."""
def __init__(self, netdata, name, sensor, sensor_name, element, icon, unit, invert): 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.""" """Implementation of a Netdata alarm sensor."""
def __init__(self, netdata, name, host, port): def __init__(self, netdata, name, host, port):

View File

@ -1,5 +1,5 @@
"""Support for Netgear LTE sensors.""" """Support for Netgear LTE sensors."""
from homeassistant.components.sensor import DOMAIN from homeassistant.components.sensor import DOMAIN, SensorEntity
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from . import CONF_MONITORED_CONDITIONS, DATA_KEY, LTEEntity 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) async_add_entities(sensors)
class LTESensor(LTEEntity): class LTESensor(LTEEntity, SensorEntity):
"""Base LTE sensor entity.""" """Base LTE sensor entity."""
@property @property

View File

@ -6,10 +6,9 @@ import neurio
import requests.exceptions import requests.exceptions
import voluptuous as vol 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 from homeassistant.const import CONF_API_KEY, ENERGY_KILO_WATT_HOUR, POWER_WATT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -123,7 +122,7 @@ class NeurioData:
self._daily_usage = round(kwh, 2) self._daily_usage = round(kwh, 2)
class NeurioEnergy(Entity): class NeurioEnergy(SensorEntity):
"""Implementation of a Neurio energy sensor.""" """Implementation of a Neurio energy sensor."""
def __init__(self, data, name, sensor_type, update_call): def __init__(self, data, name, sensor_type, update_call):

View File

@ -2,6 +2,7 @@
from nexia.const import UNIT_CELSIUS from nexia.const import UNIT_CELSIUS
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
@ -149,7 +150,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class NexiaThermostatSensor(NexiaThermostatEntity): class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
"""Provides Nexia thermostat sensor support.""" """Provides Nexia thermostat sensor support."""
def __init__( def __init__(
@ -196,7 +197,7 @@ class NexiaThermostatSensor(NexiaThermostatEntity):
return self._unit_of_measurement return self._unit_of_measurement
class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity): class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
"""Nexia Zone Sensor Support.""" """Nexia Zone Sensor Support."""
def __init__( def __init__(

View File

@ -5,10 +5,9 @@ import logging
from py_nextbus import NextBusClient from py_nextbus import NextBusClient
import voluptuous as vol 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 from homeassistant.const import CONF_NAME, DEVICE_CLASS_TIMESTAMP
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util.dt import utc_from_timestamp from homeassistant.util.dt import utc_from_timestamp
_LOGGER = logging.getLogger(__name__) _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) add_entities([NextBusDepartureSensor(client, agency, route, stop, name)], True)
class NextBusDepartureSensor(Entity): class NextBusDepartureSensor(SensorEntity):
"""Sensor class that displays upcoming NextBus times. """Sensor class that displays upcoming NextBus times.
To function, this requires knowing the agency tag as well as the tags for To function, this requires knowing the agency tag as well as the tags for

View File

@ -1,5 +1,5 @@
"""Summary data from Nextcoud.""" """Summary data from Nextcoud."""
from homeassistant.helpers.entity import Entity from homeassistant.components.sensor import SensorEntity
from . import DOMAIN, SENSORS from . import DOMAIN, SENSORS
@ -15,7 +15,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class NextcloudSensor(Entity): class NextcloudSensor(SensorEntity):
"""Represents a Nextcloud sensor.""" """Represents a Nextcloud sensor."""
def __init__(self, item): def __init__(self, item):

View File

@ -9,6 +9,7 @@ from typing import Callable
from aiohttp import ClientError from aiohttp import ClientError
from py_nightscout import Api as NightscoutAPI from py_nightscout import Api as NightscoutAPI
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_DATE from homeassistant.const import ATTR_DATE
from homeassistant.core import HomeAssistant 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) async_add_entities([NightscoutSensor(api, "Blood Sugar", entry.unique_id)], True)
class NightscoutSensor(Entity): class NightscoutSensor(SensorEntity):
"""Implementation of a Nightscout sensor.""" """Implementation of a Nightscout sensor."""
def __init__(self, api: NightscoutAPI, name, unique_id): def __init__(self, api: NightscoutAPI, name, unique_id):

View File

@ -1,6 +1,7 @@
"""Battery Charge and Range Support for the Nissan Leaf.""" """Battery Charge and Range Support for the Nissan Leaf."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.util.distance import LENGTH_KILOMETERS, LENGTH_MILES 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) add_devices(devices, True)
class LeafBatterySensor(LeafEntity): class LeafBatterySensor(LeafEntity, SensorEntity):
"""Nissan Leaf Battery Sensor.""" """Nissan Leaf Battery Sensor."""
@property @property
@ -65,7 +66,7 @@ class LeafBatterySensor(LeafEntity):
return icon_for_battery_level(battery_level=self.state, charging=chargestate) return icon_for_battery_level(battery_level=self.state, charging=chargestate)
class LeafRangeSensor(LeafEntity): class LeafRangeSensor(LeafEntity, SensorEntity):
"""Nissan Leaf Range Sensor.""" """Nissan Leaf Range Sensor."""
def __init__(self, car, ac_on): def __init__(self, car, ac_on):

View File

@ -4,7 +4,7 @@ import logging
from pyrail import iRail from pyrail import iRail
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -14,7 +14,6 @@ from homeassistant.const import (
TIME_MINUTES, TIME_MINUTES,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -88,7 +87,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class NMBSLiveBoard(Entity): class NMBSLiveBoard(SensorEntity):
"""Get the next train from a station's liveboard.""" """Get the next train from a station's liveboard."""
def __init__(self, api_client, live_station, station_from, station_to): 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.""" """Get the the total travel time for a given connection."""
def __init__( def __init__(

View File

@ -6,7 +6,7 @@ import noaa_coops as coops
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONF_NAME, CONF_NAME,
@ -15,7 +15,6 @@ from homeassistant.const import (
) )
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -72,7 +71,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([noaa_sensor], True) add_entities([noaa_sensor], True)
class NOAATidesAndCurrentsSensor(Entity): class NOAATidesAndCurrentsSensor(SensorEntity):
"""Representation of a NOAA Tides and Currents sensor.""" """Representation of a NOAA Tides and Currents sensor."""
def __init__(self, name, station_id, timezone, unit_system, station): def __init__(self, name, station_id, timezone, unit_system, station):

View File

@ -1,6 +1,7 @@
"""Support for Notion sensors.""" """Support for Notion sensors."""
from typing import Callable from typing import Callable
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -42,7 +43,7 @@ async def async_setup_entry(
async_add_entities(sensor_list) async_add_entities(sensor_list)
class NotionSensor(NotionEntity): class NotionSensor(NotionEntity, SensorEntity):
"""Define a Notion sensor.""" """Define a Notion sensor."""
def __init__( def __init__(

View File

@ -7,10 +7,9 @@ import logging
from nsw_fuel import FuelCheckClient, FuelCheckError from nsw_fuel import FuelCheckClient, FuelCheckError
import voluptuous as vol 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 from homeassistant.const import ATTR_ATTRIBUTION, CURRENCY_CENT, VOLUME_LITERS
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -146,7 +145,7 @@ class StationPriceData:
return self._station_name return self._station_name
class StationPriceSensor(Entity): class StationPriceSensor(SensorEntity):
"""Implementation of a sensor that reports the fuel price for a station.""" """Implementation of a sensor that reports the fuel price for a station."""
def __init__(self, station_data: StationPriceData, fuel_type: str): def __init__(self, station_data: StationPriceData, fuel_type: str):

View File

@ -3,8 +3,8 @@ import logging
from numato_gpio import NumatoGpioError from numato_gpio import NumatoGpioError
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_ID, CONF_NAME, CONF_SENSORS from homeassistant.const import CONF_ID, CONF_NAME, CONF_SENSORS
from homeassistant.helpers.entity import Entity
from . import ( from . import (
CONF_DEVICES, CONF_DEVICES,
@ -58,7 +58,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class NumatoGpioAdc(Entity): class NumatoGpioAdc(SensorEntity):
"""Represents an ADC port of a Numato USB GPIO expander.""" """Represents an ADC port of a Numato USB GPIO expander."""
def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api): def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api):

View File

@ -1,6 +1,7 @@
"""Provides a sensor to track various status aspects of a UPS.""" """Provides a sensor to track various status aspects of a UPS."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_STATE, CONF_RESOURCES, STATE_UNKNOWN from homeassistant.const import ATTR_STATE, CONF_RESOURCES, STATE_UNKNOWN
from homeassistant.helpers.update_coordinator import CoordinatorEntity 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) async_add_entities(entities, True)
class NUTSensor(CoordinatorEntity): class NUTSensor(CoordinatorEntity, SensorEntity):
"""Representation of a sensor entity for NUT status values.""" """Representation of a sensor entity for NUT status values."""
def __init__( def __init__(

View File

@ -5,6 +5,7 @@ from datetime import timedelta
import logging import logging
from typing import Callable from typing import Callable
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
@ -66,7 +67,7 @@ async def async_setup_entry(
async_add_entities(sensors) async_add_entities(sensors)
class NZBGetSensor(NZBGetEntity): class NZBGetSensor(NZBGetEntity, SensorEntity):
"""Representation of a NZBGet sensor.""" """Representation of a NZBGet sensor."""
def __init__( def __init__(

View File

@ -6,10 +6,9 @@ from operator import itemgetter
import oasatelematics import oasatelematics
import voluptuous as vol 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 from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, DEVICE_CLASS_TIMESTAMP
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
_LOGGER = logging.getLogger(__name__) _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) add_entities([OASATelematicsSensor(data, stop_id, route_id, name)], True)
class OASATelematicsSensor(Entity): class OASATelematicsSensor(SensorEntity):
"""Implementation of the OASA Telematics sensor.""" """Implementation of the OASA Telematics sensor."""
def __init__(self, data, stop_id, route_id, name): def __init__(self, data, stop_id, route_id, name):

View File

@ -5,7 +5,7 @@ import logging
from pyobihai import PyObihai from pyobihai import PyObihai
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PASSWORD, CONF_PASSWORD,
@ -13,7 +13,6 @@ from homeassistant.const import (
DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_TIMESTAMP,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -69,7 +68,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class ObihaiServiceSensors(Entity): class ObihaiServiceSensors(SensorEntity):
"""Get the status of each Obihai Lines.""" """Get the status of each Obihai Lines."""
def __init__(self, pyobihai, serial, service_name): def __init__(self, pyobihai, serial, service_name):

View File

@ -3,8 +3,8 @@ import logging
import requests import requests
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
from . import DOMAIN as COMPONENT_DOMAIN, SENSOR_TYPES 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) add_entities(devices, True)
class OctoPrintSensor(Entity): class OctoPrintSensor(SensorEntity):
"""Representation of an OctoPrint sensor.""" """Representation of an OctoPrint sensor."""
def __init__( def __init__(

View File

@ -6,10 +6,9 @@ import defusedxml.ElementTree as ET
import requests import requests
import voluptuous as vol 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 from homeassistant.const import CONF_ID, CONF_NAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -34,7 +33,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([OhmconnectSensor(name, ohmid)], True) add_entities([OhmconnectSensor(name, ohmid)], True)
class OhmconnectSensor(Entity): class OhmconnectSensor(SensorEntity):
"""Representation of a OhmConnect sensor.""" """Representation of a OhmConnect sensor."""
def __init__(self, name, ohmid): def __init__(self, name, ohmid):

View File

@ -4,7 +4,7 @@ import logging
from pyombi import OmbiError from pyombi import OmbiError
from homeassistant.helpers.entity import Entity from homeassistant.components.sensor import SensorEntity
from .const import DOMAIN, SENSOR_TYPES from .const import DOMAIN, SENSOR_TYPES
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class OmbiSensor(Entity): class OmbiSensor(SensorEntity):
"""Representation of an Ombi sensor.""" """Representation of an Ombi sensor."""
def __init__(self, label, sensor_type, ombi, icon): def __init__(self, label, sensor_type, ombi, icon):

View File

@ -1,5 +1,5 @@
"""Definition and setup of the Omnilogic Sensors for Home Assistant.""" """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 ( from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
MASS_GRAMS, MASS_GRAMS,
@ -59,7 +59,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class OmnilogicSensor(OmniLogicEntity): class OmnilogicSensor(OmniLogicEntity, SensorEntity):
"""Defines an Omnilogic sensor entity.""" """Defines an Omnilogic sensor entity."""
def __init__( def __init__(

View File

@ -4,6 +4,7 @@ import logging
from ondilo import OndiloError from ondilo import OndiloError
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEVICE_CLASS_BATTERY, DEVICE_CLASS_BATTERY,
@ -83,7 +84,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class OndiloICO(CoordinatorEntity): class OndiloICO(CoordinatorEntity, SensorEntity):
"""Representation of a Sensor.""" """Representation of a Sensor."""
def __init__( def __init__(

View File

@ -6,7 +6,7 @@ import os
from pi1wire import InvalidCRCException, UnsupportResponseException from pi1wire import InvalidCRCException, UnsupportResponseException
import voluptuous as vol 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.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -394,7 +394,7 @@ def get_entities(onewirehub: OneWireHub, config):
return entities return entities
class OneWireProxySensor(OneWireProxyEntity): class OneWireProxySensor(OneWireProxyEntity, SensorEntity):
"""Implementation of a 1-Wire sensor connected through owserver.""" """Implementation of a 1-Wire sensor connected through owserver."""
@property @property
@ -403,7 +403,7 @@ class OneWireProxySensor(OneWireProxyEntity):
return self._state return self._state
class OneWireDirectSensor(OneWireBaseEntity): class OneWireDirectSensor(OneWireBaseEntity, SensorEntity):
"""Implementation of a 1-Wire sensor directly connected to RPI GPIO.""" """Implementation of a 1-Wire sensor directly connected to RPI GPIO."""
def __init__(self, name, device_file, device_info, owsensor): def __init__(self, name, device_file, device_info, owsensor):
@ -431,7 +431,7 @@ class OneWireDirectSensor(OneWireBaseEntity):
self._state = value self._state = value
class OneWireOWFSSensor(OneWireBaseEntity): # pragma: no cover class OneWireOWFSSensor(OneWireBaseEntity, SensorEntity): # pragma: no cover
"""Implementation of a 1-Wire sensor through owfs. """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. This part of the implementation does not conform to policy regarding 3rd-party libraries, and will not longer be updated.

View File

@ -1,6 +1,7 @@
"""Support for ONVIF binary sensors.""" """Support for ONVIF binary sensors."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import SensorEntity
from homeassistant.core import callback from homeassistant.core import callback
from .base import ONVIFBaseEntity from .base import ONVIFBaseEntity
@ -33,7 +34,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
return True return True
class ONVIFSensor(ONVIFBaseEntity): class ONVIFSensor(ONVIFBaseEntity, SensorEntity):
"""Representation of a ONVIF sensor event.""" """Representation of a ONVIF sensor event."""
def __init__(self, uid, device): def __init__(self, uid, device):

View File

@ -4,9 +4,9 @@ from datetime import timedelta
from openerz_api.main import OpenERZConnector from openerz_api.main import OpenERZConnector
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import SensorEntity
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity
SCAN_INTERVAL = timedelta(hours=12) 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) add_entities([OpenERZSensor(api_connector, config.get(CONF_NAME))], True)
class OpenERZSensor(Entity): class OpenERZSensor(SensorEntity):
"""Representation of a Sensor.""" """Representation of a Sensor."""
def __init__(self, api_connector, name): def __init__(self, api_connector, name):

View File

@ -5,7 +5,7 @@ import openevsewifi
from requests import RequestException from requests import RequestException
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_MONITORED_VARIABLES, CONF_MONITORED_VARIABLES,
@ -14,7 +14,6 @@ from homeassistant.const import (
TIME_MINUTES, TIME_MINUTES,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(dev, True) add_entities(dev, True)
class OpenEVSESensor(Entity): class OpenEVSESensor(SensorEntity):
"""Implementation of an OpenEVSE sensor.""" """Implementation of an OpenEVSE sensor."""
def __init__(self, sensor_type, charger): def __init__(self, sensor_type, charger):

View File

@ -5,7 +5,7 @@ import logging
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONF_API_KEY, CONF_API_KEY,
@ -15,7 +15,6 @@ from homeassistant.const import (
HTTP_OK, HTTP_OK,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _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) add_entities([OpenexchangeratesSensor(rest, name, quote)], True)
class OpenexchangeratesSensor(Entity): class OpenexchangeratesSensor(SensorEntity):
"""Representation of an Open Exchange Rates sensor.""" """Representation of an Open Exchange Rates sensor."""
def __init__(self, rest, name, quote): def __init__(self, rest, name, quote):

View File

@ -5,11 +5,10 @@ import logging
import requests import requests
import voluptuous as vol 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.const import CONF_HOST, CONF_PORT
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
from homeassistant.util.dt import utcnow 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) add_entities(data.devices, True)
class OpenHardwareMonitorDevice(Entity): class OpenHardwareMonitorDevice(SensorEntity):
"""Device used to display information from OpenHardwareMonitor.""" """Device used to display information from OpenHardwareMonitor."""
def __init__(self, data, name, path, unit_of_measurement): def __init__(self, data, name, path, unit_of_measurement):

View File

@ -4,7 +4,7 @@ from datetime import timedelta
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -17,7 +17,6 @@ from homeassistant.const import (
LENGTH_METERS, LENGTH_METERS,
) )
import homeassistant.helpers.config_validation as cv 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 from homeassistant.util import distance as util_distance, location as util_location
CONF_ALTITUDE = "altitude" 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.""" """Open Sky Network Sensor."""
def __init__(self, hass, name, latitude, longitude, radius, altitude): def __init__(self, hass, name, latitude, longitude, radius, altitude):

View File

@ -2,11 +2,11 @@
import logging import logging
from pprint import pformat 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.const import CONF_ID
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect 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 homeassistant.helpers.entity_registry import async_get_registry
from . import DOMAIN from . import DOMAIN
@ -77,7 +77,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(sensors) async_add_entities(sensors)
class OpenThermSensor(Entity): class OpenThermSensor(SensorEntity):
"""Representation of an OpenTherm Gateway sensor.""" """Representation of an OpenTherm Gateway sensor."""
def __init__(self, gw_dev, var, source, device_class, unit, friendly_name_format): def __init__(self, gw_dev, var, source, device_class, unit, friendly_name_format):

View File

@ -1,4 +1,5 @@
"""Support for OpenUV sensors.""" """Support for OpenUV sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import TIME_MINUTES, UV_INDEX from homeassistant.const import TIME_MINUTES, UV_INDEX
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.util.dt import as_local, parse_datetime 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) async_add_entities(sensors, True)
class OpenUvSensor(OpenUvEntity): class OpenUvSensor(OpenUvEntity, SensorEntity):
"""Define a binary sensor for OpenUV.""" """Define a binary sensor for OpenUV."""
def __init__(self, openuv, sensor_type, name, icon, unit, entry_id): def __init__(self, openuv, sensor_type, name, icon, unit, entry_id):

View File

@ -1,12 +1,12 @@
"""Abstraction form OWM sensors.""" """Abstraction form OWM sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import ATTRIBUTION, SENSOR_DEVICE_CLASS, SENSOR_NAME, SENSOR_UNIT from .const import ATTRIBUTION, SENSOR_DEVICE_CLASS, SENSOR_NAME, SENSOR_UNIT
class AbstractOpenWeatherMapSensor(Entity): class AbstractOpenWeatherMapSensor(SensorEntity):
"""Abstract class for an OpenWeatherMap sensor.""" """Abstract class for an OpenWeatherMap sensor."""
def __init__( def __init__(

View File

@ -5,10 +5,9 @@ import logging
from oru import Meter, MeterError from oru import Meter, MeterError
import voluptuous as vol 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 from homeassistant.const import ENERGY_KILO_WATT_HOUR
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _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) _LOGGER.debug("Oru meter_number = %s", meter_number)
class CurrentEnergyUsageSensor(Entity): class CurrentEnergyUsageSensor(SensorEntity):
"""Representation of the sensor.""" """Representation of the sensor."""
def __init__(self, meter): def __init__(self, meter):

View File

@ -4,11 +4,10 @@ import time
import pyotp import pyotp
import voluptuous as vol 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.const import CONF_NAME, CONF_TOKEN
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
DEFAULT_NAME = "OTP Sensor" 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 # Only TOTP supported at the moment, HOTP might be added later
class TOTPSensor(Entity): class TOTPSensor(SensorEntity):
"""Representation of a TOTP sensor.""" """Representation of a TOTP sensor."""
def __init__(self, name, token): def __init__(self, name, token):

View File

@ -4,6 +4,7 @@ from datetime import timedelta
from ovoenergy import OVODailyUsage from ovoenergy import OVODailyUsage
from ovoenergy.ovoenergy import OVOEnergy from ovoenergy.ovoenergy import OVOEnergy
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -53,7 +54,7 @@ async def async_setup_entry(
async_add_entities(entities, True) async_add_entities(entities, True)
class OVOEnergySensor(OVOEnergyDeviceEntity): class OVOEnergySensor(OVOEnergyDeviceEntity, SensorEntity):
"""Defines a OVO Energy sensor.""" """Defines a OVO Energy sensor."""
def __init__( def __init__(

View File

@ -12,6 +12,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASS_PRESSURE, DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
DOMAIN as SENSOR_DOMAIN, DOMAIN as SENSOR_DOMAIN,
SensorEntity,
) )
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.core import callback 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.""" """Basic Representation of a Z-Wave sensor."""
@property @property

View File

@ -1,5 +1,6 @@
"""Support for getting statistical data from a Pi-hole system.""" """Support for getting statistical data from a Pi-hole system."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from . import PiHoleEntity from . import PiHoleEntity
@ -30,7 +31,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(sensors, True) async_add_entities(sensors, True)
class PiHoleSensor(PiHoleEntity): class PiHoleSensor(PiHoleEntity, SensorEntity):
"""Representation of a Pi-hole sensor.""" """Representation of a Pi-hole sensor."""
def __init__(self, api, coordinator, name, sensor_name, server_unique_id): def __init__(self, api, coordinator, name, sensor_name, server_unique_id):

View File

@ -4,10 +4,9 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components import pilight 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 from homeassistant.const import CONF_NAME, CONF_PAYLOAD, CONF_UNIT_OF_MEASUREMENT
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _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.""" """Representation of a sensor that can be updated using Pilight."""
def __init__(self, hass, name, variable, payload, unit_of_measurement): def __init__(self, hass, name, variable, payload, unit_of_measurement):

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from pyplaato.models.device import PlaatoDevice from pyplaato.models.device import PlaatoDevice
from pyplaato.plaato import PlaatoKeg 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 ( from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, 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.""" """Representation of a Plaato Sensor."""
@property @property

View File

@ -1,9 +1,9 @@
"""Support for Plex media server monitoring.""" """Support for Plex media server monitoring."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from .const import ( from .const import (
CONF_SERVER_IDENTIFIER, CONF_SERVER_IDENTIFIER,
@ -25,7 +25,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities([sensor]) async_add_entities([sensor])
class PlexSensor(Entity): class PlexSensor(SensorEntity):
"""Representation of a Plex now playing sensor.""" """Representation of a Plex now playing sensor."""
def __init__(self, hass, plex_server): def __init__(self, hass, plex_server):

View File

@ -2,6 +2,7 @@
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_BATTERY, DEVICE_CLASS_BATTERY,
DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_ILLUMINANCE,
@ -17,7 +18,6 @@ from homeassistant.const import (
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import Entity
from .const import ( from .const import (
COOL_ICON, COOL_ICON,
@ -236,7 +236,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class SmileSensor(SmileGateway): class SmileSensor(SmileGateway, SensorEntity):
"""Represent Smile Sensors.""" """Represent Smile Sensors."""
def __init__(self, api, coordinator, name, dev_id, sensor): def __init__(self, api, coordinator, name, dev_id, sensor):
@ -282,7 +282,7 @@ class SmileSensor(SmileGateway):
return self._unit_of_measurement return self._unit_of_measurement
class PwThermostatSensor(SmileSensor, Entity): class PwThermostatSensor(SmileSensor):
"""Thermostat (or generic) sensor devices.""" """Thermostat (or generic) sensor devices."""
def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type): def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type):
@ -311,7 +311,7 @@ class PwThermostatSensor(SmileSensor, Entity):
self.async_write_ha_state() self.async_write_ha_state()
class PwAuxDeviceSensor(SmileSensor, Entity): class PwAuxDeviceSensor(SmileSensor):
"""Auxiliary Device Sensors.""" """Auxiliary Device Sensors."""
def __init__(self, api, coordinator, name, dev_id, sensor): def __init__(self, api, coordinator, name, dev_id, sensor):
@ -348,7 +348,7 @@ class PwAuxDeviceSensor(SmileSensor, Entity):
self.async_write_ha_state() self.async_write_ha_state()
class PwPowerSensor(SmileSensor, Entity): class PwPowerSensor(SmileSensor):
"""Power sensor entities.""" """Power sensor entities."""
def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type, model): def __init__(self, api, coordinator, name, dev_id, sensor, sensor_type, model):

View File

@ -5,10 +5,9 @@ import logging
from pycketcasts import pocketcasts from pycketcasts import pocketcasts
import voluptuous as vol 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 from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -37,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return False return False
class PocketCastsSensor(Entity): class PocketCastsSensor(SensorEntity):
"""Representation of a pocket casts sensor.""" """Representation of a pocket casts sensor."""
def __init__(self, api): def __init__(self, api):

View File

@ -1,7 +1,7 @@
"""Support for Minut Point sensors.""" """Support for Minut Point sensors."""
import logging import logging
from homeassistant.components.sensor import DOMAIN from homeassistant.components.sensor import DOMAIN, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_PRESSURE, 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.""" """The platform class required by Home Assistant."""
def __init__(self, point_client, device_id, device_class): def __init__(self, point_client, device_id, device_class):

View File

@ -1,4 +1,5 @@
"""Sensor platform for the PoolSense sensor.""" """Sensor platform for the PoolSense sensor."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONF_EMAIL, CONF_EMAIL,
@ -8,7 +9,6 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.helpers.entity import Entity
from . import PoolSenseEntity from . import PoolSenseEntity
from .const import ATTRIBUTION, DOMAIN 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) async_add_entities(sensors_list, False)
class PoolSenseSensor(PoolSenseEntity, Entity): class PoolSenseSensor(PoolSenseEntity, SensorEntity):
"""Sensor representing poolsense data.""" """Sensor representing poolsense data."""
@property @property

View File

@ -3,6 +3,7 @@ import logging
from tesla_powerwall import MeterType from tesla_powerwall import MeterType
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER, PERCENTAGE from homeassistant.const import DEVICE_CLASS_BATTERY, DEVICE_CLASS_POWER, PERCENTAGE
from .const import ( from .const import (
@ -59,7 +60,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class PowerWallChargeSensor(PowerWallEntity): class PowerWallChargeSensor(PowerWallEntity, SensorEntity):
"""Representation of an Powerwall charge sensor.""" """Representation of an Powerwall charge sensor."""
@property @property
@ -88,7 +89,7 @@ class PowerWallChargeSensor(PowerWallEntity):
return round(self.coordinator.data[POWERWALL_API_CHARGE]) return round(self.coordinator.data[POWERWALL_API_CHARGE])
class PowerWallEnergySensor(PowerWallEntity): class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
"""Representation of an Powerwall Energy sensor.""" """Representation of an Powerwall Energy sensor."""
def __init__( def __init__(

View File

@ -5,10 +5,9 @@ import threading
from pushbullet import InvalidKeyError, Listener, PushBullet from pushbullet import InvalidKeyError, Listener, PushBullet
import voluptuous as vol 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 from homeassistant.const import CONF_API_KEY, CONF_MONITORED_CONDITIONS
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -52,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class PushBulletNotificationSensor(Entity): class PushBulletNotificationSensor(SensorEntity):
"""Representation of a Pushbullet Sensor.""" """Representation of a Pushbullet Sensor."""
def __init__(self, pb, element): def __init__(self, pb, element):

View File

@ -6,7 +6,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.rest.data import RestData 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 ( from homeassistant.const import (
ATTR_DATE, ATTR_DATE,
ATTR_TEMPERATURE, ATTR_TEMPERATURE,
@ -17,7 +17,6 @@ from homeassistant.const import (
) )
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_ENDPOINT = "http://pvoutput.org/service/r2/getstatus.jsp" _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)]) async_add_entities([PvoutputSensor(rest, name)])
class PvoutputSensor(Entity): class PvoutputSensor(SensorEntity):
"""Representation of a PVOutput sensor.""" """Representation of a PVOutput sensor."""
def __init__(self, rest, name): def __init__(self, rest, name):

View File

@ -7,6 +7,7 @@ from random import randint
from aiopvpc import PVPCData from aiopvpc import PVPCData
from homeassistant import config_entries 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.const import CONF_NAME, CURRENCY_EURO, ENERGY_KILO_WATT_HOUR
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession 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.""" """Class to hold the prices of electricity as a sensor."""
unit_of_measurement = UNIT unit_of_measurement = UNIT

View File

@ -6,7 +6,7 @@ from aiohttp.hdrs import CONTENT_TYPE
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_MONITORED_VARIABLES, CONF_MONITORED_VARIABLES,
@ -19,7 +19,6 @@ from homeassistant.const import (
DATA_RATE_MEGABYTES_PER_SECOND, DATA_RATE_MEGABYTES_PER_SECOND,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -77,7 +76,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True) add_entities(devices, True)
class PyLoadSensor(Entity): class PyLoadSensor(SensorEntity):
"""Representation of a pyLoad sensor.""" """Representation of a pyLoad sensor."""
def __init__(self, api, sensor_type, client_name): def __init__(self, api, sensor_type, client_name):

View File

@ -5,7 +5,7 @@ from qbittorrent.client import Client, LoginRequired
from requests.exceptions import RequestException from requests.exceptions import RequestException
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
CONF_PASSWORD, CONF_PASSWORD,
@ -16,7 +16,6 @@ from homeassistant.const import (
) )
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -71,7 +70,7 @@ def format_speed(speed):
return round(kb_spd, 2 if kb_spd < 0.1 else 1) return round(kb_spd, 2 if kb_spd < 0.1 else 1)
class QBittorrentSensor(Entity): class QBittorrentSensor(SensorEntity):
"""Representation of an qBittorrent sensor.""" """Representation of an qBittorrent sensor."""
def __init__(self, sensor_type, qbittorrent_client, client_name, exception): def __init__(self, sensor_type, qbittorrent_client, client_name, exception):

View File

@ -5,7 +5,7 @@ import logging
from qnapstats import QNAPStats from qnapstats import QNAPStats
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_NAME, ATTR_NAME,
CONF_HOST, CONF_HOST,
@ -23,7 +23,6 @@ from homeassistant.const import (
) )
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -200,7 +199,7 @@ class QNAPStatsAPI:
_LOGGER.exception("Failed to fetch QNAP stats from the NAS") _LOGGER.exception("Failed to fetch QNAP stats from the NAS")
class QNAPSensor(Entity): class QNAPSensor(SensorEntity):
"""Base class for a QNAP sensor.""" """Base class for a QNAP sensor."""
def __init__(self, api, variable, variable_info, monitor_device=None): def __init__(self, api, variable, variable_info, monitor_device=None):

View File

@ -3,6 +3,7 @@ import logging
from pyqwikswitch.qwikswitch import SENSORS from pyqwikswitch.qwikswitch import SENSORS
from homeassistant.components.sensor import SensorEntity
from homeassistant.core import callback from homeassistant.core import callback
from . import DOMAIN as QWIKSWITCH, QSEntity from . import DOMAIN as QWIKSWITCH, QSEntity
@ -21,7 +22,7 @@ async def async_setup_platform(hass, _, add_entities, discovery_info=None):
add_entities(devs) add_entities(devs)
class QSSensor(QSEntity): class QSSensor(QSEntity, SensorEntity):
"""Sensor based on a Qwikswitch relay/dimmer module.""" """Sensor based on a Qwikswitch relay/dimmer module."""
_val = None _val = None