Migrate integrations i-m to extend SensorEntity (#48213)

This commit is contained in:
Erik Montnemery 2021-03-22 19:59:03 +01:00 committed by GitHub
parent 64bc9a8196
commit fdf97eaca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 152 additions and 157 deletions

View file

@ -8,7 +8,7 @@ from iammeter import real_time_api
from iammeter.power_meter import IamMeterError from iammeter.power_meter import IamMeterError
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_NAME, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers import debounce from homeassistant.helpers import debounce
@ -74,7 +74,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(entities) async_add_entities(entities)
class IamMeter(CoordinatorEntity): class IamMeter(CoordinatorEntity, SensorEntity):
"""Class for a sensor.""" """Class for a sensor."""
def __init__(self, coordinator, uid, sensor_name, unit, dev_name): def __init__(self, coordinator, uid, sensor_name, unit, dev_name):

View file

@ -1,7 +1,7 @@
"""Support for Aqualink temperature sensors.""" """Support for Aqualink temperature sensors."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import DOMAIN from homeassistant.components.sensor import DOMAIN, SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -22,7 +22,7 @@ async def async_setup_entry(
async_add_entities(devs, True) async_add_entities(devs, True)
class HassAqualinkSensor(AqualinkEntity): class HassAqualinkSensor(AqualinkEntity, SensorEntity):
"""Representation of a sensor.""" """Representation of a sensor."""
@property @property

View file

@ -1,11 +1,11 @@
"""Support for iCloud sensors.""" """Support for iCloud sensors."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
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
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -48,7 +48,7 @@ def add_entities(account, async_add_entities, tracked):
async_add_entities(new_tracked, True) async_add_entities(new_tracked, True)
class IcloudDeviceBatterySensor(Entity): class IcloudDeviceBatterySensor(SensorEntity):
"""Representation of a iCloud device battery sensor.""" """Representation of a iCloud device battery sensor."""
def __init__(self, account: IcloudAccount, device: IcloudDevice): def __init__(self, account: IcloudAccount, device: IcloudDevice):

View file

@ -1,6 +1,6 @@
"""Support for IHC sensors.""" """Support for IHC sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_UNIT_OF_MEASUREMENT from homeassistant.const import CONF_UNIT_OF_MEASUREMENT
from homeassistant.helpers.entity import Entity
from . import IHC_CONTROLLER, IHC_INFO from . import IHC_CONTROLLER, IHC_INFO
from .ihcdevice import IHCDevice from .ihcdevice import IHCDevice
@ -26,7 +26,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices) add_entities(devices)
class IHCSensor(IHCDevice, Entity): class IHCSensor(IHCDevice, SensorEntity):
"""Implementation of the IHC sensor.""" """Implementation of the IHC sensor."""
def __init__( def __init__(

View file

@ -6,7 +6,7 @@ from aioimaplib import IMAP4_SSL, AioImapException
import async_timeout import async_timeout
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__)
@ -62,7 +61,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([sensor], True) async_add_entities([sensor], True)
class ImapSensor(Entity): class ImapSensor(SensorEntity):
"""Representation of an IMAP sensor.""" """Representation of an IMAP sensor."""
def __init__(self, name, user, password, server, port, charset, folder, search): def __init__(self, name, user, password, server, port, charset, folder, search):

View file

@ -7,7 +7,7 @@ import logging
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_DATE, ATTR_DATE,
CONF_NAME, CONF_NAME,
@ -18,7 +18,6 @@ from homeassistant.const import (
CONTENT_TYPE_TEXT_PLAIN, CONTENT_TYPE_TEXT_PLAIN,
) )
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__)
@ -145,7 +144,7 @@ class EmailReader:
return None return None
class EmailContentSensor(Entity): class EmailContentSensor(SensorEntity):
"""Representation of an EMail sensor.""" """Representation of an EMail sensor."""
def __init__(self, hass, email_reader, name, allowed_senders, value_template): def __init__(self, hass, email_reader, name, allowed_senders, value_template):

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any from typing import Any
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_PRESSURE, DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
@ -40,7 +40,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class IncomfortSensor(IncomfortChild): class IncomfortSensor(IncomfortChild, SensorEntity):
"""Representation of an InComfort/InTouch sensor device.""" """Representation of an InComfort/InTouch sensor device."""
def __init__(self, client, heater, name) -> None: def __init__(self, client, heater, name) -> None:

View file

@ -5,7 +5,10 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA from homeassistant.components.sensor import (
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorEntity,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_API_VERSION, CONF_API_VERSION,
CONF_NAME, CONF_NAME,
@ -16,7 +19,6 @@ from homeassistant.const import (
) )
from homeassistant.exceptions import PlatformNotReady, TemplateError from homeassistant.exceptions import PlatformNotReady, TemplateError
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 . import create_influx_url, get_influx_connection, validate_version_specific_config from . import create_influx_url, get_influx_connection, validate_version_specific_config
@ -169,7 +171,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda _: influx.close()) hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda _: influx.close())
class InfluxSensor(Entity): class InfluxSensor(SensorEntity):
"""Implementation of a Influxdb sensor.""" """Implementation of a Influxdb sensor."""
def __init__(self, hass, influx, query): def __init__(self, hass, influx, query):

View file

@ -4,7 +4,7 @@ import logging
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_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
CONF_METHOD, CONF_METHOD,
@ -83,7 +83,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([integral]) async_add_entities([integral])
class IntegrationSensor(RestoreEntity): class IntegrationSensor(RestoreEntity, SensorEntity):
"""Representation of an integration sensor.""" """Representation of an integration sensor."""
def __init__( def __init__(

View file

@ -1,9 +1,9 @@
"""Support for Home Assistant iOS app sensors.""" """Support for Home Assistant iOS app sensors."""
from homeassistant.components import ios from homeassistant.components import ios
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import PERCENTAGE from homeassistant.const import PERCENTAGE
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
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from .const import DOMAIN from .const import DOMAIN
@ -32,7 +32,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(dev, True) async_add_entities(dev, True)
class IOSSensor(Entity): class IOSSensor(SensorEntity):
"""Representation of an iOS sensor.""" """Representation of an iOS sensor."""
def __init__(self, sensor_type, device_name, device): def __init__(self, sensor_type, device_name, device):

View file

@ -1,6 +1,7 @@
"""Support for IOTA wallet sensors.""" """Support for IOTA wallet sensors."""
from datetime import timedelta from datetime import timedelta
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from . import CONF_WALLETS, IotaDevice from . import CONF_WALLETS, IotaDevice
@ -27,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class IotaBalanceSensor(IotaDevice): class IotaBalanceSensor(IotaDevice, SensorEntity):
"""Implement an IOTA sensor for displaying wallets balance.""" """Implement an IOTA sensor for displaying wallets balance."""
def __init__(self, wallet_config, iota_config): def __init__(self, wallet_config, iota_config):
@ -60,7 +61,7 @@ class IotaBalanceSensor(IotaDevice):
self._state = self.api.get_inputs()["totalBalance"] self._state = self.api.get_inputs()["totalBalance"]
class IotaNodeSensor(IotaDevice): class IotaNodeSensor(IotaDevice, SensorEntity):
"""Implement an IOTA sensor for displaying attributes of node.""" """Implement an IOTA sensor for displaying attributes of node."""
def __init__(self, iota_config): def __init__(self, iota_config):

View file

@ -1,4 +1,5 @@
"""Support for Iperf3 sensors.""" """Support for Iperf3 sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
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
@ -23,7 +24,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info)
async_add_entities(sensors, True) async_add_entities(sensors, True)
class Iperf3Sensor(RestoreEntity): class Iperf3Sensor(RestoreEntity, SensorEntity):
"""A Iperf3 sensor implementation.""" """A Iperf3 sensor implementation."""
def __init__(self, iperf3_data, sensor_type): def __init__(self, iperf3_data, sensor_type):

