From 7c3ca38eb7dcd0918439a4b26b2ce159d4f7ef58 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:51:26 +0100 Subject: [PATCH] Use UnitOfElectricCurrent in integrations (#83622) --- homeassistant/components/broadlink/sensor.py | 6 +++--- homeassistant/components/bthome/sensor.py | 4 ++-- .../components/dsmr_reader/definitions.py | 8 ++++---- homeassistant/components/edl21/sensor.py | 4 ++-- homeassistant/components/fritzbox/sensor.py | 4 ++-- homeassistant/components/fronius/sensor.py | 16 ++++++++-------- homeassistant/components/goalzero/sensor.py | 6 +++--- homeassistant/components/goodwe/sensor.py | 4 ++-- .../growatt_server/sensor_types/inverter.py | 10 +++++----- .../growatt_server/sensor_types/storage.py | 10 +++++----- .../growatt_server/sensor_types/tlx.py | 6 +++--- homeassistant/components/homematic/sensor.py | 4 ++-- homeassistant/components/iotawatt/sensor.py | 4 ++-- homeassistant/components/juicenet/sensor.py | 4 ++-- homeassistant/components/keba/sensor.py | 4 ++-- .../components/kostal_plenticore/sensor.py | 8 ++++---- homeassistant/components/mysensors/sensor.py | 4 ++-- homeassistant/components/nibe_heatpump/sensor.py | 7 +++---- homeassistant/components/oncue/sensor.py | 4 ++-- homeassistant/components/p1_monitor/sensor.py | 8 ++++---- homeassistant/components/powerwall/sensor.py | 4 ++-- homeassistant/components/switcher_kis/sensor.py | 4 ++-- homeassistant/components/tuya/sensor.py | 14 +++++++------- homeassistant/components/wled/sensor.py | 6 +++--- .../zwave_js/discovery_data_template.py | 9 ++++----- 25 files changed, 80 insertions(+), 82 deletions(-) diff --git a/homeassistant/components/broadlink/sensor.py b/homeassistant/components/broadlink/sensor.py index 4d362482e64..e6b50f60fb1 100644 --- a/homeassistant/components/broadlink/sensor.py +++ b/homeassistant/components/broadlink/sensor.py @@ -9,12 +9,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, PERCENTAGE, POWER_WATT, TEMP_CELSIUS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -67,14 +67,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="current", name="Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="overload", name="Overload", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/bthome/sensor.py b/homeassistant/components/bthome/sensor.py index 6493b291085..39389fdd498 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_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TIME_SECONDS, + UnitOfElectricCurrent, UnitOfEnergy, UnitOfLength, UnitOfMass, @@ -217,7 +217,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{BTHomeSensorDeviceClass.CURRENT}_{Units.ELECTRIC_CURRENT_AMPERE}", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), # Used for speed sensor diff --git a/homeassistant/components/dsmr_reader/definitions.py b/homeassistant/components/dsmr_reader/definitions.py index ac61837afec..37a83e41d73 100644 --- a/homeassistant/components/dsmr_reader/definitions.py +++ b/homeassistant/components/dsmr_reader/definitions.py @@ -12,11 +12,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import ( CURRENCY_EURO, - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT, VOLUME_CUBIC_METERS, + UnitOfElectricCurrent, ) from homeassistant.util import dt as dt_util @@ -173,7 +173,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L1", entity_registry_enabled_default=False, device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -181,7 +181,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L2", entity_registry_enabled_default=False, device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -189,7 +189,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L3", entity_registry_enabled_default=False, device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, ), DSMRReaderSensorEntityDescription( diff --git a/homeassistant/components/edl21/sensor.py b/homeassistant/components/edl21/sensor.py index c598827d244..5aee02b21c0 100644 --- a/homeassistant/components/edl21/sensor.py +++ b/homeassistant/components/edl21/sensor.py @@ -18,12 +18,12 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( CONF_NAME, DEGREE, - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, FREQUENCY_HERTZ, POWER_WATT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry as er @@ -258,7 +258,7 @@ SENSOR_UNIT_MAPPING = { "Wh": ENERGY_WATT_HOUR, "kWh": ENERGY_KILO_WATT_HOUR, "W": POWER_WATT, - "A": ELECTRIC_CURRENT_AMPERE, + "A": UnitOfElectricCurrent.AMPERE, "V": ELECTRIC_POTENTIAL_VOLT, "°": DEGREE, "Hz": FREQUENCY_HERTZ, diff --git a/homeassistant/components/fritzbox/sensor.py b/homeassistant/components/fritzbox/sensor.py index 9d68821fdca..6721c0a55fe 100644 --- a/homeassistant/components/fritzbox/sensor.py +++ b/homeassistant/components/fritzbox/sensor.py @@ -17,12 +17,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, PERCENTAGE, POWER_WATT, TEMP_CELSIUS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -149,7 +149,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = ( FritzSensorEntityDescription( key="electric_current", name="Electric Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, 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 8206cdf50a7..40c447745a9 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -11,7 +11,6 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, FREQUENCY_HERTZ, @@ -20,6 +19,7 @@ from homeassistant.const import ( POWER_WATT, TEMP_CELSIUS, UnitOfApparentPower, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -109,14 +109,14 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_ac", name="Current AC", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="current_dc", name="Current DC", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -124,7 +124,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_dc_2", name="Current DC 2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", @@ -215,7 +215,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_ac_phase_1", name="Current AC phase 1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -223,7 +223,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_ac_phase_2", name="Current AC phase 2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -231,7 +231,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_ac_phase_3", name="Current AC phase 3", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, @@ -603,7 +603,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [ SensorEntityDescription( key="current_dc", name="Current DC", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, icon="mdi:current-dc", diff --git a/homeassistant/components/goalzero/sensor.py b/homeassistant/components/goalzero/sensor.py index 2538639883c..4a91ba74fe3 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_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, PERCENTAGE, @@ -20,6 +19,7 @@ from homeassistant.const import ( TEMP_CELSIUS, TIME_MINUTES, TIME_SECONDS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -41,7 +41,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="ampsIn", name="Amps in", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), @@ -56,7 +56,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="ampsOut", name="Amps out", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), diff --git a/homeassistant/components/goodwe/sensor.py b/homeassistant/components/goodwe/sensor.py index 22439a05491..9b9ff0db933 100644 --- a/homeassistant/components/goodwe/sensor.py +++ b/homeassistant/components/goodwe/sensor.py @@ -17,13 +17,13 @@ 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, FREQUENCY_HERTZ, PERCENTAGE, POWER_WATT, TEMP_CELSIUS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -86,7 +86,7 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = { key="A", device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, ), "V": GoodweSensorEntityDescription( key="V", diff --git a/homeassistant/components/growatt_server/sensor_types/inverter.py b/homeassistant/components/growatt_server/sensor_types/inverter.py index eb9315c0777..edb4184283c 100644 --- a/homeassistant/components/growatt_server/sensor_types/inverter.py +++ b/homeassistant/components/growatt_server/sensor_types/inverter.py @@ -3,12 +3,12 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, POWER_WATT, TEMP_CELSIUS, + UnitOfElectricCurrent, ) from .sensor_entity_description import GrowattSensorEntityDescription @@ -43,7 +43,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_amperage_input_1", name="Input 1 Amperage", api_key="ipv1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), @@ -67,7 +67,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_amperage_input_2", name="Input 2 Amperage", api_key="ipv2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), @@ -91,7 +91,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_amperage_input_3", name="Input 3 Amperage", api_key="ipv3", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), @@ -123,7 +123,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="inverter_inverter_reactive_amperage", name="Reactive amperage", api_key="iacr", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), diff --git a/homeassistant/components/growatt_server/sensor_types/storage.py b/homeassistant/components/growatt_server/sensor_types/storage.py index 11e64274686..11c7262cc32 100644 --- a/homeassistant/components/growatt_server/sensor_types/storage.py +++ b/homeassistant/components/growatt_server/sensor_types/storage.py @@ -3,12 +3,12 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, POWER_WATT, + UnitOfElectricCurrent, ) from .sensor_entity_description import GrowattSensorEntityDescription @@ -171,7 +171,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_current_PV", name="Solar charge current", api_key="iAcCharge", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=2, ), @@ -179,7 +179,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_current_1", name="Solar current to storage", api_key="iChargePV1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=2, ), @@ -187,7 +187,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_grid_amperage_input", name="Grid charge current", api_key="chgCurr", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=2, ), @@ -195,7 +195,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="storage_grid_out_current", name="Grid out current", api_key="outPutCurrent", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=2, ), diff --git a/homeassistant/components/growatt_server/sensor_types/tlx.py b/homeassistant/components/growatt_server/sensor_types/tlx.py index ba455747457..c06b0552b40 100644 --- a/homeassistant/components/growatt_server/sensor_types/tlx.py +++ b/homeassistant/components/growatt_server/sensor_types/tlx.py @@ -3,12 +3,12 @@ from __future__ import annotations from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, FREQUENCY_HERTZ, POWER_WATT, TEMP_CELSIUS, + UnitOfElectricCurrent, ) from .sensor_entity_description import GrowattSensorEntityDescription @@ -62,7 +62,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="tlx_amperage_input_1", name="Input 1 Amperage", api_key="ipv1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), @@ -104,7 +104,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = ( key="tlx_amperage_input_2", name="Input 2 Amperage", api_key="ipv2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, precision=1, ), diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index 82d6aeb7cce..38b2b4e73f3 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_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, ENERGY_WATT_HOUR, @@ -26,6 +25,7 @@ from homeassistant.const import ( PRESSURE_HPA, TEMP_CELSIUS, VOLUME_CUBIC_METERS, + UnitOfElectricCurrent, UnitOfPrecipitationDepth, UnitOfSpeed, ) @@ -124,7 +124,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { ), "CURRENT": SensorEntityDescription( key="CURRENT", - native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/iotawatt/sensor.py b/homeassistant/components/iotawatt/sensor.py index 95adbea97e8..63298b361c2 100644 --- a/homeassistant/components/iotawatt/sensor.py +++ b/homeassistant/components/iotawatt/sensor.py @@ -15,13 +15,13 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, FREQUENCY_HERTZ, PERCENTAGE, POWER_WATT, UnitOfApparentPower, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity, entity_registry @@ -53,7 +53,7 @@ class IotaWattSensorEntityDescription(SensorEntityDescription): ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = { "Amps": IotaWattSensorEntityDescription( "Amps", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.CURRENT, entity_registry_enabled_default=False, diff --git a/homeassistant/components/juicenet/sensor.py b/homeassistant/components/juicenet/sensor.py index 7ae7b148552..01fd8154d0b 100644 --- a/homeassistant/components/juicenet/sensor.py +++ b/homeassistant/components/juicenet/sensor.py @@ -9,12 +9,12 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_WATT_HOUR, POWER_WATT, TEMP_CELSIUS, TIME_SECONDS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -43,7 +43,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="amps", name="Amps", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/keba/sensor.py b/homeassistant/components/keba/sensor.py index d35c22905f1..181f60d1766 100644 --- a/homeassistant/components/keba/sensor.py +++ b/homeassistant/components/keba/sensor.py @@ -8,9 +8,9 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -38,7 +38,7 @@ async def async_setup_platform( SensorEntityDescription( key="Curr user", name="Max Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, ), ), diff --git a/homeassistant/components/kostal_plenticore/sensor.py b/homeassistant/components/kostal_plenticore/sensor.py index 29b42e88b50..3431cb6399d 100644 --- a/homeassistant/components/kostal_plenticore/sensor.py +++ b/homeassistant/components/kostal_plenticore/sensor.py @@ -15,11 +15,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, PERCENTAGE, POWER_WATT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -151,7 +151,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv1", key="I", name="DC1 Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, formatter="format_float", @@ -178,7 +178,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv2", key="I", name="DC2 Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, formatter="format_float", @@ -205,7 +205,7 @@ SENSOR_PROCESS_DATA = [ module_id="devices:local:pv3", key="I", name="DC3 Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, formatter="format_float", diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 0339c75d97c..790ccec9090 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -15,7 +15,6 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONDUCTIVITY, DEGREE, - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, @@ -30,6 +29,7 @@ from homeassistant.const import ( VOLUME_CUBIC_METERS, Platform, UnitOfApparentPower, + UnitOfElectricCurrent, UnitOfSoundPressure, ) from homeassistant.core import HomeAssistant @@ -160,7 +160,7 @@ SENSORS: dict[str, SensorEntityDescription] = { ), "V_CURRENT": SensorEntityDescription( key="V_CURRENT", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/nibe_heatpump/sensor.py b/homeassistant/components/nibe_heatpump/sensor.py index c092464b1bf..5f50358912d 100644 --- a/homeassistant/components/nibe_heatpump/sensor.py +++ b/homeassistant/components/nibe_heatpump/sensor.py @@ -12,11 +12,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, - ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_VOLT, TIME_HOURS, + UnitOfElectricCurrent, UnitOfEnergy, UnitOfPower, UnitOfTemperature, @@ -47,14 +46,14 @@ UNIT_DESCRIPTIONS = { entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, ), "mA": SensorEntityDescription( key="mA", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE, ), "V": SensorEntityDescription( key="V", diff --git a/homeassistant/components/oncue/sensor.py b/homeassistant/components/oncue/sensor.py index 84802d67d10..73d3e82886f 100644 --- a/homeassistant/components/oncue/sensor.py +++ b/homeassistant/components/oncue/sensor.py @@ -11,7 +11,6 @@ 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, FREQUENCY_HERTZ, @@ -20,6 +19,7 @@ from homeassistant.const import ( PRESSURE_PSI, TEMP_CELSIUS, TEMP_FAHRENHEIT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -163,7 +163,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="GeneratorCurrentAverage", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, 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 8a1c9d68b5a..c100005e59e 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -14,12 +14,12 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_HOST, CURRENCY_EURO, - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, POWER_WATT, VOLUME_CUBIC_METERS, VOLUME_LITERS, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceEntryType @@ -120,21 +120,21 @@ SENSORS_PHASES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="current_phase_l1", name="Current Phase L1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="current_phase_l2", name="Current Phase L2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="current_phase_l3", name="Current Phase L3", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/powerwall/sensor.py b/homeassistant/components/powerwall/sensor.py index 573dcab6bcc..736ab5b635b 100644 --- a/homeassistant/components/powerwall/sensor.py +++ b/homeassistant/components/powerwall/sensor.py @@ -14,12 +14,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, FREQUENCY_HERTZ, PERCENTAGE, POWER_KILO_WATT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -89,7 +89,7 @@ POWERWALL_INSTANT_SENSORS = ( name="Average Current Now", state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, entity_registry_enabled_default=False, value_fn=_get_meter_total_current, ), diff --git a/homeassistant/components/switcher_kis/sensor.py b/homeassistant/components/switcher_kis/sensor.py index 34a4de3e9d3..33e2fb91a43 100644 --- a/homeassistant/components/switcher_kis/sensor.py +++ b/homeassistant/components/switcher_kis/sensor.py @@ -11,7 +11,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ELECTRIC_CURRENT_AMPERE, POWER_WATT +from homeassistant.const import POWER_WATT, UnitOfElectricCurrent from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -44,7 +44,7 @@ POWER_SENSORS = { ), "electric_current": AttributeDescription( name="Electric Current", - unit=ELECTRIC_CURRENT_AMPERE, + unit=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 6a4dc1b18dc..b675a6b7033 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -14,11 +14,11 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, PERCENTAGE, POWER_KILO_WATT, TIME_MINUTES, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -666,7 +666,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_A, name="Phase A current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), @@ -690,7 +690,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_B, name="Phase B current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), @@ -714,7 +714,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_C, name="Phase C current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), @@ -748,7 +748,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_A, name="Phase A current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), @@ -772,7 +772,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_B, name="Phase B current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), @@ -796,7 +796,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { key=DPCode.PHASE_C, name="Phase C current", device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, state_class=SensorStateClass.MEASUREMENT, subkey="electriccurrent", ), diff --git a/homeassistant/components/wled/sensor.py b/homeassistant/components/wled/sensor.py index 1b5e81ec469..7598a5e0dc4 100644 --- a/homeassistant/components/wled/sensor.py +++ b/homeassistant/components/wled/sensor.py @@ -16,9 +16,9 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DATA_BYTES, - ELECTRIC_CURRENT_MILLIAMPERE, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + UnitOfElectricCurrent, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -51,7 +51,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = ( WLEDSensorEntityDescription( key="estimated_current", name="Estimated current", - native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE, device_class=SensorDeviceClass.CURRENT, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -67,7 +67,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = ( WLEDSensorEntityDescription( key="info_leds_max_power", name="Max current", - native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, + native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE, entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.CURRENT, value_fn=lambda device: device.info.leds.max_power, diff --git a/homeassistant/components/zwave_js/discovery_data_template.py b/homeassistant/components/zwave_js/discovery_data_template.py index 1e2ad1df366..b68cc83199e 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_CURRENT_AMPERE, - ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_VOLT, FREQUENCY_HERTZ, @@ -105,6 +103,7 @@ from homeassistant.const import ( TIME_SECONDS, VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, + UnitOfElectricCurrent, UnitOfEnergy, UnitOfIrradiance, UnitOfLength, @@ -161,7 +160,7 @@ MULTILEVEL_SENSOR_DEVICE_CLASS_MAP: dict[str, set[MultilevelSensorType]] = { } METER_UNIT_MAP: dict[str, set[MeterScaleType]] = { - ELECTRIC_CURRENT_AMPERE: METER_UNIT_AMPERE, + UnitOfElectricCurrent.AMPERE: METER_UNIT_AMPERE, UnitOfVolume.CUBIC_FEET: UNIT_CUBIC_FEET, UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER, UnitOfVolume.GALLONS: UNIT_US_GALLON, @@ -171,7 +170,7 @@ METER_UNIT_MAP: dict[str, set[MeterScaleType]] = { } MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = { - ELECTRIC_CURRENT_AMPERE: SENSOR_UNIT_AMPERE, + UnitOfElectricCurrent.AMPERE: SENSOR_UNIT_AMPERE, UnitOfPower.BTU_PER_HOUR: UNIT_BTU_H, UnitOfTemperature.CELSIUS: UNIT_CELSIUS, UnitOfLength.CENTIMETERS: UNIT_CENTIMETER, @@ -195,7 +194,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = { UnitOfVolume.LITERS: UNIT_LITER, LIGHT_LUX: UNIT_LUX, UnitOfLength.METERS: UNIT_METER, - ELECTRIC_CURRENT_MILLIAMPERE: UNIT_MILLIAMPERE, + UnitOfElectricCurrent.MILLIAMPERE: UNIT_MILLIAMPERE, UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR, ELECTRIC_POTENTIAL_MILLIVOLT: UNIT_MILLIVOLT, UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH,