diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index 00646249399..a79453eec98 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -23,13 +23,13 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_CURRENT_AMPERE, LIGHT_LUX, PERCENTAGE, PRESSURE_HPA, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, Platform, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, @@ -153,14 +153,14 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Current", device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, ), CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20, name="Current", device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, ), CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR, @@ -195,7 +195,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Amps", device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, ), CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY, diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 79646ab5f95..e9feaf06933 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -17,11 +17,11 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEGREE, - ELECTRIC_CURRENT_AMPERE, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, @@ -89,7 +89,7 @@ SENSORS: Final = { ("emeter", "current"): BlockSensorDescription( key="emeter|current", name="Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, value=lambda value: value, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index 6803435bc36..d588f4811bb 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -16,9 +16,9 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, PERCENTAGE, TEMP_CELSIUS, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfFrequency, @@ -64,7 +64,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = { (Units.A, False): SensorEntityDescription( key=f"{Units.A}_{False}", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), (Units.W, False): SensorEntityDescription( diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index bddebaab491..6420221fcf5 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -19,7 +19,6 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_CURRENT_AMPERE, LIGHT_LUX, PERCENTAGE, PRESSURE_HPA, @@ -32,6 +31,7 @@ from homeassistant.const import ( TEMP_FAHRENHEIT, TEMP_KELVIN, UnitOfApparentPower, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfFrequency, @@ -213,7 +213,7 @@ SENSOR_UNIT_MAP = { hc.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, hc.CONCENTRATION_PARTS_PER_BILLION: CONCENTRATION_PARTS_PER_BILLION, hc.CONCENTRATION_PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION, - hc.ELECTRICAL_CURRENT_AMPERE: ELECTRIC_CURRENT_AMPERE, + hc.ELECTRICAL_CURRENT_AMPERE: UnitOfElectricCurrent.AMPERE, hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE, hc.ENERGY_KILO_WATT_HOUR: UnitOfEnergy.KILO_WATT_HOUR, hc.FREQUENCY_HERTZ: UnitOfFrequency.HERTZ, diff --git a/homeassistant/components/tplink/sensor.py b/homeassistant/components/tplink/sensor.py index 54c36740ab9..7471ed8982b 100644 --- a/homeassistant/components/tplink/sensor.py +++ b/homeassistant/components/tplink/sensor.py @@ -15,7 +15,7 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_VOLTAGE, - ELECTRIC_CURRENT_AMPERE, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, @@ -81,7 +81,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = ( ), TPLinkSensorEntityDescription( key=ATTR_CURRENT_A, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, name="Current", diff --git a/homeassistant/components/wallbox/sensor.py b/homeassistant/components/wallbox/sensor.py index 68dffdb51c1..afd2b13f790 100644 --- a/homeassistant/components/wallbox/sensor.py +++ b/homeassistant/components/wallbox/sensor.py @@ -13,8 +13,8 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, PERCENTAGE, + UnitOfElectricCurrent, UnitOfEnergy, UnitOfLength, UnitOfPower, @@ -70,7 +70,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { key=CHARGER_MAX_AVAILABLE_POWER_KEY, name="Max Available Power", precision=0, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), @@ -146,7 +146,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { CHARGER_MAX_CHARGING_CURRENT_KEY: WallboxSensorEntityDescription( key=CHARGER_MAX_CHARGING_CURRENT_KEY, name="Max. Charging Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/zwave_me/sensor.py b/homeassistant/components/zwave_me/sensor.py index ac2a4c30cf9..2ac2a06fcd7 100644 --- a/homeassistant/components/zwave_me/sensor.py +++ b/homeassistant/components/zwave_me/sensor.py @@ -14,11 +14,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, LIGHT_LUX, PERCENTAGE, PRESSURE_KPA, TEMP_CELSIUS, + UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, @@ -72,7 +72,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = { "meterElectric_ampere": ZWaveMeSensorEntityDescription( key="meterElectric_ampere", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), "meterElectric_kilowatt_hour": ZWaveMeSensorEntityDescription(