View file

@ -4,6 +4,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from typing import Any, Callable from typing import Any, Callable
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_LOCATION, DEVICE_CLASS_TIMESTAMP, PERCENTAGE from homeassistant.const import ATTR_LOCATION, DEVICE_CLASS_TIMESTAMP, PERCENTAGE
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -52,7 +53,7 @@ async def async_setup_entry(
async_add_entities(sensors, True) async_add_entities(sensors, True)
class IPPSensor(IPPEntity): class IPPSensor(IPPEntity, SensorEntity):
"""Defines an IPP sensor.""" """Defines an IPP sensor."""
def __init__( def __init__(

View file

@ -3,6 +3,7 @@ from statistics import mean
import numpy as np import numpy as np
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_STATE from homeassistant.const import ATTR_STATE
from homeassistant.core import callback from homeassistant.core import callback
@ -98,7 +99,7 @@ def calculate_trend(indices):
return TREND_FLAT return TREND_FLAT
class ForecastSensor(IQVIAEntity): class ForecastSensor(IQVIAEntity, SensorEntity):
"""Define sensor related to forecast data.""" """Define sensor related to forecast data."""
@callback @callback
@ -137,7 +138,7 @@ class ForecastSensor(IQVIAEntity):
self._state = average self._state = average
class IndexSensor(IQVIAEntity): class IndexSensor(IQVIAEntity, SensorEntity):
"""Define sensor related to indices.""" """Define sensor related to indices."""
@callback @callback

View file

@ -4,10 +4,9 @@ from datetime import timedelta
from pyirishrail.pyirishrail import IrishRailRTPI from pyirishrail.pyirishrail import IrishRailRTPI
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, TIME_MINUTES from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, TIME_MINUTES
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
ATTR_STATION = "Station" ATTR_STATION = "Station"
ATTR_ORIGIN = "Origin" ATTR_ORIGIN = "Origin"
@ -64,7 +63,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class IrishRailTransportSensor(Entity): class IrishRailTransportSensor(SensorEntity):
"""Implementation of an irish rail public transport sensor.""" """Implementation of an irish rail public transport sensor."""
def __init__(self, data, station, direction, destination, stops_at, name): def __init__(self, data, station, direction, destination, stops_at, name):

View file

@ -1,8 +1,8 @@
"""Platform to retrieve Islamic prayer times information for Home Assistant.""" """Platform to retrieve Islamic prayer times information for Home Assistant."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_TIMESTAMP from homeassistant.const import DEVICE_CLASS_TIMESTAMP
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_TYPES from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_TYPES
@ -20,7 +20,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True) async_add_entities(entities, True)
class IslamicPrayerTimeSensor(Entity): class IslamicPrayerTimeSensor(SensorEntity):
"""Representation of an Islamic prayer time sensor.""" """Representation of an Islamic prayer time sensor."""
def __init__(self, sensor_type, client): def __init__(self, sensor_type, client):

View file

@ -5,7 +5,7 @@ from typing import Callable
from pyisy.constants import ISY_VALUE_UNKNOWN from pyisy.constants import ISY_VALUE_UNKNOWN
from homeassistant.components.sensor import DOMAIN as SENSOR from homeassistant.components.sensor import DOMAIN as SENSOR, SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -45,7 +45,7 @@ async def async_setup_entry(
async_add_entities(devices) async_add_entities(devices)
class ISYSensorEntity(ISYNodeEntity): class ISYSensorEntity(ISYNodeEntity, SensorEntity):
"""Representation of an ISY994 sensor device.""" """Representation of an ISY994 sensor device."""
@property @property
@ -105,7 +105,7 @@ class ISYSensorEntity(ISYNodeEntity):
return raw_units return raw_units
class ISYSensorVariableEntity(ISYEntity): class ISYSensorVariableEntity(ISYEntity, SensorEntity):
"""Representation of an ISY994 variable as a sensor device.""" """Representation of an ISY994 variable as a sensor device."""
def __init__(self, vname: str, vobj: object) -> None: def __init__(self, vname: str, vobj: object) -> None:

View file

@ -3,8 +3,8 @@ import logging
import hdate import hdate
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_TIMESTAMP, SUN_EVENT_SUNSET from homeassistant.const import DEVICE_CLASS_TIMESTAMP, SUN_EVENT_SUNSET
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.sun import get_astral_event_date from homeassistant.helpers.sun import get_astral_event_date
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -30,7 +30,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensors) async_add_entities(sensors)
class JewishCalendarSensor(Entity): class JewishCalendarSensor(SensorEntity):
"""Representation of an Jewish calendar sensor.""" """Representation of an Jewish calendar sensor."""
def __init__(self, data, sensor, sensor_info): def __init__(self, data, sensor, sensor_info):

View file

@ -1,4 +1,5 @@
"""Support for monitoring juicenet/juicepoint/juicebox based EVSE sensors.""" """Support for monitoring juicenet/juicepoint/juicebox based EVSE sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ELECTRICAL_CURRENT_AMPERE, ELECTRICAL_CURRENT_AMPERE,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
@ -7,7 +8,6 @@ from homeassistant.const import (
TIME_SECONDS, TIME_SECONDS,
VOLT, VOLT,
) )
from homeassistant.helpers.entity import Entity
from .const import DOMAIN, JUICENET_API, JUICENET_COORDINATOR from .const import DOMAIN, JUICENET_API, JUICENET_COORDINATOR
from .entity import JuiceNetDevice from .entity import JuiceNetDevice
@ -36,7 +36,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class JuiceNetSensorDevice(JuiceNetDevice, Entity): class JuiceNetSensorDevice(JuiceNetDevice, SensorEntity):
"""Implementation of a JuiceNet sensor.""" """Implementation of a JuiceNet sensor."""
def __init__(self, device, sensor_type, coordinator): def __init__(self, device, sensor_type, coordinator):

View file

@ -1,7 +1,7 @@
"""Support for Kaiterra Temperature ahn Humidity Sensors.""" """Support for Kaiterra Temperature ahn Humidity Sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_DEVICE_ID, CONF_NAME, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import CONF_DEVICE_ID, CONF_NAME, TEMP_CELSIUS, TEMP_FAHRENHEIT
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 DISPATCHER_KAITERRA, DOMAIN from .const import DISPATCHER_KAITERRA, DOMAIN
@ -25,7 +25,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class KaiterraSensor(Entity): class KaiterraSensor(SensorEntity):
"""Implementation of a Kaittera sensor.""" """Implementation of a Kaittera sensor."""
def __init__(self, api, name, device_id, sensor): def __init__(self, api, name, device_id, sensor):

View file

@ -1,10 +1,10 @@
"""Support for KEBA charging station sensors.""" """Support for KEBA charging station sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_POWER, DEVICE_CLASS_POWER,
ELECTRICAL_CURRENT_AMPERE, ELECTRICAL_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
) )
from homeassistant.helpers.entity import Entity
from . import DOMAIN from . import DOMAIN
@ -62,7 +62,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensors) async_add_entities(sensors)
class KebaSensor(Entity): class KebaSensor(SensorEntity):
"""The entity class for KEBA charging stations sensors.""" """The entity class for KEBA charging stations sensors."""
def __init__(self, keba, key, name, entity_type, icon, unit, device_class=None): def __init__(self, keba, key, name, entity_type, icon, unit, device_class=None):

