diff --git a/homeassistant/components/apcupsd/sensor.py b/homeassistant/components/apcupsd/sensor.py index b55f672264d..3e3326c7bde 100644 --- a/homeassistant/components/apcupsd/sensor.py +++ b/homeassistant/components/apcupsd/sensor.py @@ -21,11 +21,11 @@ from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, FREQUENCY_HERTZ, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, TEMP_CELSIUS, TIME_MINUTES, TIME_SECONDS, + UnitOfApparentPower, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -290,8 +290,8 @@ SENSORS: dict[str, SensorEntityDescription] = { "nomapnt": SensorEntityDescription( key="nomapnt", name="UPS Nominal Apparent Power", - native_unit_of_measurement=POWER_VOLT_AMPERE, - icon="mdi:flash", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, ), "numxfers": SensorEntityDescription( key="numxfers", @@ -423,7 +423,7 @@ INFERRED_UNITS = { " Percent": PERCENTAGE, " Volts": ELECTRIC_POTENTIAL_VOLT, " Ampere": ELECTRIC_CURRENT_AMPERE, - " Volt-Ampere": POWER_VOLT_AMPERE, + " Volt-Ampere": UnitOfApparentPower.VOLT_AMPERE, " Watts": POWER_WATT, " Hz": FREQUENCY_HERTZ, " C": TEMP_CELSIUS, diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index 35881225b68..8206cdf50a7 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -16,10 +16,10 @@ from homeassistant.const import ( ENERGY_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_VOLT_AMPERE_REACTIVE, POWER_WATT, TEMP_CELSIUS, + UnitOfApparentPower, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -297,7 +297,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="power_apparent_phase_1", name="Power apparent phase 1", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, device_class=SensorDeviceClass.APPARENT_POWER, state_class=SensorStateClass.MEASUREMENT, icon="mdi:flash-outline", @@ -306,7 +306,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="power_apparent_phase_2", name="Power apparent phase 2", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, device_class=SensorDeviceClass.APPARENT_POWER, state_class=SensorStateClass.MEASUREMENT, icon="mdi:flash-outline", @@ -315,7 +315,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="power_apparent_phase_3", name="Power apparent phase 3", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, device_class=SensorDeviceClass.APPARENT_POWER, state_class=SensorStateClass.MEASUREMENT, icon="mdi:flash-outline", @@ -324,7 +324,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="power_apparent", name="Power apparent", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, device_class=SensorDeviceClass.APPARENT_POWER, state_class=SensorStateClass.MEASUREMENT, icon="mdi:flash-outline", diff --git a/homeassistant/components/iotawatt/sensor.py b/homeassistant/components/iotawatt/sensor.py index dd04a32cce4..95adbea97e8 100644 --- a/homeassistant/components/iotawatt/sensor.py +++ b/homeassistant/components/iotawatt/sensor.py @@ -20,8 +20,8 @@ from homeassistant.const import ( ENERGY_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, + UnitOfApparentPower, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity, entity_registry @@ -87,9 +87,9 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = { ), "VA": IotaWattSensorEntityDescription( "VA", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, state_class=SensorStateClass.MEASUREMENT, - icon="mdi:flash", + device_class=SensorDeviceClass.APPARENT_POWER, entity_registry_enabled_default=False, ), "VAR": IotaWattSensorEntityDescription( diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 5bafed04353..3c190422bfb 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -24,13 +24,13 @@ from homeassistant.const import ( LIGHT_LUX, MASS_KILOGRAMS, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, SOUND_PRESSURE_DB, TEMP_CELSIUS, TEMP_FAHRENHEIT, VOLUME_CUBIC_METERS, Platform, + UnitOfApparentPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -182,7 +182,8 @@ SENSORS: dict[str, SensorEntityDescription] = { ), "V_VA": SensorEntityDescription( key="V_VA", - native_unit_of_measurement=POWER_VOLT_AMPERE, + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, ), } diff --git a/homeassistant/components/nut/const.py b/homeassistant/components/nut/const.py index a8591349b56..97bc0347077 100644 --- a/homeassistant/components/nut/const.py +++ b/homeassistant/components/nut/const.py @@ -14,11 +14,11 @@ from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, FREQUENCY_HERTZ, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, TEMP_CELSIUS, TIME_SECONDS, Platform, + UnitOfApparentPower, ) from homeassistant.helpers.entity import EntityCategory @@ -182,8 +182,8 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = { "ups.power": SensorEntityDescription( key="ups.power", name="Current Apparent Power", - native_unit_of_measurement=POWER_VOLT_AMPERE, - icon="mdi:flash", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, @@ -191,8 +191,8 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = { "ups.power.nominal": SensorEntityDescription( key="ups.power.nominal", name="Nominal Power", - native_unit_of_measurement=POWER_VOLT_AMPERE, - icon="mdi:flash", + native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE, + device_class=SensorDeviceClass.APPARENT_POWER, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, ), diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index 1db2eb4dba6..b505a52f78e 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -27,7 +27,6 @@ from homeassistant.const import ( LIGHT_LUX, MASS_KILOGRAMS, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, PRESSURE_HPA, SIGNAL_STRENGTH_DECIBELS, @@ -38,6 +37,7 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, TEMP_KELVIN, + UnitOfApparentPower, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -214,7 +214,7 @@ SENSOR_UNIT_MAP = { 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_VOLT_AMPERE: POWER_VOLT_AMPERE, + hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE, hc.ENERGY_KILO_WATT_HOUR: ENERGY_KILO_WATT_HOUR, hc.FREQUENCY_HERTZ: FREQUENCY_HERTZ, hc.LENGTH_CENTIMETERS: LENGTH_CENTIMETERS, diff --git a/homeassistant/components/zha/sensor.py b/homeassistant/components/zha/sensor.py index 003f5771b93..117cac9f293 100644 --- a/homeassistant/components/zha/sensor.py +++ b/homeassistant/components/zha/sensor.py @@ -24,7 +24,6 @@ from homeassistant.const import ( FREQUENCY_HERTZ, LIGHT_LUX, PERCENTAGE, - POWER_VOLT_AMPERE, POWER_WATT, PRESSURE_HPA, TEMP_CELSIUS, @@ -38,6 +37,7 @@ from homeassistant.const import ( VOLUME_GALLONS, VOLUME_LITERS, Platform, + UnitOfApparentPower, UnitOfMass, ) from homeassistant.core import HomeAssistant, callback @@ -315,7 +315,7 @@ class ElectricalMeasurementApparentPower( _attr_device_class: SensorDeviceClass = SensorDeviceClass.APPARENT_POWER _attr_should_poll = False # Poll indirectly by ElectricalMeasurementSensor _attr_name: str = "Apparent power" - _unit = POWER_VOLT_AMPERE + _unit = UnitOfApparentPower.VOLT_AMPERE _div_mul_prefix = "ac_power"