From 0c086b5067858155e935e5486dfd149d9d1e9e20 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 22 Mar 2021 19:50:29 +0100 Subject: [PATCH] Migrate integrations w-z to extend SensorEntity (#48217) --- homeassistant/components/waqi/sensor.py | 4 ++-- homeassistant/components/waterfurnace/sensor.py | 5 ++--- homeassistant/components/waze_travel_time/sensor.py | 5 ++--- homeassistant/components/websocket_api/sensor.py | 4 ++-- homeassistant/components/whois/sensor.py | 5 ++--- homeassistant/components/wiffi/sensor.py | 5 +++-- homeassistant/components/wink/sensor.py | 11 ++++++----- homeassistant/components/wirelesstag/sensor.py | 4 ++-- homeassistant/components/withings/sensor.py | 4 ++-- homeassistant/components/wled/sensor.py | 4 ++-- homeassistant/components/wolflink/sensor.py | 3 ++- homeassistant/components/worldclock/sensor.py | 5 ++--- homeassistant/components/worldtidesinfo/sensor.py | 5 ++--- homeassistant/components/worxlandroid/sensor.py | 5 ++--- homeassistant/components/wsdot/sensor.py | 5 ++--- homeassistant/components/wunderground/sensor.py | 5 ++--- homeassistant/components/xbee/sensor.py | 4 ++-- homeassistant/components/xbox/sensor.py | 3 ++- homeassistant/components/xbox_live/sensor.py | 5 ++--- homeassistant/components/xiaomi_aqara/sensor.py | 5 +++-- homeassistant/components/xiaomi_miio/sensor.py | 9 ++++----- homeassistant/components/xs1/sensor.py | 4 ++-- homeassistant/components/yandex_transport/sensor.py | 5 ++--- homeassistant/components/zabbix/sensor.py | 5 ++--- homeassistant/components/zamg/sensor.py | 4 ++-- homeassistant/components/zestimate/sensor.py | 5 ++--- homeassistant/components/zha/sensor.py | 3 ++- homeassistant/components/zodiac/sensor.py | 4 ++-- homeassistant/components/zoneminder/sensor.py | 9 ++++----- homeassistant/components/zwave/sensor.py | 4 ++-- homeassistant/components/zwave_js/sensor.py | 3 ++- 31 files changed, 72 insertions(+), 79 deletions(-) diff --git a/homeassistant/components/waqi/sensor.py b/homeassistant/components/waqi/sensor.py index ac43da68641..ef01c057a9e 100644 --- a/homeassistant/components/waqi/sensor.py +++ b/homeassistant/components/waqi/sensor.py @@ -7,6 +7,7 @@ import aiohttp import voluptuous as vol from waqiasync import WaqiClient +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_TEMPERATURE, @@ -17,7 +18,6 @@ from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import PLATFORM_SCHEMA -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -93,7 +93,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(dev, True) -class WaqiSensor(Entity): +class WaqiSensor(SensorEntity): """Implementation of a WAQI sensor.""" def __init__(self, client, station): diff --git a/homeassistant/components/waterfurnace/sensor.py b/homeassistant/components/waterfurnace/sensor.py index dfb960fe819..91e455d03d6 100644 --- a/homeassistant/components/waterfurnace/sensor.py +++ b/homeassistant/components/waterfurnace/sensor.py @@ -1,9 +1,8 @@ """Support for Waterfurnace.""" -from homeassistant.components.sensor import ENTITY_ID_FORMAT +from homeassistant.components.sensor import ENTITY_ID_FORMAT, SensorEntity from homeassistant.const import PERCENTAGE, POWER_WATT, TEMP_FAHRENHEIT from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from homeassistant.util import slugify from . import DOMAIN as WF_DOMAIN, UPDATE_TOPIC @@ -61,7 +60,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class WaterFurnaceSensor(Entity): +class WaterFurnaceSensor(SensorEntity): """Implementing the Waterfurnace sensor.""" def __init__(self, client, config): diff --git a/homeassistant/components/waze_travel_time/sensor.py b/homeassistant/components/waze_travel_time/sensor.py index be2cf7ca2da..327a0769b50 100644 --- a/homeassistant/components/waze_travel_time/sensor.py +++ b/homeassistant/components/waze_travel_time/sensor.py @@ -6,7 +6,7 @@ import re import WazeRouteCalculator import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_LATITUDE, @@ -20,7 +20,6 @@ from homeassistant.const import ( ) from homeassistant.helpers import location import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -126,7 +125,7 @@ def _get_location_from_attributes(state): return "{},{}".format(attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)) -class WazeTravelTime(Entity): +class WazeTravelTime(SensorEntity): """Representation of a Waze travel time sensor.""" def __init__(self, name, origin, destination, waze_data): diff --git a/homeassistant/components/websocket_api/sensor.py b/homeassistant/components/websocket_api/sensor.py index c026978634f..dfcdc57842e 100644 --- a/homeassistant/components/websocket_api/sensor.py +++ b/homeassistant/components/websocket_api/sensor.py @@ -1,7 +1,7 @@ """Entity to track connections to websocket API.""" +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback -from homeassistant.helpers.entity import Entity from .const import ( DATA_CONNECTIONS, @@ -19,7 +19,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([entity]) -class APICount(Entity): +class APICount(SensorEntity): """Entity to represent how many people are connected to the stream API.""" def __init__(self): diff --git a/homeassistant/components/whois/sensor.py b/homeassistant/components/whois/sensor.py index 72c992456a7..6d97037a4ee 100644 --- a/homeassistant/components/whois/sensor.py +++ b/homeassistant/components/whois/sensor.py @@ -5,10 +5,9 @@ import logging import voluptuous as vol import whois -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_DOMAIN, CONF_NAME, TIME_DAYS import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -47,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return -class WhoisSensor(Entity): +class WhoisSensor(SensorEntity): """Implementation of a WHOIS sensor.""" def __init__(self, name, domain): diff --git a/homeassistant/components/wiffi/sensor.py b/homeassistant/components/wiffi/sensor.py index f207e3be3ac..800a420f8f0 100644 --- a/homeassistant/components/wiffi/sensor.py +++ b/homeassistant/components/wiffi/sensor.py @@ -5,6 +5,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, + SensorEntity, ) from homeassistant.const import DEGREE, PRESSURE_MBAR, TEMP_CELSIUS from homeassistant.core import callback @@ -58,7 +59,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_dispatcher_connect(hass, CREATE_ENTITY_SIGNAL, _create_entity) -class NumberEntity(WiffiEntity): +class NumberEntity(WiffiEntity, SensorEntity): """Entity for wiffi metrics which have a number value.""" def __init__(self, device, metric, options): @@ -100,7 +101,7 @@ class NumberEntity(WiffiEntity): self.async_write_ha_state() -class StringEntity(WiffiEntity): +class StringEntity(WiffiEntity, SensorEntity): """Entity for wiffi metrics which have a string value.""" def __init__(self, device, metric, options): diff --git a/homeassistant/components/wink/sensor.py b/homeassistant/components/wink/sensor.py index d2de4c43945..88f9588750e 100644 --- a/homeassistant/components/wink/sensor.py +++ b/homeassistant/components/wink/sensor.py @@ -3,6 +3,7 @@ import logging import pywink +from homeassistant.components.sensor import SensorEntity from homeassistant.const import DEGREE, TEMP_CELSIUS from . import DOMAIN, WinkDevice @@ -19,29 +20,29 @@ def setup_platform(hass, config, add_entities, discovery_info=None): _id = sensor.object_id() + sensor.name() if _id not in hass.data[DOMAIN]["unique_ids"]: if sensor.capability() in SENSOR_TYPES: - add_entities([WinkSensorDevice(sensor, hass)]) + add_entities([WinkSensorEntity(sensor, hass)]) for eggtray in pywink.get_eggtrays(): _id = eggtray.object_id() + eggtray.name() if _id not in hass.data[DOMAIN]["unique_ids"]: - add_entities([WinkSensorDevice(eggtray, hass)]) + add_entities([WinkSensorEntity(eggtray, hass)]) for tank in pywink.get_propane_tanks(): _id = tank.object_id() + tank.name() if _id not in hass.data[DOMAIN]["unique_ids"]: - add_entities([WinkSensorDevice(tank, hass)]) + add_entities([WinkSensorEntity(tank, hass)]) for piggy_bank in pywink.get_piggy_banks(): _id = piggy_bank.object_id() + piggy_bank.name() if _id not in hass.data[DOMAIN]["unique_ids"]: try: if piggy_bank.capability() in SENSOR_TYPES: - add_entities([WinkSensorDevice(piggy_bank, hass)]) + add_entities([WinkSensorEntity(piggy_bank, hass)]) except AttributeError: _LOGGER.info("Device is not a sensor") -class WinkSensorDevice(WinkDevice): +class WinkSensorEntity(WinkDevice, SensorEntity): """Representation of a Wink sensor.""" def __init__(self, wink, hass): diff --git a/homeassistant/components/wirelesstag/sensor.py b/homeassistant/components/wirelesstag/sensor.py index 2a845249028..cc0ce0cb888 100644 --- a/homeassistant/components/wirelesstag/sensor.py +++ b/homeassistant/components/wirelesstag/sensor.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_MONITORED_CONDITIONS from homeassistant.core import callback import homeassistant.helpers.config_validation as cv @@ -44,7 +44,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class WirelessTagSensor(WirelessTagBaseSensor): +class WirelessTagSensor(WirelessTagBaseSensor, SensorEntity): """Representation of a Sensor.""" def __init__(self, api, tag, sensor_type, config): diff --git a/homeassistant/components/withings/sensor.py b/homeassistant/components/withings/sensor.py index a7a7947dec5..89bb81eb607 100644 --- a/homeassistant/components/withings/sensor.py +++ b/homeassistant/components/withings/sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Callable -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import Entity @@ -28,7 +28,7 @@ async def async_setup_entry( async_add_entities(entities, True) -class WithingsHealthSensor(BaseWithingsSensor): +class WithingsHealthSensor(BaseWithingsSensor, SensorEntity): """Implementation of a Withings sensor.""" @property diff --git a/homeassistant/components/wled/sensor.py b/homeassistant/components/wled/sensor.py index 4bfca885613..7e91f81dea0 100644 --- a/homeassistant/components/wled/sensor.py +++ b/homeassistant/components/wled/sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from datetime import timedelta from typing import Any, Callable -from homeassistant.components.sensor import DEVICE_CLASS_CURRENT +from homeassistant.components.sensor import DEVICE_CLASS_CURRENT, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DATA_BYTES, @@ -42,7 +42,7 @@ async def async_setup_entry( async_add_entities(sensors, True) -class WLEDSensor(WLEDDeviceEntity): +class WLEDSensor(WLEDDeviceEntity, SensorEntity): """Defines a WLED sensor.""" def __init__( diff --git a/homeassistant/components/wolflink/sensor.py b/homeassistant/components/wolflink/sensor.py index 9ea7f9d1163..f243160ff59 100644 --- a/homeassistant/components/wolflink/sensor.py +++ b/homeassistant/components/wolflink/sensor.py @@ -9,6 +9,7 @@ from wolf_smartset.models import ( Temperature, ) +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, @@ -46,7 +47,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class WolfLinkSensor(CoordinatorEntity): +class WolfLinkSensor(CoordinatorEntity, SensorEntity): """Base class for all Wolf entities.""" def __init__(self, coordinator, wolf_object: Parameter, device_id): diff --git a/homeassistant/components/worldclock/sensor.py b/homeassistant/components/worldclock/sensor.py index e02dc3a0d5c..de5b3991e3f 100644 --- a/homeassistant/components/worldclock/sensor.py +++ b/homeassistant/components/worldclock/sensor.py @@ -1,10 +1,9 @@ """Support for showing the time in a different time zone.""" 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_TIME_ZONE import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util CONF_TIME_FORMAT = "time_format" @@ -39,7 +38,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class WorldClockSensor(Entity): +class WorldClockSensor(SensorEntity): """Representation of a World clock sensor.""" def __init__(self, time_zone, name, time_format): diff --git a/homeassistant/components/worldtidesinfo/sensor.py b/homeassistant/components/worldtidesinfo/sensor.py index 43c9446b6ce..0fa65957e40 100644 --- a/homeassistant/components/worldtidesinfo/sensor.py +++ b/homeassistant/components/worldtidesinfo/sensor.py @@ -6,7 +6,7 @@ import time import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_API_KEY, @@ -15,7 +15,6 @@ from homeassistant.const import ( CONF_NAME, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -55,7 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([tides]) -class WorldTidesInfoSensor(Entity): +class WorldTidesInfoSensor(SensorEntity): """Representation of a WorldTidesInfo sensor.""" def __init__(self, name, lat, lon, key): diff --git a/homeassistant/components/worxlandroid/sensor.py b/homeassistant/components/worxlandroid/sensor.py index e4fe33f62f1..9be3afabc9f 100644 --- a/homeassistant/components/worxlandroid/sensor.py +++ b/homeassistant/components/worxlandroid/sensor.py @@ -6,11 +6,10 @@ import aiohttp import async_timeout 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_PIN, CONF_TIMEOUT, PERCENTAGE from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -50,7 +49,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([WorxLandroidSensor(typ, config)]) -class WorxLandroidSensor(Entity): +class WorxLandroidSensor(SensorEntity): """Implementation of a Worx Landroid sensor.""" def __init__(self, sensor, config): diff --git a/homeassistant/components/wsdot/sensor.py b/homeassistant/components/wsdot/sensor.py index 34ad5a37ec8..9e4d957d028 100644 --- a/homeassistant/components/wsdot/sensor.py +++ b/homeassistant/components/wsdot/sensor.py @@ -6,7 +6,7 @@ import re import requests import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_NAME, @@ -17,7 +17,6 @@ from homeassistant.const import ( TIME_MINUTES, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -65,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class WashingtonStateTransportSensor(Entity): +class WashingtonStateTransportSensor(SensorEntity): """ Sensor that reads the WSDOT web API. diff --git a/homeassistant/components/wunderground/sensor.py b/homeassistant/components/wunderground/sensor.py index 38d6bba0b1f..358e305dc47 100644 --- a/homeassistant/components/wunderground/sensor.py +++ b/homeassistant/components/wunderground/sensor.py @@ -12,7 +12,7 @@ import async_timeout import voluptuous as vol from homeassistant.components import sensor -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_API_KEY, @@ -36,7 +36,6 @@ from homeassistant.const import ( from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.util import Throttle @@ -1117,7 +1116,7 @@ async def async_setup_platform( async_add_entities(sensors, True) -class WUndergroundSensor(Entity): +class WUndergroundSensor(SensorEntity): """Implementing the WUnderground sensor.""" def __init__(self, hass: HomeAssistantType, rest, condition, unique_id_base: str): diff --git a/homeassistant/components/xbee/sensor.py b/homeassistant/components/xbee/sensor.py index 4d9f9ca518b..78cfe964277 100644 --- a/homeassistant/components/xbee/sensor.py +++ b/homeassistant/components/xbee/sensor.py @@ -5,8 +5,8 @@ import logging import voluptuous as vol from xbee_helper.exceptions import ZigBeeException, ZigBeeTxFailure +from homeassistant.components.sensor import SensorEntity from homeassistant.const import CONF_TYPE, TEMP_CELSIUS -from homeassistant.helpers.entity import Entity from . import DOMAIN, PLATFORM_SCHEMA, XBeeAnalogIn, XBeeAnalogInConfig, XBeeConfig @@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([sensor_class(config_class(config), zigbee_device)], True) -class XBeeTemperatureSensor(Entity): +class XBeeTemperatureSensor(SensorEntity): """Representation of XBee Pro temperature sensor.""" def __init__(self, config, device): diff --git a/homeassistant/components/xbox/sensor.py b/homeassistant/components/xbox/sensor.py index 88bf112b728..ac19a4be193 100644 --- a/homeassistant/components/xbox/sensor.py +++ b/homeassistant/components/xbox/sensor.py @@ -3,6 +3,7 @@ from __future__ import annotations from functools import partial +from homeassistant.components.sensor import SensorEntity from homeassistant.core import callback from homeassistant.helpers.entity_registry import ( async_get_registry as async_get_entity_registry, @@ -29,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_ent update_friends() -class XboxSensorEntity(XboxBaseSensorEntity): +class XboxSensorEntity(XboxBaseSensorEntity, SensorEntity): """Representation of a Xbox presence state.""" @property diff --git a/homeassistant/components/xbox_live/sensor.py b/homeassistant/components/xbox_live/sensor.py index 780051b2d87..2717bc1ad62 100644 --- a/homeassistant/components/xbox_live/sensor.py +++ b/homeassistant/components/xbox_live/sensor.py @@ -5,11 +5,10 @@ import logging import voluptuous as vol from xboxapi import Client -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_API_KEY, CONF_SCAN_INTERVAL from homeassistant.core import callback import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval _LOGGER = logging.getLogger(__name__) @@ -73,7 +72,7 @@ def get_user_gamercard(api, xuid): return None -class XboxSensor(Entity): +class XboxSensor(SensorEntity): """A class for the Xbox account.""" def __init__(self, api, xuid, gamercard, interval): diff --git a/homeassistant/components/xiaomi_aqara/sensor.py b/homeassistant/components/xiaomi_aqara/sensor.py index 969980bf7c8..fa3d265f12f 100644 --- a/homeassistant/components/xiaomi_aqara/sensor.py +++ b/homeassistant/components/xiaomi_aqara/sensor.py @@ -1,6 +1,7 @@ """Support for Xiaomi Aqara sensors.""" import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( ATTR_BATTERY_LEVEL, DEVICE_CLASS_BATTERY, @@ -107,7 +108,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class XiaomiSensor(XiaomiDevice): +class XiaomiSensor(XiaomiDevice, SensorEntity): """Representation of a XiaomiSensor.""" def __init__(self, device, name, data_key, xiaomi_hub, config_entry): @@ -171,7 +172,7 @@ class XiaomiSensor(XiaomiDevice): return True -class XiaomiBatterySensor(XiaomiDevice): +class XiaomiBatterySensor(XiaomiDevice, SensorEntity): """Representation of a XiaomiSensor.""" @property diff --git a/homeassistant/components/xiaomi_miio/sensor.py b/homeassistant/components/xiaomi_miio/sensor.py index e2b645a10ea..ac9a7ab4543 100644 --- a/homeassistant/components/xiaomi_miio/sensor.py +++ b/homeassistant/components/xiaomi_miio/sensor.py @@ -12,7 +12,7 @@ from miio.gateway.gateway import ( ) import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import ( ATTR_BATTERY_LEVEL, @@ -30,7 +30,6 @@ from homeassistant.const import ( TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from .const import CONF_DEVICE, CONF_FLOW_TYPE, CONF_GATEWAY, DOMAIN, KEY_COORDINATOR from .device import XiaomiMiioEntity @@ -147,7 +146,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, update_before_add=True) -class XiaomiAirQualityMonitor(XiaomiMiioEntity): +class XiaomiAirQualityMonitor(XiaomiMiioEntity, SensorEntity): """Representation of a Xiaomi Air Quality Monitor.""" def __init__(self, name, device, entry, unique_id): @@ -221,7 +220,7 @@ class XiaomiAirQualityMonitor(XiaomiMiioEntity): _LOGGER.error("Got exception while fetching the state: %s", ex) -class XiaomiGatewaySensor(XiaomiGatewayDevice): +class XiaomiGatewaySensor(XiaomiGatewayDevice, SensorEntity): """Representation of a XiaomiGatewaySensor.""" def __init__(self, coordinator, sub_device, entry, data_key): @@ -252,7 +251,7 @@ class XiaomiGatewaySensor(XiaomiGatewayDevice): return self._sub_device.status[self._data_key] -class XiaomiGatewayIlluminanceSensor(Entity): +class XiaomiGatewayIlluminanceSensor(SensorEntity): """Representation of the gateway device's illuminance sensor.""" def __init__(self, gateway_device, gateway_name, gateway_device_id): diff --git a/homeassistant/components/xs1/sensor.py b/homeassistant/components/xs1/sensor.py index 9e6afa40fa4..f158e7d74b8 100644 --- a/homeassistant/components/xs1/sensor.py +++ b/homeassistant/components/xs1/sensor.py @@ -1,7 +1,7 @@ """Support for XS1 sensors.""" from xs1_api_client.api_constants import ActuatorType -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS, XS1DeviceEntity @@ -28,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensor_entities) -class XS1Sensor(XS1DeviceEntity, Entity): +class XS1Sensor(XS1DeviceEntity, SensorEntity): """Representation of a Sensor.""" @property diff --git a/homeassistant/components/yandex_transport/sensor.py b/homeassistant/components/yandex_transport/sensor.py index 0df073f581d..08e856a721e 100644 --- a/homeassistant/components/yandex_transport/sensor.py +++ b/homeassistant/components/yandex_transport/sensor.py @@ -6,11 +6,10 @@ import logging from aioymaps import YandexMapsRequester 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.helpers.aiohttp_client import async_create_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) @@ -47,7 +46,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([DiscoverYandexTransport(data, stop_id, routes, name)], True) -class DiscoverYandexTransport(Entity): +class DiscoverYandexTransport(SensorEntity): """Implementation of yandex_transport sensor.""" def __init__(self, requester: YandexMapsRequester, stop_id, routes, name): diff --git a/homeassistant/components/zabbix/sensor.py b/homeassistant/components/zabbix/sensor.py index 536709e5a83..a2644287690 100644 --- a/homeassistant/components/zabbix/sensor.py +++ b/homeassistant/components/zabbix/sensor.py @@ -4,10 +4,9 @@ import logging import voluptuous as vol from homeassistant.components import zabbix -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -79,7 +78,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class ZabbixTriggerCountSensor(Entity): +class ZabbixTriggerCountSensor(SensorEntity): """Get the active trigger count for all Zabbix monitored hosts.""" def __init__(self, zApi, name="Zabbix"): diff --git a/homeassistant/components/zamg/sensor.py b/homeassistant/components/zamg/sensor.py index ef0a476f612..2e2d07cea62 100644 --- a/homeassistant/components/zamg/sensor.py +++ b/homeassistant/components/zamg/sensor.py @@ -11,6 +11,7 @@ import pytz import requests import voluptuous as vol +from homeassistant.components.sensor import SensorEntity from homeassistant.const import ( AREA_SQUARE_METERS, ATTR_ATTRIBUTION, @@ -27,7 +28,6 @@ from homeassistant.const import ( __version__, ) import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -132,7 +132,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class ZamgSensor(Entity): +class ZamgSensor(SensorEntity): """Implementation of a ZAMG sensor.""" def __init__(self, probe, variable, name): diff --git a/homeassistant/components/zestimate/sensor.py b/homeassistant/components/zestimate/sensor.py index ed15d42b7e3..0333bb76a20 100644 --- a/homeassistant/components/zestimate/sensor.py +++ b/homeassistant/components/zestimate/sensor.py @@ -6,10 +6,9 @@ import requests import voluptuous as vol import xmltodict -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _RESOURCE = "http://www.zillow.com/webservice/GetZestimate.htm" @@ -56,7 +55,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class ZestimateDataSensor(Entity): +class ZestimateDataSensor(SensorEntity): """Implementation of a Zestimate sensor.""" def __init__(self, name, params): diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index 425a41a1340..41dce816e86 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -15,6 +15,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, DOMAIN, + SensorEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -89,7 +90,7 @@ async def async_setup_entry( hass.data[DATA_ZHA][DATA_ZHA_DISPATCHERS].append(unsub) -class Sensor(ZhaEntity): +class Sensor(ZhaEntity, SensorEntity): """Base ZHA sensor.""" SENSOR_ATTR: int | str | None = None diff --git a/homeassistant/components/zodiac/sensor.py b/homeassistant/components/zodiac/sensor.py index b602d7a50c4..4c037a7aa02 100644 --- a/homeassistant/components/zodiac/sensor.py +++ b/homeassistant/components/zodiac/sensor.py @@ -1,5 +1,5 @@ """Support for tracking the zodiac sign.""" -from homeassistant.helpers.entity import Entity +from homeassistant.components.sensor import SensorEntity from homeassistant.util.dt import as_local, utcnow from .const import ( @@ -162,7 +162,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([ZodiacSensor()], True) -class ZodiacSensor(Entity): +class ZodiacSensor(SensorEntity): """Representation of a Zodiac sensor.""" def __init__(self): diff --git a/homeassistant/components/zoneminder/sensor.py b/homeassistant/components/zoneminder/sensor.py index 75531e79e13..701f4b490d3 100644 --- a/homeassistant/components/zoneminder/sensor.py +++ b/homeassistant/components/zoneminder/sensor.py @@ -4,10 +4,9 @@ import logging import voluptuous as vol from zoneminder.monitor import TimePeriod -from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from . import DOMAIN as ZONEMINDER_DOMAIN @@ -57,7 +56,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors) -class ZMSensorMonitors(Entity): +class ZMSensorMonitors(SensorEntity): """Get the status of each ZoneMinder monitor.""" def __init__(self, monitor): @@ -91,7 +90,7 @@ class ZMSensorMonitors(Entity): self._is_available = self._monitor.is_available -class ZMSensorEvents(Entity): +class ZMSensorEvents(SensorEntity): """Get the number of events for each monitor.""" def __init__(self, monitor, include_archived, sensor_type): @@ -122,7 +121,7 @@ class ZMSensorEvents(Entity): self._state = self._monitor.get_events(self.time_period, self._include_archived) -class ZMSensorRunState(Entity): +class ZMSensorRunState(SensorEntity): """Get the ZoneMinder run state.""" def __init__(self, client): diff --git a/homeassistant/components/zwave/sensor.py b/homeassistant/components/zwave/sensor.py index aae38382f2e..a3183ba8927 100644 --- a/homeassistant/components/zwave/sensor.py +++ b/homeassistant/components/zwave/sensor.py @@ -1,5 +1,5 @@ """Support for Z-Wave sensors.""" -from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, DOMAIN +from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, DOMAIN, SensorEntity from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -37,7 +37,7 @@ def get_device(node, values, **kwargs): return None -class ZWaveSensor(ZWaveDeviceEntity): +class ZWaveSensor(ZWaveDeviceEntity, SensorEntity): """Representation of a Z-Wave sensor.""" def __init__(self, values): diff --git a/homeassistant/components/zwave_js/sensor.py b/homeassistant/components/zwave_js/sensor.py index 5f116f0790c..574e1af658c 100644 --- a/homeassistant/components/zwave_js/sensor.py +++ b/homeassistant/components/zwave_js/sensor.py @@ -13,6 +13,7 @@ from homeassistant.components.sensor import ( DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_POWER, DOMAIN as SENSOR_DOMAIN, + SensorEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -67,7 +68,7 @@ async def async_setup_entry( ) -class ZwaveSensorBase(ZWaveBaseEntity): +class ZwaveSensorBase(ZWaveBaseEntity, SensorEntity): """Basic Representation of a Z-Wave sensor.""" def __init__(