From 604d0d066bfcb93f1a11e3d7732d430ab6de8d59 Mon Sep 17 00:00:00 2001 From: farmio Date: Thu, 19 Aug 2021 12:21:17 +0200 Subject: [PATCH] move to sensor/const.py --- homeassistant/components/knx/schema.py | 3 ++- homeassistant/components/knx/sensor.py | 7 ++----- homeassistant/components/mqtt/sensor.py | 2 +- homeassistant/components/sensor/__init__.py | 1 - homeassistant/components/sensor/const.py | 4 ++++ homeassistant/components/template/sensor.py | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 homeassistant/components/sensor/const.py diff --git a/homeassistant/components/knx/schema.py b/homeassistant/components/knx/schema.py index 76dadd10118..34b314ff357 100644 --- a/homeassistant/components/knx/schema.py +++ b/homeassistant/components/knx/schema.py @@ -17,7 +17,8 @@ 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 CONF_STATE_CLASS, STATE_CLASSES_SCHEMA +from homeassistant.components.sensor import STATE_CLASSES_SCHEMA +from homeassistant.components.sensor.const import CONF_STATE_CLASS from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_ID, diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index c1f68e4c376..6df10eb790e 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -6,11 +6,8 @@ from typing import Any from xknx import XKNX from xknx.devices import Sensor as XknxSensor -from homeassistant.components.sensor import ( - CONF_STATE_CLASS, - DEVICE_CLASSES, - SensorEntity, -) +from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity +from homeassistant.components.sensor.const import CONF_STATE_CLASS from homeassistant.const import CONF_NAME, CONF_TYPE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback diff --git a/homeassistant/components/mqtt/sensor.py b/homeassistant/components/mqtt/sensor.py index c5441840878..14ba0d6fb88 100644 --- a/homeassistant/components/mqtt/sensor.py +++ b/homeassistant/components/mqtt/sensor.py @@ -9,11 +9,11 @@ import voluptuous as vol from homeassistant.components import sensor from homeassistant.components.sensor import ( - CONF_STATE_CLASS, DEVICE_CLASSES_SCHEMA, STATE_CLASSES_SCHEMA, SensorEntity, ) +from homeassistant.components.sensor.const import CONF_STATE_CLASS from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_FORCE_UPDATE, diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 84d0a404304..94fb08c66b1 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -89,7 +89,6 @@ 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" # The state represents a monotonically increasing total, e.g. an amount of consumed gas diff --git a/homeassistant/components/sensor/const.py b/homeassistant/components/sensor/const.py new file mode 100644 index 00000000000..54d683242ea --- /dev/null +++ b/homeassistant/components/sensor/const.py @@ -0,0 +1,4 @@ +"""Constants for sensor.""" +from typing import Final + +CONF_STATE_CLASS: Final = "state_class" diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index 4214323c8ee..283186dffad 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -4,7 +4,6 @@ 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, @@ -12,6 +11,7 @@ from homeassistant.components.sensor import ( STATE_CLASSES_SCHEMA, SensorEntity, ) +from homeassistant.components.sensor.const import CONF_STATE_CLASS from homeassistant.const import ( ATTR_ENTITY_ID, CONF_DEVICE_CLASS,