mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Use ApparentPower unit and device class in integrations (#83577)
This commit is contained in:
parent
f5334c5aed
commit
248d5ff541
@ -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,
|
||||
|
@ -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",
|
||||
|
@ -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(
|
||||
|
@ -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,
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
),
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user