diff --git a/homeassistant/components/broadlink/sensor.py b/homeassistant/components/broadlink/sensor.py index 7b91f4bf170..8f5a6c6ebbb 100644 --- a/homeassistant/components/broadlink/sensor.py +++ b/homeassistant/components/broadlink/sensor.py @@ -9,11 +9,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -60,7 +60,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="volt", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/bthome/sensor.py b/homeassistant/components/bthome/sensor.py index 39389fdd498..4b2cfc913e2 100644 --- a/homeassistant/components/bthome/sensor.py +++ b/homeassistant/components/bthome/sensor.py @@ -22,12 +22,12 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_MILLION, DEGREE, - ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TIME_SECONDS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfEnergy, UnitOfLength, UnitOfMass, @@ -82,7 +82,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{BTHomeSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), ( diff --git a/homeassistant/components/dsmr_reader/definitions.py b/homeassistant/components/dsmr_reader/definitions.py index 81d9b348f17..aa45b457c6f 100644 --- a/homeassistant/components/dsmr_reader/definitions.py +++ b/homeassistant/components/dsmr_reader/definitions.py @@ -12,10 +12,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import ( CURRENCY_EURO, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.util import dt as dt_util @@ -149,7 +149,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L1", entity_registry_enabled_default=False, device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -157,7 +157,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L2", entity_registry_enabled_default=False, device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -165,7 +165,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L3", entity_registry_enabled_default=False, device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( diff --git a/homeassistant/components/edl21/sensor.py b/homeassistant/components/edl21/sensor.py index cf6ad175c41..98c1536f28b 100644 --- a/homeassistant/components/edl21/sensor.py +++ b/homeassistant/components/edl21/sensor.py @@ -18,10 +18,10 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( CONF_NAME, DEGREE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -259,7 +259,7 @@ SENSOR_UNIT_MAPPING = { "kWh": ENERGY_KILO_WATT_HOUR, "W": UnitOfPower.WATT, "A": UnitOfElectricCurrent.AMPERE, - "V": ELECTRIC_POTENTIAL_VOLT, + "V": UnitOfElectricPotential.VOLT, "°": DEGREE, "Hz": UnitOfFrequency.HERTZ, } diff --git a/homeassistant/components/elkm1/sensor.py b/homeassistant/components/elkm1/sensor.py index 1d84af259ee..aac9f630f9e 100644 --- a/homeassistant/components/elkm1/sensor.py +++ b/homeassistant/components/elkm1/sensor.py @@ -16,7 +16,7 @@ import voluptuous as vol from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ELECTRIC_POTENTIAL_VOLT +from homeassistant.const import UnitOfElectricPotential from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_platform @@ -278,7 +278,7 @@ class ElkZone(ElkSensor): if self._element.definition == ZoneType.TEMPERATURE: return self._temperature_unit if self._element.definition == ZoneType.ANALOG_ZONE: - return ELECTRIC_POTENTIAL_VOLT + return UnitOfElectricPotential.VOLT return None def _element_changed(self, _: Element, changeset: Any) -> None: diff --git a/homeassistant/components/fritzbox/sensor.py b/homeassistant/components/fritzbox/sensor.py index a59ec0642b4..136c2683e52 100644 --- a/homeassistant/components/fritzbox/sensor.py +++ b/homeassistant/components/fritzbox/sensor.py @@ -17,11 +17,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -140,7 +140,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = ( FritzSensorEntityDescription( key="voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return] diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index 0c30ef5ccc3..e693c9fdf19 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -11,13 +11,13 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, PERCENTAGE, POWER_VOLT_AMPERE_REACTIVE, TEMP_CELSIUS, UnitOfApparentPower, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -139,7 +139,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac", name="Voltage AC", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -147,7 +147,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_dc", name="Voltage DC", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -155,7 +155,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_dc_2", name="Voltage DC 2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -427,7 +427,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_1", name="Voltage AC phase 1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -435,7 +435,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_2", name="Voltage AC phase 2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -443,7 +443,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_3", name="Voltage AC phase 3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -451,7 +451,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_to_phase_12", name="Voltage AC phase 1-2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -459,7 +459,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_to_phase_23", name="Voltage AC phase 2-3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -467,7 +467,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_ac_phase_to_phase_31", name="Voltage AC phase 3-1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -611,7 +611,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_dc", name="Voltage DC", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -619,7 +619,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_dc_maximum_cell", name="Voltage DC maximum cell", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -628,7 +628,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="voltage_dc_minimum_cell", name="Voltage DC minimum cell", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", diff --git a/homeassistant/components/goalzero/sensor.py b/homeassistant/components/goalzero/sensor.py index e50ff783643..847c90472fe 100644 --- a/homeassistant/components/goalzero/sensor.py +++ b/homeassistant/components/goalzero/sensor.py @@ -11,7 +11,6 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, @@ -19,6 +18,7 @@ from homeassistant.const import ( TIME_MINUTES, TIME_SECONDS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -79,7 +79,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="volts", name="Volts", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, entity_registry_enabled_default=False, ), SensorEntityDescription( diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index 5919909f858..60d0dbe7c54 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -10,10 +10,10 @@ from homeassistant.const import ( CONF_NAME, CONF_SENSORS, CONF_TEMPERATURE_UNIT, - ELECTRIC_POTENTIAL_VOLT, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -275,7 +275,7 @@ class TemperatureSensor(GEMSensor): class VoltageSensor(GEMSensor): """Entity showing voltage.""" - _attr_native_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT + _attr_native_unit_of_measurement = UnitOfElectricPotential.VOLT _attr_device_class = SensorDeviceClass.VOLTAGE def __init__( diff --git a/homeassistant/components/growatt_server/sensor_types/inverter.py b/homeassistant/components/growatt_server/sensor_types/inverter.py index f996fde017d..f93e9f02c1f 100644 --- a/homeassistant/components/growatt_server/sensor_types/inverter.py +++ b/homeassistant/components/growatt_server/sensor_types/inverter.py @@ -3,10 +3,10 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -35,7 +35,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_voltage_input_1", name="Input 1 voltage", api_key="vpv1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=2, ), @@ -59,7 +59,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_voltage_input_2", name="Input 2 voltage", api_key="vpv2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), @@ -83,7 +83,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_voltage_input_3", name="Input 3 voltage", api_key="vpv3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), @@ -115,7 +115,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_reactive_voltage", name="Reactive voltage", api_key="vacr", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), diff --git a/homeassistant/components/growatt_server/sensor_types/mix.py b/homeassistant/components/growatt_server/sensor_types/mix.py index 8e72671e3d5..ec18f14fc01 100644 --- a/homeassistant/components/growatt_server/sensor_types/mix.py +++ b/homeassistant/components/growatt_server/sensor_types/mix.py @@ -3,9 +3,9 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, + UnitOfElectricPotential, UnitOfPower, ) @@ -76,21 +76,21 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="mix_battery_voltage", name="Battery voltage", api_key="vbat", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, ), GrowattSensorEntityDescription( key="mix_pv1_voltage", name="PV1 voltage", api_key="vpv1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, ), GrowattSensorEntityDescription( key="mix_pv2_voltage", name="PV2 voltage", api_key="vpv2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, ), # Values from 'mix_totals' API call @@ -185,7 +185,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="mix_grid_voltage", name="Grid voltage", api_key="vAc1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, ), # Values from 'mix_detail' API call diff --git a/homeassistant/components/growatt_server/sensor_types/storage.py b/homeassistant/components/growatt_server/sensor_types/storage.py index 59e61982d76..5b29904b148 100644 --- a/homeassistant/components/growatt_server/sensor_types/storage.py +++ b/homeassistant/components/growatt_server/sensor_types/storage.py @@ -3,10 +3,10 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -133,7 +133,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_grid_voltage", name="AC input voltage", api_key="vGrid", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=2, ), @@ -141,7 +141,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_pv_charging_voltage", name="PV charging voltage", api_key="vpv", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=2, ), @@ -157,7 +157,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_output_voltage", name="Output voltage", api_key="outPutVolt", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=2, ), @@ -205,7 +205,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_battery_voltage", name="Battery voltage", api_key="vBat", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=2, ), diff --git a/homeassistant/components/growatt_server/sensor_types/tlx.py b/homeassistant/components/growatt_server/sensor_types/tlx.py index e44f242b823..f381eca89bb 100644 --- a/homeassistant/components/growatt_server/sensor_types/tlx.py +++ b/homeassistant/components/growatt_server/sensor_types/tlx.py @@ -3,10 +3,10 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -54,7 +54,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="tlx_voltage_input_1", name="Input 1 voltage", api_key="vpv1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), @@ -96,7 +96,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="tlx_voltage_input_2", name="Input 2 voltage", api_key="vpv2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), @@ -128,7 +128,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="tlx_reactive_voltage", name="Reactive voltage", api_key="vacrs", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, precision=1, ), diff --git a/homeassistant/components/guardian/sensor.py b/homeassistant/components/guardian/sensor.py index 05de437b10a..d600657782f 100644 --- a/homeassistant/components/guardian/sensor.py +++ b/homeassistant/components/guardian/sensor.py @@ -10,7 +10,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ELECTRIC_POTENTIAL_VOLT, TEMP_FAHRENHEIT, TIME_MINUTES +from homeassistant.const import TEMP_FAHRENHEIT, TIME_MINUTES, UnitOfElectricPotential from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import EntityCategory @@ -48,7 +48,7 @@ PAIRED_SENSOR_DESCRIPTIONS = ( name="Battery", device_class=SensorDeviceClass.VOLTAGE, entity_category=EntityCategory.DIAGNOSTIC, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, ), SensorEntityDescription( key=SENSOR_KIND_TEMPERATURE, diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index edb3c1bfb6b..7f838435c98 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -24,7 +24,6 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_MILLION, ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, LIGHT_LUX, PERCENTAGE, @@ -32,6 +31,7 @@ from homeassistant.const import ( SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, Platform, + UnitOfElectricPotential, UnitOfPower, UnitOfSoundPressure, ) @@ -188,7 +188,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Volts", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, ), CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE, diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index f005151b3e0..8450ee5aca5 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -15,7 +15,6 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_MILLION, DEGREE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, LIGHT_LUX, @@ -23,6 +22,7 @@ from homeassistant.const import ( PRESSURE_HPA, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, UnitOfPrecipitationDepth, @@ -148,7 +148,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { ), "VOLTAGE": SensorEntityDescription( key="VOLTAGE", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/iotawatt/sensor.py b/homeassistant/components/iotawatt/sensor.py index 592d93190cb..23d97895458 100644 --- a/homeassistant/components/iotawatt/sensor.py +++ b/homeassistant/components/iotawatt/sensor.py @@ -15,11 +15,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, PERCENTAGE, UnitOfApparentPower, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -109,7 +109,7 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = { ), "Volts": IotaWattSensorEntityDescription( "Volts", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, diff --git a/homeassistant/components/juicenet/sensor.py b/homeassistant/components/juicenet/sensor.py index 404f547c207..632008e9e15 100644 --- a/homeassistant/components/juicenet/sensor.py +++ b/homeassistant/components/juicenet/sensor.py @@ -9,11 +9,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, TEMP_CELSIUS, TIME_SECONDS, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -37,7 +37,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, ), SensorEntityDescription( diff --git a/homeassistant/components/kostal_plenticore/sensor.py b/homeassistant/components/kostal_plenticore/sensor.py index 421b9e6e8ba..d95d6462456 100644 --- a/homeassistant/components/kostal_plenticore/sensor.py +++ b/homeassistant/components/kostal_plenticore/sensor.py @@ -15,10 +15,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -142,7 +142,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv1", key="U", name="DC1 Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -169,7 +169,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv2", key="U", name="DC2 Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -196,7 +196,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv3", key="U", name="DC3 Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", diff --git a/homeassistant/components/moat/sensor.py b/homeassistant/components/moat/sensor.py index 29133e11283..f354dfd8f9b 100644 --- a/homeassistant/components/moat/sensor.py +++ b/homeassistant/components/moat/sensor.py @@ -20,10 +20,10 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -53,7 +53,7 @@ SENSOR_DESCRIPTIONS = { (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), ( diff --git a/homeassistant/components/oncue/sensor.py b/homeassistant/components/oncue/sensor.py index 0d39f23073b..9dcbbeb10b8 100644 --- a/homeassistant/components/oncue/sensor.py +++ b/homeassistant/components/oncue/sensor.py @@ -11,13 +11,13 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, PRESSURE_PSI, TEMP_CELSIUS, TEMP_FAHRENHEIT, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -60,7 +60,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="BatteryVoltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -97,7 +97,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="GeneratorVoltageAverageLineToLine", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -138,14 +138,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="Source1VoltageAverageLineToLine", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), SensorEntityDescription( key="Source2VoltageAverageLineToLine", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index f6c88201dc7..f59d8a78ba4 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -17,12 +17,12 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, PRESSURE_CBAR, PRESSURE_MBAR, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -171,7 +171,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, name="Voltage VAD", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -180,7 +180,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, name="Voltage VDD", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -189,7 +189,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, name="vis", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -222,7 +222,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -231,7 +231,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.VOLTAGE, entity_registry_enabled_default=False, name="vis", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index c069aea5630..90d447e2e16 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -14,9 +14,9 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, CURRENCY_EURO, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, UnitOfVolume, ) @@ -98,21 +98,21 @@ SENSORS_PHASES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="voltage_phase_l1", name="Voltage Phase L1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="voltage_phase_l2", name="Voltage Phase L2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="voltage_phase_l3", name="Voltage Phase L3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/powerwall/sensor.py b/homeassistant/components/powerwall/sensor.py index 8f0481977e3..a748a045663 100644 --- a/homeassistant/components/powerwall/sensor.py +++ b/homeassistant/components/powerwall/sensor.py @@ -14,10 +14,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -98,7 +98,7 @@ POWERWALL_INSTANT_SENSORS = ( name="Average Voltage Now", state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, entity_registry_enabled_default=False, value_fn=_get_meter_average_voltage, ), diff --git a/homeassistant/components/pvoutput/sensor.py b/homeassistant/components/pvoutput/sensor.py index a42c83b587e..d4a5b408700 100644 --- a/homeassistant/components/pvoutput/sensor.py +++ b/homeassistant/components/pvoutput/sensor.py @@ -14,10 +14,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, TEMP_CELSIUS, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -94,7 +94,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = ( PVOutputSensorEntityDescription( key="voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda status: status.voltage, diff --git a/homeassistant/components/sensibo/sensor.py b/homeassistant/components/sensibo/sensor.py index 6ff622f7275..bb54edbe03a 100644 --- a/homeassistant/components/sensibo/sensor.py +++ b/homeassistant/components/sensibo/sensor.py @@ -19,10 +19,10 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -90,7 +90,7 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = ( key="battery_voltage", device_class=SensorDeviceClass.VOLTAGE, entity_category=EntityCategory.DIAGNOSTIC, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, name="Battery voltage", icon="mdi:battery", diff --git a/homeassistant/components/sensorpro/sensor.py b/homeassistant/components/sensorpro/sensor.py index deb79e62bdc..ce5e5fec9f2 100644 --- a/homeassistant/components/sensorpro/sensor.py +++ b/homeassistant/components/sensorpro/sensor.py @@ -23,10 +23,10 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{SensorProSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), } diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index c951cf7c5ea..9ee8836eb88 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -18,12 +18,12 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, DEGREE, ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -122,7 +122,7 @@ SENSORS: Final = { ("device", "voltage"): BlockSensorDescription( key="device|voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda value: round(value, 1), device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -131,7 +131,7 @@ SENSORS: Final = { ("emeter", "voltage"): BlockSensorDescription( key="emeter|voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda value: round(value, 1), device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -276,7 +276,7 @@ SENSORS: Final = { ("adc", "adc"): BlockSensorDescription( key="adc|adc", name="ADC", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda value: round(value, 2), device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -326,7 +326,7 @@ RPC_SENSORS: Final = { key="switch", sub_key="voltage", name="Voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda status, _: round(float(status), 1), device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -409,7 +409,7 @@ RPC_SENSORS: Final = { key="voltmeter", sub_key="voltage", name="Voltmeter", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda status, _: round(float(status), 2), device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index 7344a3ff8db..9c6e26c26b0 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -11,9 +11,9 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -141,7 +141,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="phase_voltages_a", name="Phase voltages - A", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="phase_voltage_a", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -150,7 +150,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="phase_voltages_b", name="Phase voltages - B", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="phase_voltage_b", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -159,7 +159,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="phase_voltages_c", name="Phase voltages - C", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="phase_voltage_c", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -168,7 +168,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="line_voltages_a", name="Line voltages - A", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="line_voltage_a", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -177,7 +177,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="line_voltages_b", name="Line voltages - B", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="line_voltage_b", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -186,7 +186,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = ( SmappeeVoltageSensorEntityDescription( key="line_voltages_c", name="Line voltages - C", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, sensor_id="line_voltage_c", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index 60c018edf68..919d09d9780 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -17,10 +17,10 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, TEMP_CELSIUS, + UnitOfElectricPotential, UnitOfFrequency, UnitOfPower, ) @@ -58,7 +58,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = { (Units.V, False): SensorEntityDescription( key=f"{Units.V}_{False}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), (Units.A, False): SensorEntityDescription( diff --git a/homeassistant/components/system_bridge/sensor.py b/homeassistant/components/system_bridge/sensor.py index 87edd54ee72..aaa8becfe2f 100644 --- a/homeassistant/components/system_bridge/sensor.py +++ b/homeassistant/components/system_bridge/sensor.py @@ -15,10 +15,10 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_PORT, - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS, + UnitOfElectricPotential, UnitOfFrequency, UnitOfInformation, UnitOfPower, @@ -156,7 +156,7 @@ BASE_SENSOR_TYPES: tuple[SystemBridgeSensorEntityDescription, ...] = ( entity_registry_enabled_default=False, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, value=lambda data: data.cpu.voltage, ), SystemBridgeSensorEntityDescription( diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index 94011ca8ba1..3d66a5bb2c9 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -20,7 +20,6 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, LIGHT_LUX, PERCENTAGE, @@ -34,6 +33,7 @@ from homeassistant.const import ( TEMP_FAHRENHEIT, TEMP_KELVIN, UnitOfApparentPower, + UnitOfElectricPotential, UnitOfFrequency, UnitOfLength, UnitOfMass, @@ -231,7 +231,7 @@ SENSOR_UNIT_MAP = { hc.TEMP_CELSIUS: TEMP_CELSIUS, hc.TEMP_FAHRENHEIT: TEMP_FAHRENHEIT, hc.TEMP_KELVIN: TEMP_KELVIN, - hc.VOLT: ELECTRIC_POTENTIAL_VOLT, + hc.VOLT: UnitOfElectricPotential.VOLT, } diff --git a/homeassistant/components/thermobeacon/sensor.py b/homeassistant/components/thermobeacon/sensor.py index 900aacbf7a7..0faccd6b638 100644 --- a/homeassistant/components/thermobeacon/sensor.py +++ b/homeassistant/components/thermobeacon/sensor.py @@ -23,10 +23,10 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{ThermoBeaconSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), } diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index 0b35034013c..878b162e98f 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -27,11 +27,11 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, EVENT_HOMEASSISTANT_STOP, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import Event, HomeAssistant, callback @@ -141,21 +141,21 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = ( key="voltagePhase1", name="voltage phase1", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="voltagePhase2", name="voltage phase2", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="voltagePhase3", name="voltage phase3", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/homeassistant/components/tplink/sensor.py b/homeassistant/components/tplink/sensor.py index 8fe47f56772..ef072dd02a1 100644 --- a/homeassistant/components/tplink/sensor.py +++ b/homeassistant/components/tplink/sensor.py @@ -16,8 +16,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_VOLTAGE, ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant @@ -72,7 +72,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = ( ), TPLinkSensorEntityDescription( key=ATTR_VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, name="Voltage", diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 3b7a46680f8..abc5519a000 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -16,8 +16,6 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_MILLIAMPERE, - ELECTRIC_POTENTIAL_MILLIVOLT, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, LIGHT_LUX, @@ -35,6 +33,7 @@ from homeassistant.const import ( VOLUME_CUBIC_FEET, VOLUME_CUBIC_METERS, Platform, + UnitOfElectricPotential, UnitOfPower, ) @@ -561,15 +560,15 @@ UNITS = ( device_classes={SensorDeviceClass.TEMPERATURE}, ), UnitOfMeasurement( - unit=ELECTRIC_POTENTIAL_VOLT, + unit=UnitOfElectricPotential.VOLT, aliases={"volt"}, device_classes={SensorDeviceClass.VOLTAGE}, ), UnitOfMeasurement( - unit=ELECTRIC_POTENTIAL_MILLIVOLT, + unit=UnitOfElectricPotential.MILLIVOLT, aliases={"mv", "millivolt"}, device_classes={SensorDeviceClass.VOLTAGE}, - conversion_unit=ELECTRIC_POTENTIAL_VOLT, + conversion_unit=UnitOfElectricPotential.VOLT, conversion_fn=lambda x: x / 1000, ), ) diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 626cb3bbc1b..9dfb28e10fc 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -14,10 +14,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, TIME_MINUTES, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant, callback @@ -683,7 +683,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase A voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), TuyaSensorEntityDescription( @@ -707,7 +707,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase B voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), TuyaSensorEntityDescription( @@ -731,7 +731,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase C voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), ), @@ -765,7 +765,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase A voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), TuyaSensorEntityDescription( @@ -789,7 +789,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase B voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), TuyaSensorEntityDescription( @@ -813,7 +813,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { name="Phase C voltage", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, subkey="voltage", ), ), diff --git a/homeassistant/components/unifiprotect/sensor.py b/homeassistant/components/unifiprotect/sensor.py index aa25daa67bc..cd5cfe612ca 100644 --- a/homeassistant/components/unifiprotect/sensor.py +++ b/homeassistant/components/unifiprotect/sensor.py @@ -26,13 +26,13 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, TIME_SECONDS, UnitOfDataRate, + UnitOfElectricPotential, UnitOfInformation, ) from homeassistant.core import HomeAssistant, callback @@ -192,7 +192,7 @@ CAMERA_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( key="voltage", name="Voltage", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ufp_value="voltage", diff --git a/homeassistant/components/vesync/sensor.py b/homeassistant/components/vesync/sensor.py index 3926e0fbee6..f9736619b65 100644 --- a/homeassistant/components/vesync/sensor.py +++ b/homeassistant/components/vesync/sensor.py @@ -18,9 +18,9 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant, callback @@ -155,7 +155,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = ( key="voltage", name="current voltage", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda device: device.details["voltage"], update_fn=update_energy, diff --git a/homeassistant/components/wirelesstag/__init__.py b/homeassistant/components/wirelesstag/__init__.py index 86dd5f2802b..4e0cae5bfe8 100644 --- a/homeassistant/components/wirelesstag/__init__.py +++ b/homeassistant/components/wirelesstag/__init__.py @@ -12,9 +12,9 @@ from homeassistant.const import ( ATTR_VOLTAGE, CONF_PASSWORD, CONF_USERNAME, - ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -213,7 +213,7 @@ class WirelessTagBaseSensor(Entity): """Return the state attributes.""" return { ATTR_BATTERY_LEVEL: int(self._tag.battery_remaining * 100), - ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{ELECTRIC_POTENTIAL_VOLT}", + ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{UnitOfElectricPotential.VOLT}", ATTR_TAG_SIGNAL_STRENGTH: f"{self._tag.signal_strength}{SIGNAL_STRENGTH_DECIBELS_MILLIWATT}", ATTR_TAG_OUT_OF_RANGE: not self._tag.is_in_range, ATTR_TAG_POWER_CONSUMPTION: f"{self._tag.power_consumption:.2f}{PERCENTAGE}", diff --git a/homeassistant/components/xiaomi_ble/sensor.py b/homeassistant/components/xiaomi_ble/sensor.py index 831b5d0910b..084e5940d9e 100644 --- a/homeassistant/components/xiaomi_ble/sensor.py +++ b/homeassistant/components/xiaomi_ble/sensor.py @@ -21,12 +21,12 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, CONDUCTIVITY, - ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, PRESSURE_MBAR, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, + UnitOfElectricPotential, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -102,7 +102,7 @@ SENSOR_DESCRIPTIONS = { (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, ), diff --git a/homeassistant/components/zwave_js/discovery_data_template.py b/homeassistant/components/zwave_js/discovery_data_template.py index 7e3ca61d057..ed8d73af87b 100644 --- a/homeassistant/components/zwave_js/discovery_data_template.py +++ b/homeassistant/components/zwave_js/discovery_data_template.py @@ -92,8 +92,6 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_MILLION, DEGREE, - ELECTRIC_POTENTIAL_MILLIVOLT, - ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, @@ -102,6 +100,7 @@ from homeassistant.const import ( VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfEnergy, UnitOfFrequency, UnitOfIrradiance, @@ -164,7 +163,7 @@ METER_UNIT_MAP: dict[str, set[MeterScaleType]] = { UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER, UnitOfVolume.GALLONS: UNIT_US_GALLON, UnitOfEnergy.KILO_WATT_HOUR: UNIT_KILOWATT_HOUR, - ELECTRIC_POTENTIAL_VOLT: METER_UNIT_VOLT, + UnitOfElectricPotential.VOLT: METER_UNIT_VOLT, UnitOfPower.WATT: METER_UNIT_WATT, } @@ -195,7 +194,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = { UnitOfLength.METERS: UNIT_METER, UnitOfElectricCurrent.MILLIAMPERE: UNIT_MILLIAMPERE, UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR, - ELECTRIC_POTENTIAL_MILLIVOLT: UNIT_MILLIVOLT, + UnitOfElectricPotential.MILLIVOLT: UNIT_MILLIVOLT, UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH, UnitOfSpeed.METERS_PER_SECOND: UNIT_M_S, CONCENTRATION_PARTS_PER_MILLION: UNIT_PARTS_MILLION, @@ -205,7 +204,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = { SIGNAL_STRENGTH_DECIBELS_MILLIWATT: UNIT_POWER_LEVEL, TIME_SECONDS: UNIT_SECOND, UnitOfPressure.MMHG: UNIT_SYSTOLIC, - ELECTRIC_POTENTIAL_VOLT: SENSOR_UNIT_VOLT, + UnitOfElectricPotential.VOLT: SENSOR_UNIT_VOLT, UnitOfPower.WATT: SENSOR_UNIT_WATT, UnitOfIrradiance.WATTS_PER_SQUARE_METER: UNIT_WATT_PER_SQUARE_METER, } diff --git a/homeassistant/components/zwave_me/sensor.py b/homeassistant/components/zwave_me/sensor.py index 3748ed52516..151b9bb6cda 100644 --- a/homeassistant/components/zwave_me/sensor.py +++ b/homeassistant/components/zwave_me/sensor.py @@ -15,12 +15,12 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, LIGHT_LUX, PERCENTAGE, PRESSURE_KPA, TEMP_CELSIUS, + UnitOfElectricPotential, UnitOfPower, ) from homeassistant.core import HomeAssistant, callback @@ -91,7 +91,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = { "meterElectric_voltage": ZWaveMeSensorEntityDescription( key="meterElectric_voltage", device_class=SensorDeviceClass.VOLTAGE, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, state_class=SensorStateClass.MEASUREMENT, ), "meterElectric_watt": ZWaveMeSensorEntityDescription(