View file

@ -1,8 +1,8 @@
"""KIRA interface to receive UDP packets from an IR-IP bridge.""" """KIRA interface to receive UDP packets from an IR-IP bridge."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_DEVICE, CONF_NAME, STATE_UNKNOWN from homeassistant.const import CONF_DEVICE, CONF_NAME, STATE_UNKNOWN
from homeassistant.helpers.entity import Entity
from . import CONF_SENSOR, DOMAIN from . import CONF_SENSOR, DOMAIN
@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([KiraReceiver(device, kira)]) add_entities([KiraReceiver(device, kira)])
class KiraReceiver(Entity): class KiraReceiver(SensorEntity):
"""Implementation of a Kira Receiver.""" """Implementation of a Kira Receiver."""
def __init__(self, name, kira): def __init__(self, name, kira):

View file

@ -5,7 +5,7 @@ from typing import Callable, Iterable
from xknx.devices import Sensor as XknxSensor from xknx.devices import Sensor as XknxSensor
from homeassistant.components.sensor import DEVICE_CLASSES from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ( from homeassistant.helpers.typing import (
ConfigType, ConfigType,
@ -32,7 +32,7 @@ async def async_setup_platform(
async_add_entities(entities) async_add_entities(entities)
class KNXSensor(KnxEntity, Entity): class KNXSensor(KnxEntity, SensorEntity):
"""Representation of a KNX sensor.""" """Representation of a KNX sensor."""
def __init__(self, device: XknxSensor) -> None: def __init__(self, device: XknxSensor) -> None:

View file

@ -1,4 +1,5 @@
"""Support for DHT and DS18B20 sensors attached to a Konnected device.""" """Support for DHT and DS18B20 sensors attached to a Konnected device."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICES, CONF_DEVICES,
CONF_NAME, CONF_NAME,
@ -12,7 +13,6 @@ from homeassistant.const import (
) )
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
from .const import DOMAIN as KONNECTED_DOMAIN, SIGNAL_DS18B20_NEW from .const import DOMAIN as KONNECTED_DOMAIN, SIGNAL_DS18B20_NEW
@ -70,7 +70,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_dispatcher_connect(hass, SIGNAL_DS18B20_NEW, async_add_ds18b20) async_dispatcher_connect(hass, SIGNAL_DS18B20_NEW, async_add_ds18b20)
class KonnectedSensor(Entity): class KonnectedSensor(SensorEntity):
"""Represents a Konnected DHT Sensor.""" """Represents a Konnected DHT Sensor."""
def __init__(self, device_id, data, sensor_type, addr=None, initial_state=None): def __init__(self, device_id, data, sensor_type, addr=None, initial_state=None):

View file

