diff --git a/esphome/components/scd30/sensor.py b/esphome/components/scd30/sensor.py index a5eb5d8ca4..aad2a1811c 100644 --- a/esphome/components/scd30/sensor.py +++ b/esphome/components/scd30/sensor.py @@ -1,4 +1,3 @@ -import re import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import i2c, sensor @@ -28,10 +27,6 @@ CONF_AMBIENT_PRESSURE_COMPENSATION = "ambient_pressure_compensation" CONF_TEMPERATURE_OFFSET = "temperature_offset" -def remove_altitude_suffix(value): - return re.sub(r"\s*(?:m(?:\s+a\.s\.l)?)|(?:MAM?SL)$", "", value) - - CONFIG_SCHEMA = ( cv.Schema( { @@ -47,7 +42,7 @@ CONFIG_SCHEMA = ( ), cv.Optional(CONF_AUTOMATIC_SELF_CALIBRATION, default=True): cv.boolean, cv.Optional(CONF_ALTITUDE_COMPENSATION): cv.All( - remove_altitude_suffix, + cv.float_with_unit("altitude", "(m|m a.s.l.|MAMSL|MASL)"), cv.int_range(min=0, max=0xFFFF, max_included=False), ), cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure,