diff --git a/homeassistant/components/hive/sensor.py b/homeassistant/components/hive/sensor.py index 0cc222c27c3..ed742e4bdad 100644 --- a/homeassistant/components/hive/sensor.py +++ b/homeassistant/components/hive/sensor.py @@ -8,7 +8,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import PERCENTAGE, POWER_WATT +from homeassistant.const import PERCENTAGE, UnitOfPower from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -28,7 +28,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.POWER, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index 33320a7660e..edb3c1bfb6b 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -28,11 +28,11 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, LIGHT_LUX, PERCENTAGE, - POWER_WATT, PRESSURE_HPA, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_CELSIUS, Platform, + UnitOfPower, UnitOfSoundPressure, ) from homeassistant.core import HomeAssistant, callback @@ -146,7 +146,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Power", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS, @@ -174,7 +174,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Power", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), CharacteristicsTypes.VENDOR_EVE_ENERGY_KW_HOUR: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_EVE_ENERGY_KW_HOUR, @@ -202,14 +202,14 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Power", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY_2: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY_2, name="Power", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), CharacteristicsTypes.VENDOR_EVE_DEGREE_AIR_PRESSURE: HomeKitSensorEntityDescription( key=CharacteristicsTypes.VENDOR_EVE_DEGREE_AIR_PRESSURE, @@ -223,7 +223,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { name="Power", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), CharacteristicsTypes.TEMPERATURE_CURRENT: HomeKitSensorEntityDescription( key=CharacteristicsTypes.TEMPERATURE_CURRENT, diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index 24045c5e158..be5722fc9a7 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -21,10 +21,10 @@ from homeassistant.const import ( FREQUENCY_HERTZ, LIGHT_LUX, PERCENTAGE, - POWER_WATT, PRESSURE_HPA, TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfPower, UnitOfPrecipitationDepth, UnitOfSpeed, UnitOfVolume, @@ -112,13 +112,13 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { ), "POWER": SensorEntityDescription( key="POWER", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), "IEC_POWER": SensorEntityDescription( key="IEC_POWER", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index 68b1f4588a8..8d1b6c9d458 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -14,7 +14,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, PERCENTAGE, - POWER_WATT, + UnitOfPower, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -87,28 +87,28 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( SensorEntityDescription( key="active_power_w", name="Active power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="active_power_l1_w", name="Active power L1", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="active_power_l2_w", name="Active power L2", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="active_power_l3_w", name="Active power L3", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/iotawatt/sensor.py b/homeassistant/components/iotawatt/sensor.py index 63298b361c2..2fe15359afa 100644 --- a/homeassistant/components/iotawatt/sensor.py +++ b/homeassistant/components/iotawatt/sensor.py @@ -19,9 +19,9 @@ from homeassistant.const import ( ENERGY_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, - POWER_WATT, UnitOfApparentPower, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity, entity_registry @@ -75,7 +75,7 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = { ), "Watts": IotaWattSensorEntityDescription( "Watts", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.POWER, ), diff --git a/homeassistant/components/juicenet/sensor.py b/homeassistant/components/juicenet/sensor.py index 01fd8154d0b..404f547c207 100644 --- a/homeassistant/components/juicenet/sensor.py +++ b/homeassistant/components/juicenet/sensor.py @@ -11,10 +11,10 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, - POWER_WATT, TEMP_CELSIUS, TIME_SECONDS, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -50,7 +50,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="watts", name="Watts", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/keba/sensor.py b/homeassistant/components/keba/sensor.py index 181f60d1766..1c5b0f76991 100644 --- a/homeassistant/components/keba/sensor.py +++ b/homeassistant/components/keba/sensor.py @@ -9,8 +9,8 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, - POWER_KILO_WATT, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -58,7 +58,7 @@ async def async_setup_platform( SensorEntityDescription( key="P", name="Charging Power", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/kostal_plenticore/number.py b/homeassistant/components/kostal_plenticore/number.py index e8878deb48d..464d528e4d2 100644 --- a/homeassistant/components/kostal_plenticore/number.py +++ b/homeassistant/components/kostal_plenticore/number.py @@ -15,7 +15,7 @@ from homeassistant.components.number import ( NumberMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import PERCENTAGE, POWER_WATT +from homeassistant.const import PERCENTAGE, UnitOfPower from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -66,7 +66,7 @@ NUMBER_SETTINGS_DATA = [ entity_category=EntityCategory.CONFIG, entity_registry_enabled_default=False, name="Battery min Home Consumption", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, native_max_value=38000, native_min_value=50, native_step=1, diff --git a/homeassistant/components/kostal_plenticore/sensor.py b/homeassistant/components/kostal_plenticore/sensor.py index 3431cb6399d..421b9e6e8ba 100644 --- a/homeassistant/components/kostal_plenticore/sensor.py +++ b/homeassistant/components/kostal_plenticore/sensor.py @@ -18,8 +18,8 @@ from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, PERCENTAGE, - POWER_WATT, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -59,7 +59,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="Dc_P", name="Solar Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=True, state_class=SensorStateClass.MEASUREMENT, @@ -69,7 +69,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="Grid_P", name="Grid Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=True, state_class=SensorStateClass.MEASUREMENT, @@ -79,7 +79,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="HomeBat_P", name="Home Power from Battery", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, formatter="format_round", ), @@ -87,7 +87,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="HomeGrid_P", name="Home Power from Grid", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -96,7 +96,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="HomeOwn_P", name="Home Power from Own", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -105,7 +105,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="HomePv_P", name="Home Power from PV", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -114,7 +114,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="Home_P", name="Home Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -123,7 +123,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:ac", key="P", name="AC Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, entity_registry_enabled_default=True, state_class=SensorStateClass.MEASUREMENT, @@ -133,7 +133,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv1", key="P", name="DC1 Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -160,7 +160,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv2", key="P", name="DC2 Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -187,7 +187,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv3", key="P", name="DC3 Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -214,7 +214,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local", key="PV2Bat_P", name="PV to Battery Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", @@ -238,7 +238,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:battery", key="P", name="Battery Power", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, formatter="format_round", diff --git a/homeassistant/components/landisgyr_heat_meter/const.py b/homeassistant/components/landisgyr_heat_meter/const.py index 7767a491f3b..4956539eceb 100644 --- a/homeassistant/components/landisgyr_heat_meter/const.py +++ b/homeassistant/components/landisgyr_heat_meter/const.py @@ -7,12 +7,12 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import ( ENERGY_MEGA_WATT_HOUR, - POWER_KILO_WATT, TEMP_CELSIUS, TIME_HOURS, TIME_MINUTES, VOLUME_CUBIC_METERS, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, + UnitOfPower, ) from homeassistant.helpers.entity import EntityCategory @@ -97,14 +97,14 @@ HEAT_METER_SENSOR_TYPES = ( SensorEntityDescription( key="power_max_kw", name="Power max", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, device_class=SensorDeviceClass.POWER, entity_category=EntityCategory.DIAGNOSTIC, ), SensorEntityDescription( key="power_max_previous_year_kw", name="Power max previous year", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, device_class=SensorDeviceClass.POWER, entity_category=EntityCategory.DIAGNOSTIC, ), diff --git a/homeassistant/components/mill/sensor.py b/homeassistant/components/mill/sensor.py index 2ed30315083..054e4e3f758 100644 --- a/homeassistant/components/mill/sensor.py +++ b/homeassistant/components/mill/sensor.py @@ -17,8 +17,8 @@ from homeassistant.const import ( CONF_USERNAME, ENERGY_KILO_WATT_HOUR, PERCENTAGE, - POWER_WATT, TEMP_CELSIUS, + UnitOfPower, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC @@ -105,7 +105,7 @@ LOCAL_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="current_power", device_class=SensorDeviceClass.POWER, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, name="Current power", state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/neurio_energy/sensor.py b/homeassistant/components/neurio_energy/sensor.py index a1f6791fa5a..7583e1f90f9 100644 --- a/homeassistant/components/neurio_energy/sensor.py +++ b/homeassistant/components/neurio_energy/sensor.py @@ -14,7 +14,7 @@ from homeassistant.components.sensor import ( SensorEntity, SensorStateClass, ) -from homeassistant.const import CONF_API_KEY, ENERGY_KILO_WATT_HOUR, POWER_WATT +from homeassistant.const import CONF_API_KEY, ENERGY_KILO_WATT_HOUR, UnitOfPower from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -149,7 +149,7 @@ class NeurioEnergy(SensorEntity): self._state = None if sensor_type == ACTIVE_TYPE: - self._unit_of_measurement = POWER_WATT + self._unit_of_measurement = UnitOfPower.WATT self._attr_device_class = SensorDeviceClass.POWER self._attr_state_class = SensorStateClass.MEASUREMENT elif sensor_type == DAILY_TYPE: diff --git a/homeassistant/components/oncue/sensor.py b/homeassistant/components/oncue/sensor.py index 73d3e82886f..55023f2f637 100644 --- a/homeassistant/components/oncue/sensor.py +++ b/homeassistant/components/oncue/sensor.py @@ -15,11 +15,11 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, - POWER_WATT, PRESSURE_PSI, TEMP_CELSIUS, TEMP_FAHRENHEIT, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -85,7 +85,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="GeneratorTrueTotalPower", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index 108978b8521..c069aea5630 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -16,8 +16,8 @@ from homeassistant.const import ( CURRENCY_EURO, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, - POWER_WATT, UnitOfElectricCurrent, + UnitOfPower, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -48,7 +48,7 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="power_consumption", name="Power Consumption", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), @@ -69,7 +69,7 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="power_production", name="Power Production", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), @@ -140,42 +140,42 @@ SENSORS_PHASES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="power_consumed_phase_l1", name="Power Consumed Phase L1", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="power_consumed_phase_l2", name="Power Consumed Phase L2", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="power_consumed_phase_l3", name="Power Consumed Phase L3", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="power_produced_phase_l1", name="Power Produced Phase L1", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="power_produced_phase_l2", name="Power Produced Phase L2", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="power_produced_phase_l3", name="Power Produced Phase L3", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index 19b98085dcd..7c0fa8f0a4f 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -12,9 +12,9 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, PERCENTAGE, - POWER_WATT, PRESSURE_BAR, TEMP_CELSIUS, + UnitOfPower, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -108,14 +108,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="electricity_consumed", name="Electricity consumed", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="electricity_produced", name="Electricity produced", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -166,14 +166,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="electricity_consumed_off_peak_point", name="Electricity consumed off peak point", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="electricity_consumed_peak_point", name="Electricity consumed peak point", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), @@ -194,14 +194,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="electricity_produced_off_peak_point", name="Electricity produced off peak point", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="electricity_produced_peak_point", name="Electricity produced peak point", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), @@ -236,7 +236,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="net_electricity_point", name="Net electricity point", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/powerwall/sensor.py b/homeassistant/components/powerwall/sensor.py index 736ab5b635b..fd1fc68f5eb 100644 --- a/homeassistant/components/powerwall/sensor.py +++ b/homeassistant/components/powerwall/sensor.py @@ -18,8 +18,8 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, - POWER_KILO_WATT, UnitOfElectricCurrent, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -72,7 +72,7 @@ POWERWALL_INSTANT_SENSORS = ( name="Now", state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.POWER, - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, value_fn=_get_meter_power, ), PowerwallSensorEntityDescription( diff --git a/homeassistant/components/pure_energie/sensor.py b/homeassistant/components/pure_energie/sensor.py index 8b07a2818f8..8e092183f94 100644 --- a/homeassistant/components/pure_energie/sensor.py +++ b/homeassistant/components/pure_energie/sensor.py @@ -12,7 +12,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, ENERGY_KILO_WATT_HOUR, POWER_WATT +from homeassistant.const import CONF_HOST, ENERGY_KILO_WATT_HOUR, UnitOfPower from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -40,7 +40,7 @@ SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = ( PureEnergieSensorEntityDescription( key="power_flow", name="Power Flow", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.smartbridge.power_flow, diff --git a/homeassistant/components/pvoutput/sensor.py b/homeassistant/components/pvoutput/sensor.py index a0afee0f3eb..a42c83b587e 100644 --- a/homeassistant/components/pvoutput/sensor.py +++ b/homeassistant/components/pvoutput/sensor.py @@ -17,9 +17,8 @@ from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, - POWER_KILO_WATT, - POWER_WATT, TEMP_CELSIUS, + UnitOfPower, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -64,14 +63,14 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = ( PVOutputSensorEntityDescription( key="normalized_output", name="Efficiency", - native_unit_of_measurement=f"{ENERGY_KILO_WATT_HOUR}/{POWER_KILO_WATT}", + native_unit_of_measurement=f"{ENERGY_KILO_WATT_HOUR}/{UnitOfPower.KILO_WATT}", state_class=SensorStateClass.MEASUREMENT, value_fn=lambda status: status.normalized_output, ), PVOutputSensorEntityDescription( key="power_consumption", name="Power consumed", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda status: status.power_consumption, @@ -79,7 +78,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = ( PVOutputSensorEntityDescription( key="power_generation", name="Power generated", - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda status: status.power_generation, diff --git a/homeassistant/components/rainforest_eagle/sensor.py b/homeassistant/components/rainforest_eagle/sensor.py index a2c336bc5d0..c2b7cab9d47 100644 --- a/homeassistant/components/rainforest_eagle/sensor.py +++ b/homeassistant/components/rainforest_eagle/sensor.py @@ -8,7 +8,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT +from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -23,7 +23,7 @@ SENSORS = ( key="zigbee:InstantaneousDemand", # We can drop the "Eagle-200" part of the name in HA 2021.12 name="Eagle-200 Meter Power Demand", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/renault/sensor.py b/homeassistant/components/renault/sensor.py index c12587078bd..251db26e889 100644 --- a/homeassistant/components/renault/sensor.py +++ b/homeassistant/components/renault/sensor.py @@ -26,9 +26,9 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, LENGTH_KILOMETERS, PERCENTAGE, - POWER_KILO_WATT, TEMP_CELSIUS, TIME_MINUTES, + UnitOfPower, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -209,7 +209,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = ( device_class=SensorDeviceClass.POWER, entity_class=RenaultSensor[KamereonVehicleBatteryStatusData], name="Admissible charging power", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, state_class=SensorStateClass.MEASUREMENT, ), RenaultSensorEntityDescription( @@ -222,7 +222,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = ( device_class=SensorDeviceClass.POWER, entity_class=RenaultSensor[KamereonVehicleBatteryStatusData], name="Charging power", - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, state_class=SensorStateClass.MEASUREMENT, value_lambda=_get_charging_power, ),