@ -2,7 +2,7 @@
from pykwb import kwb from pykwb import kwb
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_DEVICE, CONF_DEVICE,
CONF_HOST, CONF_HOST,
@ -11,7 +11,6 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
DEFAULT_RAW = False DEFAULT_RAW = False
DEFAULT_NAME = "KWB" DEFAULT_NAME = "KWB"
@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class KWBSensor(Entity): class KWBSensor(SensorEntity):
"""Representation of a KWB Easyfire sensor.""" """Representation of a KWB Easyfire sensor."""
def __init__(self, easyfire, sensor, client_name): def __init__(self, easyfire, sensor, client_name):

View file

@ -6,7 +6,11 @@ import pylacrosse
from serial import SerialException from serial import SerialException
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA from homeassistant.components.sensor import (
ENTITY_ID_FORMAT,
PLATFORM_SCHEMA,
SensorEntity,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICE, CONF_DEVICE,
CONF_ID, CONF_ID,
@ -19,7 +23,7 @@ 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, async_generate_entity_id from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -108,7 +112,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class LaCrosseSensor(Entity): class LaCrosseSensor(SensorEntity):
"""Implementation of a Lacrosse sensor.""" """Implementation of a Lacrosse sensor."""
_temperature = None _temperature = None

View file

@ -7,10 +7,9 @@ import pylast as lastfm
from pylast import WSError from pylast import WSError
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 from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
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(entities, True) add_entities(entities, True)
class LastfmSensor(Entity): class LastfmSensor(SensorEntity):
"""A class for the Last.fm account.""" """A class for the Last.fm account."""
def __init__(self, user, lastfm_api): def __init__(self, user, lastfm_api):

View file

@ -7,11 +7,10 @@ import logging
from pylaunches import PyLaunches, PyLaunchesException from pylaunches import PyLaunches, PyLaunchesException
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 from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
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 .const import ( from .const import (
ATTR_AGENCY, ATTR_AGENCY,
@ -40,7 +39,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([LaunchLibrarySensor(launches, name)], True) async_add_entities([LaunchLibrarySensor(launches, name)], True)
class LaunchLibrarySensor(Entity): class LaunchLibrarySensor(SensorEntity):
"""Representation of a launch_library Sensor.""" """Representation of a launch_library Sensor."""
def __init__(self, launches: PyLaunches, name: str) -> None: def __init__(self, launches: PyLaunches, name: str) -> None:

View file

@ -2,7 +2,7 @@
import pypck import pypck
from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_ADDRESS, CONF_ADDRESS,
CONF_DOMAIN, CONF_DOMAIN,
@ -51,7 +51,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class LcnVariableSensor(LcnEntity): class LcnVariableSensor(LcnEntity, SensorEntity):
"""Representation of a LCN sensor for variables.""" """Representation of a LCN sensor for variables."""
def __init__(self, config, entry_id, device_connection): def __init__(self, config, entry_id, device_connection):
@ -99,7 +99,7 @@ class LcnVariableSensor(LcnEntity):
self.async_write_ha_state() self.async_write_ha_state()
class LcnLedLogicSensor(LcnEntity): class LcnLedLogicSensor(LcnEntity, SensorEntity):
"""Representation of a LCN sensor for leds and logicops.""" """Representation of a LCN sensor for leds and logicops."""
def __init__(self, config, entry_id, device_connection): def __init__(self, config, entry_id, device_connection):

View file

@ -1,6 +1,6 @@
"""Support for LightwaveRF TRV - Associated Battery.""" """Support for LightwaveRF TRV - Associated Battery."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE
from homeassistant.helpers.entity import Entity
from . import CONF_SERIAL, LIGHTWAVE_LINK from . import CONF_SERIAL, LIGHTWAVE_LINK
@ -22,7 +22,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(batteries) async_add_entities(batteries)
class LightwaveBattery(Entity): class LightwaveBattery(SensorEntity):
"""Lightwave TRV Battery.""" """Lightwave TRV Battery."""
def __init__(self, name, lwlink, serial): def __init__(self, name, lwlink, serial):

View file

@ -5,10 +5,9 @@ import os
from batinfo import Batteries from batinfo import Batteries
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_NAME, CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE from homeassistant.const import ATTR_NAME, CONF_NAME, DEVICE_CLASS_BATTERY, PERCENTAGE
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__)
@ -68,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([LinuxBatterySensor(name, battery_id, system)], True) add_entities([LinuxBatterySensor(name, battery_id, system)], True)
class LinuxBatterySensor(Entity): class LinuxBatterySensor(SensorEntity):
"""Representation of a Linux Battery sensor.""" """Representation of a Linux Battery sensor."""
def __init__(self, name, battery_id, system): def __init__(self, name, battery_id, system):

View file

@ -3,8 +3,8 @@ from __future__ import annotations
from pylitterbot.robot import Robot from pylitterbot.robot import Robot
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_TIMESTAMP, PERCENTAGE from homeassistant.const import DEVICE_CLASS_TIMESTAMP, PERCENTAGE
from homeassistant.helpers.entity import Entity
from .const import DOMAIN from .const import DOMAIN
from .hub import LitterRobotEntity, LitterRobotHub from .hub import LitterRobotEntity, LitterRobotHub
@ -21,7 +21,7 @@ def icon_for_gauge_level(gauge_level: int | None = None, offset: int = 0) -> str
return "mdi:gauge-low" return "mdi:gauge-low"
class LitterRobotPropertySensor(LitterRobotEntity, Entity): class LitterRobotPropertySensor(LitterRobotEntity, SensorEntity):
"""Litter-Robot property sensors.""" """Litter-Robot property sensors."""
def __init__( def __init__(
@ -37,7 +37,7 @@ class LitterRobotPropertySensor(LitterRobotEntity, Entity):
return getattr(self.robot, self.sensor_attribute) return getattr(self.robot, self.sensor_attribute)
class LitterRobotWasteSensor(LitterRobotPropertySensor, Entity): class LitterRobotWasteSensor(LitterRobotPropertySensor):
"""Litter-Robot sensors.""" """Litter-Robot sensors."""
@property @property
@ -51,7 +51,7 @@ class LitterRobotWasteSensor(LitterRobotPropertySensor, Entity):
return icon_for_gauge_level(self.state, 10) return icon_for_gauge_level(self.state, 10)
class LitterRobotSleepTimeSensor(LitterRobotPropertySensor, Entity): class LitterRobotSleepTimeSensor(LitterRobotPropertySensor):
"""Litter-Robot sleep time sensors.""" """Litter-Robot sleep time sensors."""
@property @property

View file

@ -1,7 +1,7 @@
"""Sensor platform for local_ip.""" """Sensor platform for local_ip."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.helpers.entity import Entity
from homeassistant.util import get_local_ip from homeassistant.util import get_local_ip
from .const import DOMAIN, SENSOR from .const import DOMAIN, SENSOR
@ -13,7 +13,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities([IPSensor(name)], True) async_add_entities([IPSensor(name)], True)
class IPSensor(Entity): class IPSensor(SensorEntity):
"""A simple sensor.""" """A simple sensor."""
def __init__(self, name): def __init__(self, name):

View file

@ -1,6 +1,7 @@
"""Support for Logi Circle sensors.""" """Support for Logi Circle sensors."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_BATTERY_CHARGING, ATTR_BATTERY_CHARGING,
@ -9,7 +10,6 @@ from homeassistant.const import (
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
) )
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.util.dt import as_local from homeassistant.util.dt import as_local
@ -42,7 +42,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(sensors, True) async_add_entities(sensors, True)
class LogiSensor(Entity): class LogiSensor(SensorEntity):
"""A sensor implementation for a Logi Circle camera.""" """A sensor implementation for a Logi Circle camera."""
def __init__(self, camera, time_zone, sensor_type): def __init__(self, camera, time_zone, sensor_type):

View file

@ -5,10 +5,9 @@ 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 HTTP_OK from homeassistant.const import 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__)
@ -90,7 +89,7 @@ class APIData:
self.data = parse_api_response(response.json()) self.data = parse_api_response(response.json())
class AirSensor(Entity): class AirSensor(SensorEntity):
"""Single authority air sensor.""" """Single authority air sensor."""
ICON = "mdi:cloud-outline" ICON = "mdi:cloud-outline"

View file

@ -4,10 +4,9 @@ from datetime import timedelta
from london_tube_status import TubeData from london_tube_status import TubeData
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 from homeassistant.const import ATTR_ATTRIBUTION
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
ATTRIBUTION = "Powered by TfL Open Data" ATTRIBUTION = "Powered by TfL Open Data"
@ -51,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class LondonTubeSensor(Entity): class LondonTubeSensor(SensorEntity):
"""Sensor that reads the status of a line from Tube Data.""" """Sensor that reads the status of a line from Tube Data."""
def __init__(self, name, data): def __init__(self, name, data):

View file

@ -4,14 +4,13 @@ import logging
import pyloopenergy import pyloopenergy
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_UNIT_SYSTEM_IMPERIAL, CONF_UNIT_SYSTEM_IMPERIAL,
CONF_UNIT_SYSTEM_METRIC, CONF_UNIT_SYSTEM_METRIC,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
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__)
@ -82,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class LoopEnergyDevice(Entity): class LoopEnergySensor(SensorEntity):
"""Implementation of an Loop Energy base sensor.""" """Implementation of an Loop Energy base sensor."""
def __init__(self, controller): def __init__(self, controller):
@ -116,7 +115,7 @@ class LoopEnergyDevice(Entity):
self.schedule_update_ha_state(True) self.schedule_update_ha_state(True)
class LoopEnergyElec(LoopEnergyDevice): class LoopEnergyElec(LoopEnergySensor):
"""Implementation of an Loop Energy Electricity sensor.""" """Implementation of an Loop Energy Electricity sensor."""
def __init__(self, controller): def __init__(self, controller):
@ -133,7 +132,7 @@ class LoopEnergyElec(LoopEnergyDevice):
self._state = round(self._controller.electricity_useage, 2) self._state = round(self._controller.electricity_useage, 2)
class LoopEnergyGas(LoopEnergyDevice): class LoopEnergyGas(LoopEnergySensor):
"""Implementation of an Loop Energy Gas sensor.""" """Implementation of an Loop Energy Gas sensor."""
def __init__(self, controller): def __init__(self, controller):

View file

@ -1,6 +1,7 @@
"""Support for Luftdaten sensors.""" """Support for Luftdaten sensors."""
import logging import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
ATTR_LATITUDE, ATTR_LATITUDE,
@ -9,7 +10,6 @@ from homeassistant.const import (
) )
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
from . import ( from . import (
DATA_LUFTDATEN, DATA_LUFTDATEN,
@ -45,7 +45,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(sensors, True) async_add_entities(sensors, True)
class LuftdatenSensor(Entity): class LuftdatenSensor(SensorEntity):
"""Implementation of a Luftdaten sensor.""" """Implementation of a Luftdaten sensor."""
def __init__(self, luftdaten, sensor_type, name, icon, unit, show): def __init__(self, luftdaten, sensor_type, name, icon, unit, show):

View file

@ -7,10 +7,9 @@ from lyft_rides.client import LyftRidesClient
from lyft_rides.errors import APIError from lyft_rides.errors import APIError
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_CLIENT_ID, CONF_CLIENT_SECRET, TIME_MINUTES from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, TIME_MINUTES
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__)
@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(dev, True) add_entities(dev, True)
class LyftSensor(Entity): class LyftSensor(SensorEntity):
"""Implementation of an Lyft sensor.""" """Implementation of an Lyft sensor."""
def __init__(self, sensorType, products, product_id, product): def __init__(self, sensorType, products, product_id, product):

View file

@ -4,6 +4,7 @@ from datetime import datetime, timedelta
from aiolyric.objects.device import LyricDevice from aiolyric.objects.device import LyricDevice
from aiolyric.objects.location import LyricLocation from aiolyric.objects.location import LyricLocation
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 (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
@ -67,7 +68,7 @@ async def async_setup_entry(
async_add_entities(entities, True) async_add_entities(entities, True)
class LyricSensor(LyricDeviceEntity): class LyricSensor(LyricDeviceEntity, SensorEntity):
"""Defines a Honeywell Lyric sensor.""" """Defines a Honeywell Lyric sensor."""
def __init__( def __init__(

View file

@ -5,7 +5,7 @@ import logging
import magicseaweed import magicseaweed
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,
@ -13,7 +13,6 @@ from homeassistant.const import (
CONF_NAME, 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
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -90,7 +89,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class MagicSeaweedSensor(Entity): class MagicSeaweedSensor(SensorEntity):
"""Implementation of a MagicSeaweed sensor.""" """Implementation of a MagicSeaweed sensor."""
def __init__(self, forecast_data, sensor_type, name, unit_system, hour=None): def __init__(self, forecast_data, sensor_type, name, unit_system, hour=None):

View file

@ -1,4 +1,5 @@
"""Platform for Mazda sensor integration.""" """Platform for Mazda sensor integration."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_UNIT_SYSTEM_IMPERIAL, CONF_UNIT_SYSTEM_IMPERIAL,
LENGTH_KILOMETERS, LENGTH_KILOMETERS,
@ -29,7 +30,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class MazdaFuelRemainingSensor(MazdaEntity): class MazdaFuelRemainingSensor(MazdaEntity, SensorEntity):
"""Class for the fuel remaining sensor.""" """Class for the fuel remaining sensor."""
@property @property
@ -59,7 +60,7 @@ class MazdaFuelRemainingSensor(MazdaEntity):
return self.coordinator.data[self.index]["status"]["fuelRemainingPercent"] return self.coordinator.data[self.index]["status"]["fuelRemainingPercent"]
class MazdaFuelDistanceSensor(MazdaEntity): class MazdaFuelDistanceSensor(MazdaEntity, SensorEntity):
"""Class for the fuel distance sensor.""" """Class for the fuel distance sensor."""
@property @property
@ -100,7 +101,7 @@ class MazdaFuelDistanceSensor(MazdaEntity):
) )
class MazdaOdometerSensor(MazdaEntity): class MazdaOdometerSensor(MazdaEntity, SensorEntity):
"""Class for the odometer sensor.""" """Class for the odometer sensor."""
@property @property
@ -137,7 +138,7 @@ class MazdaOdometerSensor(MazdaEntity):
) )
class MazdaFrontLeftTirePressureSensor(MazdaEntity): class MazdaFrontLeftTirePressureSensor(MazdaEntity, SensorEntity):
"""Class for the front left tire pressure sensor.""" """Class for the front left tire pressure sensor."""
@property @property
@ -170,7 +171,7 @@ class MazdaFrontLeftTirePressureSensor(MazdaEntity):
return None if tire_pressure is None else round(tire_pressure) return None if tire_pressure is None else round(tire_pressure)
class MazdaFrontRightTirePressureSensor(MazdaEntity): class MazdaFrontRightTirePressureSensor(MazdaEntity, SensorEntity):
"""Class for the front right tire pressure sensor.""" """Class for the front right tire pressure sensor."""
@property @property
@ -203,7 +204,7 @@ class MazdaFrontRightTirePressureSensor(MazdaEntity):
return None if tire_pressure is None else round(tire_pressure) return None if tire_pressure is None else round(tire_pressure)
class MazdaRearLeftTirePressureSensor(MazdaEntity): class MazdaRearLeftTirePressureSensor(MazdaEntity, SensorEntity):
"""Class for the rear left tire pressure sensor.""" """Class for the rear left tire pressure sensor."""
@property @property
@ -236,7 +237,7 @@ class MazdaRearLeftTirePressureSensor(MazdaEntity):
return None if tire_pressure is None else round(tire_pressure) return None if tire_pressure is None else round(tire_pressure)
class MazdaRearRightTirePressureSensor(MazdaEntity): class MazdaRearRightTirePressureSensor(MazdaEntity, SensorEntity):
"""Class for the rear right tire pressure sensor.""" """Class for the rear right tire pressure sensor."""
@property @property

