From 82f66df578dd2a1df0d5628921436e89bb15388a Mon Sep 17 00:00:00 2001 From: farmio Date: Thu, 5 Aug 2021 23:37:53 +0200 Subject: [PATCH] add CONF_STATE_CLASS to const.py --- homeassistant/components/knx/schema.py | 2 +- homeassistant/components/knx/sensor.py | 4 ++-- homeassistant/components/mqtt/sensor.py | 2 +- homeassistant/components/template/const.py | 1 - homeassistant/const.py | 1 + 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/knx/schema.py b/homeassistant/components/knx/schema.py index 196c171c9b5..02a19e731b8 100644 --- a/homeassistant/components/knx/schema.py +++ b/homeassistant/components/knx/schema.py @@ -24,6 +24,7 @@ from homeassistant.const import ( CONF_HOST, CONF_NAME, CONF_PORT, + CONF_STATE_CLASS, CONF_TYPE, ) import homeassistant.helpers.config_validation as cv @@ -725,7 +726,6 @@ class SensorSchema(KNXPlatformSchema): CONF_ALWAYS_CALLBACK = "always_callback" CONF_STATE_ADDRESS = CONF_STATE_ADDRESS - CONF_STATE_CLASS = "state_class" CONF_SYNC_STATE = CONF_SYNC_STATE DEFAULT_NAME = "KNX Sensor" diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index 5fee8446e91..2eb6a0c4ca6 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -7,7 +7,7 @@ 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_TYPE +from homeassistant.const import CONF_NAME, CONF_STATE_CLASS, CONF_TYPE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType @@ -63,7 +63,7 @@ class KNXSensor(KnxEntity, SensorEntity): self._attr_force_update = self._device.always_callback self._attr_unique_id = str(self._device.sensor_value.group_address_state) self._attr_unit_of_measurement = self._device.unit_of_measurement() - self._attr_state_class = config.get(SensorSchema.CONF_STATE_CLASS) + self._attr_state_class = config.get(CONF_STATE_CLASS) @property def state(self) -> StateType: diff --git a/homeassistant/components/mqtt/sensor.py b/homeassistant/components/mqtt/sensor.py index 239af7b450a..676ff4d7729 100644 --- a/homeassistant/components/mqtt/sensor.py +++ b/homeassistant/components/mqtt/sensor.py @@ -17,6 +17,7 @@ from homeassistant.const import ( CONF_DEVICE_CLASS, CONF_FORCE_UPDATE, CONF_NAME, + CONF_STATE_CLASS, CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, ) @@ -42,7 +43,6 @@ _LOGGER = logging.getLogger(__name__) CONF_EXPIRE_AFTER = "expire_after" CONF_LAST_RESET_TOPIC = "last_reset_topic" CONF_LAST_RESET_VALUE_TEMPLATE = "last_reset_value_template" -CONF_STATE_CLASS = "state_class" MQTT_SENSOR_ATTRIBUTES_BLOCKED = frozenset( { diff --git a/homeassistant/components/template/const.py b/homeassistant/components/template/const.py index 31896e930e4..661953bcfa5 100644 --- a/homeassistant/components/template/const.py +++ b/homeassistant/components/template/const.py @@ -25,4 +25,3 @@ CONF_AVAILABILITY = "availability" CONF_ATTRIBUTES = "attributes" CONF_PICTURE = "picture" CONF_OBJECT_ID = "object_id" -CONF_STATE_CLASS = "state_class" diff --git a/homeassistant/const.py b/homeassistant/const.py index ccd42ca32bb..78f3c11d8bd 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -181,6 +181,7 @@ 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"