From 7cfc28e915a31994faa9d6937ec15c32e75fa062 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:46:47 +0200 Subject: [PATCH] Add unit constant for revolutions per minute (#78752) --- homeassistant/components/comfoconnect/sensor.py | 5 +++-- homeassistant/components/xiaomi_miio/number.py | 6 +++--- homeassistant/components/xiaomi_miio/sensor.py | 11 ++++++----- homeassistant/const.py | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/comfoconnect/sensor.py b/homeassistant/components/comfoconnect/sensor.py index 2be98b9eeb5..efb6b11a6d9 100644 --- a/homeassistant/components/comfoconnect/sensor.py +++ b/homeassistant/components/comfoconnect/sensor.py @@ -41,6 +41,7 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_WATT, + REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS, TIME_DAYS, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, @@ -159,7 +160,7 @@ SENSOR_TYPES = ( key=ATTR_SUPPLY_FAN_SPEED, state_class=SensorStateClass.MEASUREMENT, name="Supply fan speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fan-plus", sensor_id=SENSOR_FAN_SUPPLY_SPEED, ), @@ -175,7 +176,7 @@ SENSOR_TYPES = ( key=ATTR_EXHAUST_FAN_SPEED, state_class=SensorStateClass.MEASUREMENT, name="Exhaust fan speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fan-minus", sensor_id=SENSOR_FAN_EXHAUST_SPEED, ), diff --git a/homeassistant/components/xiaomi_miio/number.py b/homeassistant/components/xiaomi_miio/number.py index b324ab318a0..15cb7175d91 100644 --- a/homeassistant/components/xiaomi_miio/number.py +++ b/homeassistant/components/xiaomi_miio/number.py @@ -12,7 +12,7 @@ from homeassistant.components.number import ( NumberEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_MODEL, DEGREE, TIME_MINUTES +from homeassistant.const import CONF_MODEL, DEGREE, REVOLUTIONS_PER_MINUTE, TIME_MINUTES from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity import EntityCategory @@ -135,7 +135,7 @@ NUMBER_TYPES = { key=ATTR_MOTOR_SPEED, name="Motor speed", icon="mdi:fast-forward-outline", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, native_min_value=200, native_max_value=2000, native_step=10, @@ -219,7 +219,7 @@ NUMBER_TYPES = { key=ATTR_FAVORITE_RPM, name="Favorite motor speed", icon="mdi:star-cog", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, native_min_value=300, native_max_value=2200, native_step=10, diff --git a/homeassistant/components/xiaomi_miio/sensor.py b/homeassistant/components/xiaomi_miio/sensor.py index 472339a4103..6a84874e2e6 100644 --- a/homeassistant/components/xiaomi_miio/sensor.py +++ b/homeassistant/components/xiaomi_miio/sensor.py @@ -35,6 +35,7 @@ from homeassistant.const import ( PERCENTAGE, POWER_WATT, PRESSURE_HPA, + REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS, TIME_DAYS, TIME_HOURS, @@ -192,7 +193,7 @@ SENSOR_TYPES = { ATTR_ACTUAL_SPEED: XiaomiMiioSensorDescription( key=ATTR_ACTUAL_SPEED, name="Actual speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fast-forward", state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -200,7 +201,7 @@ SENSOR_TYPES = { ATTR_CONTROL_SPEED: XiaomiMiioSensorDescription( key=ATTR_CONTROL_SPEED, name="Control speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fast-forward", state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -208,7 +209,7 @@ SENSOR_TYPES = { ATTR_FAVORITE_SPEED: XiaomiMiioSensorDescription( key=ATTR_FAVORITE_SPEED, name="Favorite speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fast-forward", state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -216,7 +217,7 @@ SENSOR_TYPES = { ATTR_MOTOR_SPEED: XiaomiMiioSensorDescription( key=ATTR_MOTOR_SPEED, name="Motor speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fast-forward", state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -224,7 +225,7 @@ SENSOR_TYPES = { ATTR_MOTOR2_SPEED: XiaomiMiioSensorDescription( key=ATTR_MOTOR2_SPEED, name="Second motor speed", - native_unit_of_measurement="rpm", + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, icon="mdi:fast-forward", state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/const.py b/homeassistant/const.py index 7afb781b3d9..27d172265ce 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -588,6 +588,9 @@ UV_INDEX: Final = "UV index" # Percentage units PERCENTAGE: Final = "%" +# Rotational speed units +REVOLUTIONS_PER_MINUTE: Final = "rpm" + # Irradiation units IRRADIATION_WATTS_PER_SQUARE_METER: Final = "W/m²" IRRADIATION_BTUS_PER_HOUR_SQUARE_FOOT: Final = "BTU/(h×ft²)"