View file

@ -2,6 +2,7 @@
from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW
from pymelcloud.atw_device import Zone from pymelcloud.atw_device import Zone
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_DEVICE_CLASS, ATTR_DEVICE_CLASS,
ATTR_ICON, ATTR_ICON,
@ -9,7 +10,6 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.helpers.entity import Entity
from . import MelCloudDevice from . import MelCloudDevice
from .const import DOMAIN from .const import DOMAIN
@ -110,7 +110,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
) )
class MelDeviceSensor(Entity): class MelDeviceSensor(SensorEntity):
"""Representation of a Sensor.""" """Representation of a Sensor."""
def __init__(self, api: MelCloudDevice, measurement, definition): def __init__(self, api: MelCloudDevice, measurement, definition):

View file

@ -6,6 +6,7 @@ from meteofrance_api.helpers import (
readeable_phenomenoms_dict, readeable_phenomenoms_dict,
) )
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -74,7 +75,7 @@ async def async_setup_entry(
) )
class MeteoFranceSensor(CoordinatorEntity): class MeteoFranceSensor(CoordinatorEntity, SensorEntity):
"""Representation of a Meteo-France sensor.""" """Representation of a Meteo-France sensor."""
def __init__(self, sensor_type: str, coordinator: DataUpdateCoordinator): def __init__(self, sensor_type: str, coordinator: DataUpdateCoordinator):

