From 07480b82f89154cd03f5103dc9211059107abcc2 Mon Sep 17 00:00:00 2001 From: farmio Date: Fri, 6 Aug 2021 14:01:34 +0200 Subject: [PATCH] move to `sensor/__init__.py` --- homeassistant/components/knx/schema.py | 3 +-- homeassistant/components/knx/sensor.py | 8 ++++++-- homeassistant/components/mqtt/sensor.py | 2 +- homeassistant/components/sensor/__init__.py | 1 + homeassistant/components/template/sensor.py | 2 +- homeassistant/const.py | 1 - 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/knx/schema.py b/homeassistant/components/knx/schema.py index 02a19e731b8..76dadd10118 100644 --- a/homeassistant/components/knx/schema.py +++ b/homeassistant/components/knx/schema.py @@ -17,14 +17,13 @@ from homeassistant.components.binary_sensor import ( DEVICE_CLASSES as BINARY_SENSOR_DEVICE_CLASSES, ) from homeassistant.components.cover import DEVICE_CLASSES as COVER_DEVICE_CLASSES -from homeassistant.components.sensor import STATE_CLASSES_SCHEMA +from homeassistant.components.sensor import CONF_STATE_CLASS, STATE_CLASSES_SCHEMA from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_PORT, - CONF_STATE_CLASS, CONF_TYPE, ) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index 2eb6a0c4ca6..196448e8262 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -6,8 +6,12 @@ from typing import Any from xknx import XKNX from xknx.devices import Sensor as XknxSensor -from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity -from homeassistant.const import CONF_NAME, CONF_STATE_CLASS, CONF_TYPE +from homeassistant.components.sensor import ( + CONF_STATE_CLASS, + DEVICE_CLASSES, + SensorEntity, +) +from homeassistant.const import CONF_NAME, CONF_TYPE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType diff --git a/homeassistant/components/mqtt/sensor.py b/homeassistant/components/mqtt/sensor.py index 676ff4d7729..f4629499db0 100644 --- a/homeassistant/components/mqtt/sensor.py +++ b/homeassistant/components/mqtt/sensor.py @@ -9,6 +9,7 @@ import voluptuous as vol from homeassistant.components import sensor from homeassistant.components.sensor import ( + CONF_STATE_CLASS, DEVICE_CLASSES_SCHEMA, STATE_CLASSES_SCHEMA, SensorEntity, @@ -17,7 +18,6 @@ from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_FORCE_UPDATE, CONF_NAME, - CONF_STATE_CLASS, CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, ) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index e36640b1c1d..51404ed7c40 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -66,6 +66,7 @@ DEVICE_CLASSES: Final[list[str]] = [ DEVICE_CLASSES_SCHEMA: Final = vol.All(vol.Lower, vol.In(DEVICE_CLASSES)) +CONF_STATE_CLASS: Final = "state_class" # The state represents a measurement in present time STATE_CLASS_MEASUREMENT: Final = "measurement" diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index a887890510a..e9afdbd8cb4 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -4,6 +4,7 @@ from __future__ import annotations import voluptuous as vol from homeassistant.components.sensor import ( + CONF_STATE_CLASS, DEVICE_CLASSES_SCHEMA, DOMAIN as SENSOR_DOMAIN, ENTITY_ID_FORMAT, @@ -38,7 +39,6 @@ from .const import ( CONF_AVAILABILITY_TEMPLATE, CONF_OBJECT_ID, CONF_PICTURE, - CONF_STATE_CLASS, CONF_TRIGGER, ) from .template_entity import TemplateEntity diff --git a/homeassistant/const.py b/homeassistant/const.py index 78f3c11d8bd..ccd42ca32bb 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -181,7 +181,6 @@ CONF_SLAVE: Final = "slave" CONF_SOURCE: Final = "source" CONF_SSL: Final = "ssl" CONF_STATE: Final = "state" -CONF_STATE_CLASS: Final = "state_class" CONF_STATE_TEMPLATE: Final = "state_template" CONF_STRUCTURE: Final = "structure" CONF_SWITCHES: Final = "switches"