mirror of
https://github.com/esphome/esphome.git
synced 2025-09-14 17:22:20 +01:00
Remove last_reset_type and convert all those sensors to TOTAL_INCREASING (#2233)
This commit is contained in:
@@ -17,7 +17,6 @@ from esphome.const import (
|
||||
CONF_ICON,
|
||||
CONF_ID,
|
||||
CONF_INTERNAL,
|
||||
CONF_LAST_RESET_TYPE,
|
||||
CONF_ON_RAW_VALUE,
|
||||
CONF_ON_VALUE,
|
||||
CONF_ON_VALUE_RANGE,
|
||||
@@ -31,9 +30,6 @@ from esphome.const import (
|
||||
CONF_NAME,
|
||||
CONF_MQTT_ID,
|
||||
CONF_FORCE_UPDATE,
|
||||
LAST_RESET_TYPE_AUTO,
|
||||
LAST_RESET_TYPE_NEVER,
|
||||
LAST_RESET_TYPE_NONE,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_CARBON_MONOXIDE,
|
||||
@@ -85,15 +81,6 @@ STATE_CLASSES = {
|
||||
}
|
||||
validate_state_class = cv.enum(STATE_CLASSES, lower=True, space="_")
|
||||
|
||||
LastResetTypes = sensor_ns.enum("LastResetType")
|
||||
LAST_RESET_TYPES = {
|
||||
LAST_RESET_TYPE_NONE: LastResetTypes.LAST_RESET_TYPE_NONE,
|
||||
LAST_RESET_TYPE_NEVER: LastResetTypes.LAST_RESET_TYPE_NEVER,
|
||||
LAST_RESET_TYPE_AUTO: LastResetTypes.LAST_RESET_TYPE_AUTO,
|
||||
}
|
||||
validate_last_reset_type = cv.enum(LAST_RESET_TYPES, lower=True, space="_")
|
||||
|
||||
|
||||
IS_PLATFORM_COMPONENT = True
|
||||
|
||||
|
||||
@@ -183,7 +170,9 @@ SENSOR_SCHEMA = cv.NAMEABLE_SCHEMA.extend(cv.MQTT_COMPONENT_SCHEMA).extend(
|
||||
cv.Optional(CONF_ACCURACY_DECIMALS): validate_accuracy_decimals,
|
||||
cv.Optional(CONF_DEVICE_CLASS): validate_device_class,
|
||||
cv.Optional(CONF_STATE_CLASS): validate_state_class,
|
||||
cv.Optional(CONF_LAST_RESET_TYPE): validate_last_reset_type,
|
||||
cv.Optional("last_reset_type"): cv.invalid(
|
||||
"last_reset_type has been removed since 2021.9.0. state_class: total_increasing should be used for total values."
|
||||
),
|
||||
cv.Optional(CONF_FORCE_UPDATE, default=False): cv.boolean,
|
||||
cv.Optional(CONF_EXPIRE_AFTER): cv.All(
|
||||
cv.requires_component("mqtt"),
|
||||
@@ -220,7 +209,6 @@ def sensor_schema(
|
||||
accuracy_decimals: int = _UNDEF,
|
||||
device_class: str = _UNDEF,
|
||||
state_class: str = _UNDEF,
|
||||
last_reset_type: str = _UNDEF,
|
||||
) -> cv.Schema:
|
||||
schema = SENSOR_SCHEMA
|
||||
if unit_of_measurement is not _UNDEF:
|
||||
@@ -253,14 +241,6 @@ def sensor_schema(
|
||||
schema = schema.extend(
|
||||
{cv.Optional(CONF_STATE_CLASS, default=state_class): validate_state_class}
|
||||
)
|
||||
if last_reset_type is not _UNDEF:
|
||||
schema = schema.extend(
|
||||
{
|
||||
cv.Optional(
|
||||
CONF_LAST_RESET_TYPE, default=last_reset_type
|
||||
): validate_last_reset_type
|
||||
}
|
||||
)
|
||||
return schema
|
||||
|
||||
|
||||
@@ -511,8 +491,6 @@ async def setup_sensor_core_(var, config):
|
||||
cg.add(var.set_icon(config[CONF_ICON]))
|
||||
if CONF_ACCURACY_DECIMALS in config:
|
||||
cg.add(var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS]))
|
||||
if CONF_LAST_RESET_TYPE in config:
|
||||
cg.add(var.set_last_reset_type(config[CONF_LAST_RESET_TYPE]))
|
||||
cg.add(var.set_force_update(config[CONF_FORCE_UPDATE]))
|
||||
if config.get(CONF_FILTERS): # must exist and not be empty
|
||||
filters = await build_filters(config[CONF_FILTERS])
|
||||
|
Reference in New Issue
Block a user