View file

@ -1,4 +1,5 @@
"""Support for UK Met Office weather service.""" """Support for UK Met Office weather service."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
@ -10,7 +11,6 @@ from homeassistant.const import (
UV_INDEX, UV_INDEX,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from .const import ( from .const import (
@ -92,7 +92,7 @@ async def async_setup_entry(
) )
class MetOfficeCurrentSensor(Entity): class MetOfficeCurrentSensor(SensorEntity):
"""Implementation of a Met Office current weather condition sensor.""" """Implementation of a Met Office current weather condition sensor."""
def __init__(self, entry_data, hass_data, sensor_type): def __init__(self, entry_data, hass_data, sensor_type):

View file

@ -5,7 +5,7 @@ from mficlient.client import FailedToLogin, MFiClient
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_PASSWORD, CONF_PASSWORD,
@ -18,7 +18,6 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
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__)
@ -74,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
) )
class MfiSensor(Entity): class MfiSensor(SensorEntity):
"""Representation of a mFi sensor.""" """Representation of a mFi sensor."""
def __init__(self, port, hass): def __init__(self, port, hass):

View file

@ -5,7 +5,7 @@ import logging
from pmsensor import co2sensor from pmsensor import co2sensor
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_TEMPERATURE, ATTR_TEMPERATURE,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
@ -14,7 +14,6 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
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.temperature import celsius_to_fahrenheit from homeassistant.util.temperature import celsius_to_fahrenheit
@ -69,7 +68,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return True return True
class MHZ19Sensor(Entity): class MHZ19Sensor(SensorEntity):
"""Representation of an CO2 sensor.""" """Representation of an CO2 sensor."""
def __init__(self, mhz_client, sensor_type, temp_unit, name): def __init__(self, mhz_client, sensor_type, temp_unit, name):

View file

@ -8,7 +8,7 @@ from btlewrap import BluetoothBackendException
from miflora import miflora_poller from miflora import miflora_poller
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 (
CONDUCTIVITY, CONDUCTIVITY,
CONF_FORCE_UPDATE, CONF_FORCE_UPDATE,
@ -27,7 +27,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
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.temperature import celsius_to_fahrenheit from homeassistant.util.temperature import celsius_to_fahrenheit
@ -130,7 +129,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(devs) async_add_entities(devs)
class MiFloraSensor(Entity): class MiFloraSensor(SensorEntity):
"""Implementing the MiFlora sensor.""" """Implementing the MiFlora sensor."""
def __init__( def __init__(

View file

@ -3,7 +3,7 @@ import logging
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_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
CONF_NAME, CONF_NAME,
@ -13,7 +13,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
from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
@ -131,7 +130,7 @@ def calc_median(sensor_values, round_digits):
return round(median, round_digits) return round(median, round_digits)
class MinMaxSensor(Entity): class MinMaxSensor(SensorEntity):
"""Representation of a min/max sensor.""" """Representation of a min/max sensor."""
def __init__(self, entity_ids, name, sensor_type, round_digits): def __init__(self, entity_ids, name, sensor_type, round_digits):

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from typing import Any from typing import Any
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TIME_MILLISECONDS from homeassistant.const import TIME_MILLISECONDS
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
@ -47,7 +48,7 @@ async def async_setup_entry(
async_add_entities(entities, True) async_add_entities(entities, True)
class MinecraftServerSensorEntity(MinecraftServerEntity): class MinecraftServerSensorEntity(MinecraftServerEntity, SensorEntity):
"""Representation of a Minecraft Server sensor base entity.""" """Representation of a Minecraft Server sensor base entity."""
def __init__( def __init__(

View file

@ -6,7 +6,7 @@ from btlewrap.base import BluetoothBackendException
from mitemp_bt import mitemp_bt_poller from mitemp_bt import mitemp_bt_poller
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_FORCE_UPDATE, CONF_FORCE_UPDATE,
CONF_MAC, CONF_MAC,
@ -20,7 +20,6 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
try: try:
import bluepy.btle # noqa: F401 pylint: disable=unused-import import bluepy.btle # noqa: F401 pylint: disable=unused-import
@ -104,7 +103,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devs) add_entities(devs)
class MiTempBtSensor(Entity): class MiTempBtSensor(SensorEntity):
"""Implementing the MiTempBt sensor.""" """Implementing the MiTempBt sensor."""
def __init__(self, poller, parameter, device, name, unit, force_update, median): def __init__(self, poller, parameter, device, name, unit, force_update, median):

View file

@ -1,6 +1,7 @@
"""Sensor platform for mobile_app.""" """Sensor platform for mobile_app."""
from functools import partial from functools import partial
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import CONF_NAME, CONF_UNIQUE_ID, CONF_WEBHOOK_ID from homeassistant.const import CONF_NAME, CONF_UNIQUE_ID, CONF_WEBHOOK_ID
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@ -71,7 +72,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
) )
class MobileAppSensor(MobileAppEntity): class MobileAppSensor(MobileAppEntity, SensorEntity):
"""Representation of an mobile app sensor.""" """Representation of an mobile app sensor."""
@property @property

View file

@ -9,7 +9,11 @@ from pymodbus.exceptions import ConnectionException, ModbusException
from pymodbus.pdu import ExceptionResponse from pymodbus.pdu import ExceptionResponse
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA, PLATFORM_SCHEMA from homeassistant.components.sensor import (
DEVICE_CLASSES_SCHEMA,
PLATFORM_SCHEMA,
SensorEntity,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_NAME, CONF_NAME,
@ -158,7 +162,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class ModbusRegisterSensor(RestoreEntity): class ModbusRegisterSensor(RestoreEntity, SensorEntity):
"""Modbus register sensor.""" """Modbus register sensor."""
def __init__( def __init__(

View file

@ -4,7 +4,7 @@ import logging
from basicmodem.basicmodem import BasicModem as bm from basicmodem.basicmodem import BasicModem as bm
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_DEVICE, CONF_DEVICE,
CONF_NAME, CONF_NAME,
@ -12,7 +12,6 @@ from homeassistant.const import (
STATE_IDLE, STATE_IDLE,
) )
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__)
DEFAULT_NAME = "Modem CallerID" DEFAULT_NAME = "Modem CallerID"
@ -44,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([ModemCalleridSensor(hass, name, port, modem)]) add_entities([ModemCalleridSensor(hass, name, port, modem)])
class ModemCalleridSensor(Entity): class ModemCalleridSensor(SensorEntity):
"""Implementation of USB modem caller ID sensor.""" """Implementation of USB modem caller ID sensor."""
def __init__(self, hass, name, port, modem): def __init__(self, hass, name, port, modem):

View file

@ -5,7 +5,7 @@ import math
import voluptuous as vol import voluptuous as vol
from homeassistant import util from homeassistant import util
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, ATTR_UNIT_OF_MEASUREMENT,
CONF_NAME, CONF_NAME,
@ -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
from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.event import async_track_state_change_event
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -69,7 +68,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class MoldIndicator(Entity): class MoldIndicator(SensorEntity):
"""Represents a MoldIndication sensor.""" """Represents a MoldIndication sensor."""
def __init__( def __init__(

View file

@ -2,10 +2,9 @@
from astral import Astral from astral import Astral
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 from homeassistant.const import CONF_NAME
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
DEFAULT_NAME = "Moon" DEFAULT_NAME = "Moon"
@ -42,7 +41,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities([MoonSensor(name)], True) async_add_entities([MoonSensor(name)], True)
class MoonSensor(Entity): class MoonSensor(SensorEntity):
"""Representation of a Moon sensor.""" """Representation of a Moon sensor."""
def __init__(self, name): def __init__(self, name):

View file

@ -1,13 +1,13 @@
"""Support for Motion Blinds sensors.""" """Support for Motion Blinds sensors."""
from motionblinds import BlindType from motionblinds import BlindType
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_BATTERY, DEVICE_CLASS_BATTERY,
DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_SIGNAL_STRENGTH,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
) )
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY from .const import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
@ -39,7 +39,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities) async_add_entities(entities)
class MotionBatterySensor(CoordinatorEntity, Entity): class MotionBatterySensor(CoordinatorEntity, SensorEntity):
""" """
Representation of a Motion Battery Sensor. Representation of a Motion Battery Sensor.
@ -144,7 +144,7 @@ class MotionTDBUBatterySensor(MotionBatterySensor):
return attributes return attributes
class MotionSignalStrengthSensor(CoordinatorEntity, Entity): class MotionSignalStrengthSensor(CoordinatorEntity, SensorEntity):
"""Representation of a Motion Signal Strength Sensor.""" """Representation of a Motion Signal Strength Sensor."""
def __init__(self, coordinator, device, device_type): def __init__(self, coordinator, device, device_type):

View file

@ -7,7 +7,7 @@ import functools
import voluptuous as vol import voluptuous as vol
from homeassistant.components import sensor from homeassistant.components import sensor
from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_FORCE_UPDATE, CONF_FORCE_UPDATE,
@ -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
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
@ -71,7 +70,7 @@ async def _async_setup_entity(
async_add_entities([MqttSensor(hass, config, config_entry, discovery_data)]) async_add_entities([MqttSensor(hass, config, config_entry, discovery_data)])
class MqttSensor(MqttEntity, Entity): class MqttSensor(MqttEntity, SensorEntity):
"""Representation of a sensor that can be updated using MQTT.""" """Representation of a sensor that can be updated using MQTT."""
def __init__(self, hass, config, config_entry, discovery_data): def __init__(self, hass, config, config_entry, discovery_data):

View file

@ -7,7 +7,7 @@ import voluptuous as vol
from homeassistant.components import mqtt from homeassistant.components import mqtt
from homeassistant.components.mqtt import CONF_STATE_TOPIC from homeassistant.components.mqtt import CONF_STATE_TOPIC
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_DEVICE_ID, ATTR_DEVICE_ID,
ATTR_ID, ATTR_ID,
@ -18,7 +18,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
from homeassistant.util import dt, slugify from homeassistant.util import dt, slugify
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -71,7 +70,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
) )
class MQTTRoomSensor(Entity): class MQTTRoomSensor(SensorEntity):
"""Representation of a room sensor that is updated via MQTT.""" """Representation of a room sensor that is updated via MQTT."""
def __init__(self, name, state_topic, device_id, timeout, consider_home): def __init__(self, name, state_topic, device_id, timeout, consider_home):

View file

@ -6,10 +6,9 @@ import logging
import MVGLive import MVGLive
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, TIME_MINUTES from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, 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__)
@ -78,7 +77,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors, True) add_entities(sensors, True)
class MVGLiveSensor(Entity): class MVGLiveSensor(SensorEntity):
"""Implementation of an MVG Live sensor.""" """Implementation of an MVG Live sensor."""
def __init__( def __init__(

View file

@ -1,10 +1,9 @@
"""Support for MyChevy sensors.""" """Support for MyChevy sensors."""
import logging import logging
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity
from homeassistant.const import PERCENTAGE from homeassistant.const import PERCENTAGE
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.util import slugify from homeassistant.util import slugify
@ -46,7 +45,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(sensors) add_entities(sensors)
class MyChevyStatus(Entity): class MyChevyStatus(SensorEntity):
"""A string representing the charge mode.""" """A string representing the charge mode."""
_name = "MyChevy Status" _name = "MyChevy Status"
@ -109,7 +108,7 @@ class MyChevyStatus(Entity):
return False return False
class EVSensor(Entity): class EVSensor(SensorEntity):
"""Base EVSensor class. """Base EVSensor class.
The only real difference between sensors is which units and what The only real difference between sensors is which units and what

View file

@ -4,7 +4,7 @@ from typing import Callable
from homeassistant.components import mysensors from homeassistant.components import mysensors
from homeassistant.components.mysensors import on_unload from homeassistant.components.mysensors import on_unload
from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY
from homeassistant.components.sensor import DOMAIN from homeassistant.components.sensor import DOMAIN, SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONDUCTIVITY, CONDUCTIVITY,
@ -87,7 +87,7 @@ async def async_setup_entry(
) )
class MySensorsSensor(mysensors.device.MySensorsEntity): class MySensorsSensor(mysensors.device.MySensorsEntity, SensorEntity):
"""Representation of a MySensors Sensor child node.""" """Representation of a MySensors Sensor child node."""
@property @property