diff --git a/esphome/components/a02yyuw/sensor.py b/esphome/components/a02yyuw/sensor.py index 5232b04546..d491a51be9 100644 --- a/esphome/components/a02yyuw/sensor.py +++ b/esphome/components/a02yyuw/sensor.py @@ -4,11 +4,11 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, ICON_ARROW_EXPAND_VERTICAL, DEVICE_CLASS_DISTANCE, + UNIT_MILLIMETER, ) CODEOWNERS = ["@TH-Braemer"] DEPENDENCIES = ["uart"] -UNIT_MILLIMETERS = "mm" a02yyuw_ns = cg.esphome_ns.namespace("a02yyuw") A02yyuwComponent = a02yyuw_ns.class_( @@ -17,7 +17,7 @@ A02yyuwComponent = a02yyuw_ns.class_( CONFIG_SCHEMA = sensor.sensor_schema( A02yyuwComponent, - unit_of_measurement=UNIT_MILLIMETERS, + unit_of_measurement=UNIT_MILLIMETER, icon=ICON_ARROW_EXPAND_VERTICAL, accuracy_decimals=0, state_class=STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/hydreon_rgxx/sensor.py b/esphome/components/hydreon_rgxx/sensor.py index 72b74bf624..fb2099c85e 100644 --- a/esphome/components/hydreon_rgxx/sensor.py +++ b/esphome/components/hydreon_rgxx/sensor.py @@ -12,13 +12,13 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, UNIT_CELSIUS, + UNIT_MILLIMETER, ICON_THERMOMETER, ) from . import RGModel, RG15Resolution, HydreonRGxxComponent UNIT_INTENSITY = "intensity" -UNIT_MILLIMETERS = "mm" UNIT_MILLIMETERS_PER_HOUR = "mm/h" CONF_ACC = "acc" @@ -85,19 +85,19 @@ CONFIG_SCHEMA = cv.All( ), cv.Optional(CONF_RESOLUTION): cv.enum(RG15_RESOLUTION, upper=False), cv.Optional(CONF_ACC): sensor.sensor_schema( - unit_of_measurement=UNIT_MILLIMETERS, + unit_of_measurement=UNIT_MILLIMETER, accuracy_decimals=2, device_class=DEVICE_CLASS_PRECIPITATION, state_class=STATE_CLASS_MEASUREMENT, ), cv.Optional(CONF_EVENT_ACC): sensor.sensor_schema( - unit_of_measurement=UNIT_MILLIMETERS, + unit_of_measurement=UNIT_MILLIMETER, accuracy_decimals=2, device_class=DEVICE_CLASS_PRECIPITATION, state_class=STATE_CLASS_MEASUREMENT, ), cv.Optional(CONF_TOTAL_ACC): sensor.sensor_schema( - unit_of_measurement=UNIT_MILLIMETERS, + unit_of_measurement=UNIT_MILLIMETER, accuracy_decimals=2, device_class=DEVICE_CLASS_PRECIPITATION, state_class=STATE_CLASS_TOTAL_INCREASING, diff --git a/esphome/components/mopeka_pro_check/sensor.py b/esphome/components/mopeka_pro_check/sensor.py index 51a515ef0c..0ba33e94de 100644 --- a/esphome/components/mopeka_pro_check/sensor.py +++ b/esphome/components/mopeka_pro_check/sensor.py @@ -12,6 +12,7 @@ from esphome.const import ( CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, UNIT_CELSIUS, + UNIT_MILLIMETER, STATE_CLASS_MEASUREMENT, CONF_BATTERY_LEVEL, DEVICE_CLASS_BATTERY, @@ -25,8 +26,6 @@ ICON_PROPANE_TANK = "mdi:propane-tank" TANK_TYPE_CUSTOM = "CUSTOM" -UNIT_MILLIMETER = "mm" - def small_distance(value): """small_distance is stored in mm""" diff --git a/esphome/components/mopeka_std_check/sensor.py b/esphome/components/mopeka_std_check/sensor.py index bbba798e95..ac745cf3d5 100644 --- a/esphome/components/mopeka_std_check/sensor.py +++ b/esphome/components/mopeka_std_check/sensor.py @@ -12,6 +12,7 @@ from esphome.const import ( CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, UNIT_CELSIUS, + UNIT_MILLIMETER, STATE_CLASS_MEASUREMENT, CONF_BATTERY_LEVEL, DEVICE_CLASS_BATTERY, @@ -26,8 +27,6 @@ ICON_PROPANE_TANK = "mdi:propane-tank" TANK_TYPE_CUSTOM = "CUSTOM" -UNIT_MILLIMETER = "mm" - def small_distance(value): """small_distance is stored in mm""" diff --git a/esphome/const.py b/esphome/const.py index ed0a9b1f64..dcb353ab1c 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1035,6 +1035,7 @@ UNIT_MICROSIEMENS_PER_CENTIMETER = "µS/cm" UNIT_MICROSILVERTS_PER_HOUR = "µSv/h" UNIT_MICROTESLA = "µT" UNIT_MILLIGRAMS_PER_CUBIC_METER = "mg/m³" +UNIT_MILLIMETER = "mm" UNIT_MILLISECOND = "ms" UNIT_MILLISIEMENS_PER_CENTIMETER = "mS/cm" UNIT_MINUTE = "min"