Extend state class sensor warnings with expected values (#87294)

This commit is contained in:
Franck Nijhof
2023-02-04 11:49:24 +01:00
committed by GitHub
parent 95e8717fb4
commit bf482eee24
3 changed files with 11 additions and 2 deletions
@@ -508,12 +508,15 @@ class SensorEntity(Entity):
_LOGGER.warning(
"Entity %s (%s) is using state class '%s' which "
"is impossible considering device class ('%s') it is using; "
"expected %s%s; "
"Please update your configuration if your entity is manually "
"configured, otherwise %s",
self.entity_id,
type(self),
state_class,
device_class,
"None or one of " if classes else "None",
", ".join(f"'{value.value}'" for value in classes),
report_issue,
)
+1 -1
View File
@@ -509,7 +509,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = {
SensorDeviceClass.WIND_SPEED: set(UnitOfSpeed),
}
DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass | None]] = {
DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = {
SensorDeviceClass.APPARENT_POWER: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.AQI: {SensorStateClass.MEASUREMENT},
SensorDeviceClass.ATMOSPHERIC_PRESSURE: {SensorStateClass.MEASUREMENT},