Use UnitOfElectricCurrent in integrations (#83622)

This commit is contained in:
epenet 2022-12-09 10:51:26 +01:00 committed by GitHub
parent cc132bfad6
commit 7c3ca38eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 80 additions and 82 deletions

View File

@ -9,12 +9,12 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -67,14 +67,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="current", key="current",
name="Current", name="Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="overload", key="overload",
name="Overload", name="Overload",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -22,12 +22,12 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent,
UnitOfEnergy, UnitOfEnergy,
UnitOfLength, UnitOfLength,
UnitOfMass, UnitOfMass,
@ -217,7 +217,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription( ): SensorEntityDescription(
key=f"{BTHomeSensorDeviceClass.CURRENT}_{Units.ELECTRIC_CURRENT_AMPERE}", key=f"{BTHomeSensorDeviceClass.CURRENT}_{Units.ELECTRIC_CURRENT_AMPERE}",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
# Used for speed sensor # Used for speed sensor

View File

@ -12,11 +12,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.const import ( from homeassistant.const import (
CURRENCY_EURO, CURRENCY_EURO,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
POWER_KILO_WATT, POWER_KILO_WATT,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
UnitOfElectricCurrent,
) )
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -173,7 +173,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Phase power current L1", name="Phase power current L1",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -181,7 +181,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Phase power current L2", name="Phase power current L2",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -189,7 +189,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Phase power current L3", name="Phase power current L3",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(

View File

@ -18,12 +18,12 @@ from homeassistant.components.sensor import (
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT, POWER_WATT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_registry as er from homeassistant.helpers import config_validation as cv, entity_registry as er
@ -258,7 +258,7 @@ SENSOR_UNIT_MAPPING = {
"Wh": ENERGY_WATT_HOUR, "Wh": ENERGY_WATT_HOUR,
"kWh": ENERGY_KILO_WATT_HOUR, "kWh": ENERGY_KILO_WATT_HOUR,
"W": POWER_WATT, "W": POWER_WATT,
"A": ELECTRIC_CURRENT_AMPERE, "A": UnitOfElectricCurrent.AMPERE,
"V": ELECTRIC_POTENTIAL_VOLT, "V": ELECTRIC_POTENTIAL_VOLT,
"°": DEGREE, "°": DEGREE,
"Hz": FREQUENCY_HERTZ, "Hz": FREQUENCY_HERTZ,

View File

@ -17,12 +17,12 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -149,7 +149,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
FritzSensorEntityDescription( FritzSensorEntityDescription(
key="electric_current", key="electric_current",
name="Electric Current", name="Electric Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return] suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]

View File

@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
@ -20,6 +19,7 @@ from homeassistant.const import (
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
@ -109,14 +109,14 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_ac", key="current_ac",
name="Current AC", name="Current AC",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="current_dc", key="current_dc",
name="Current DC", name="Current DC",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -124,7 +124,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_dc_2", key="current_dc_2",
name="Current DC 2", name="Current DC 2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -215,7 +215,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_ac_phase_1", key="current_ac_phase_1",
name="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, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -223,7 +223,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_ac_phase_2", key="current_ac_phase_2",
name="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, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -231,7 +231,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_ac_phase_3", key="current_ac_phase_3",
name="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, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -603,7 +603,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="current_dc", key="current_dc",
name="Current DC", name="Current DC",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",

View File

@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
@ -20,6 +19,7 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_MINUTES, TIME_MINUTES,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -41,7 +41,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="ampsIn", key="ampsIn",
name="Amps in", name="Amps in",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -56,7 +56,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="ampsOut", key="ampsOut",
name="Amps out", name="Amps out",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),

View File

@ -17,13 +17,13 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
@ -86,7 +86,7 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = {
key="A", key="A",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
), ),
"V": GoodweSensorEntityDescription( "V": GoodweSensorEntityDescription(
key="V", key="V",

View File

@ -3,12 +3,12 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -43,7 +43,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_amperage_input_1", key="inverter_amperage_input_1",
name="Input 1 Amperage", name="Input 1 Amperage",
api_key="ipv1", api_key="ipv1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
@ -67,7 +67,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_amperage_input_2", key="inverter_amperage_input_2",
name="Input 2 Amperage", name="Input 2 Amperage",
api_key="ipv2", api_key="ipv2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
@ -91,7 +91,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_amperage_input_3", key="inverter_amperage_input_3",
name="Input 3 Amperage", name="Input 3 Amperage",
api_key="ipv3", api_key="ipv3",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
@ -123,7 +123,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_inverter_reactive_amperage", key="inverter_inverter_reactive_amperage",
name="Reactive amperage", name="Reactive amperage",
api_key="iacr", api_key="iacr",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),

View File

@ -3,12 +3,12 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
UnitOfElectricCurrent,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -171,7 +171,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_current_PV", key="storage_current_PV",
name="Solar charge current", name="Solar charge current",
api_key="iAcCharge", api_key="iAcCharge",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
@ -179,7 +179,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_current_1", key="storage_current_1",
name="Solar current to storage", name="Solar current to storage",
api_key="iChargePV1", api_key="iChargePV1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
@ -187,7 +187,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_grid_amperage_input", key="storage_grid_amperage_input",
name="Grid charge current", name="Grid charge current",
api_key="chgCurr", api_key="chgCurr",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
@ -195,7 +195,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_grid_out_current", key="storage_grid_out_current",
name="Grid out current", name="Grid out current",
api_key="outPutCurrent", api_key="outPutCurrent",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),

View File

@ -3,12 +3,12 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -62,7 +62,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_amperage_input_1", key="tlx_amperage_input_1",
name="Input 1 Amperage", name="Input 1 Amperage",
api_key="ipv1", api_key="ipv1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
@ -104,7 +104,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_amperage_input_2", key="tlx_amperage_input_2",
name="Input 2 Amperage", name="Input 2 Amperage",
api_key="ipv2", api_key="ipv2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),

View File

@ -15,7 +15,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_CURRENT_MILLIAMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
@ -26,6 +25,7 @@ from homeassistant.const import (
PRESSURE_HPA, PRESSURE_HPA,
TEMP_CELSIUS, TEMP_CELSIUS,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
UnitOfElectricCurrent,
UnitOfPrecipitationDepth, UnitOfPrecipitationDepth,
UnitOfSpeed, UnitOfSpeed,
) )
@ -124,7 +124,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
), ),
"CURRENT": SensorEntityDescription( "CURRENT": SensorEntityDescription(
key="CURRENT", key="CURRENT",
native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -15,13 +15,13 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity, entity_registry from homeassistant.helpers import entity, entity_registry
@ -53,7 +53,7 @@ class IotaWattSensorEntityDescription(SensorEntityDescription):
ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = { ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = {
"Amps": IotaWattSensorEntityDescription( "Amps": IotaWattSensorEntityDescription(
"Amps", "Amps",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,

View File

@ -9,12 +9,12 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -43,7 +43,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="amps", key="amps",
name="Amps", name="Amps",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -8,9 +8,9 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
POWER_KILO_WATT, POWER_KILO_WATT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -38,7 +38,7 @@ async def async_setup_platform(
SensorEntityDescription( SensorEntityDescription(
key="Curr user", key="Curr user",
name="Max Current", name="Max Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
), ),
), ),

View File

@ -15,11 +15,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -151,7 +151,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv1", module_id="devices:local:pv1",
key="I", key="I",
name="DC1 Current", name="DC1 Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_float", formatter="format_float",
@ -178,7 +178,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv2", module_id="devices:local:pv2",
key="I", key="I",
name="DC2 Current", name="DC2 Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_float", formatter="format_float",
@ -205,7 +205,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv3", module_id="devices:local:pv3",
key="I", key="I",
name="DC3 Current", name="DC3 Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_float", formatter="format_float",

View File

@ -15,7 +15,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONDUCTIVITY, CONDUCTIVITY,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
@ -30,6 +29,7 @@ from homeassistant.const import (
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
Platform, Platform,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent,
UnitOfSoundPressure, UnitOfSoundPressure,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -160,7 +160,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
), ),
"V_CURRENT": SensorEntityDescription( "V_CURRENT": SensorEntityDescription(
key="V_CURRENT", key="V_CURRENT",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -12,11 +12,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_CURRENT_MILLIAMPERE,
ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
TIME_HOURS, TIME_HOURS,
UnitOfElectricCurrent,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
UnitOfTemperature, UnitOfTemperature,
@ -47,14 +46,14 @@ UNIT_DESCRIPTIONS = {
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
), ),
"mA": SensorEntityDescription( "mA": SensorEntityDescription(
key="mA", key="mA",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
), ),
"V": SensorEntityDescription( "V": SensorEntityDescription(
key="V", key="V",

View File

@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
@ -20,6 +19,7 @@ from homeassistant.const import (
PRESSURE_PSI, PRESSURE_PSI,
TEMP_CELSIUS, TEMP_CELSIUS,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -163,7 +163,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key="GeneratorCurrentAverage", key="GeneratorCurrentAverage",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,

View File

@ -14,12 +14,12 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CURRENCY_EURO, CURRENCY_EURO,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
POWER_WATT, POWER_WATT,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
VOLUME_LITERS, VOLUME_LITERS,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.device_registry import DeviceEntryType
@ -120,21 +120,21 @@ SENSORS_PHASES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="current_phase_l1", key="current_phase_l1",
name="Current Phase L1", name="Current Phase L1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="current_phase_l2", key="current_phase_l2",
name="Current Phase L2", name="Current Phase L2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="current_phase_l3", key="current_phase_l3",
name="Current Phase L3", name="Current Phase L3",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -14,12 +14,12 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_KILO_WATT, POWER_KILO_WATT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -89,7 +89,7 @@ POWERWALL_INSTANT_SENSORS = (
name="Average Current Now", name="Average Current Now",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
value_fn=_get_meter_total_current, value_fn=_get_meter_total_current,
), ),

View File

@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant, callback
from homeassistant.helpers import device_registry from homeassistant.helpers import device_registry
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -44,7 +44,7 @@ POWER_SENSORS = {
), ),
"electric_current": AttributeDescription( "electric_current": AttributeDescription(
name="Electric Current", name="Electric Current",
unit=ELECTRIC_CURRENT_AMPERE, unit=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -14,11 +14,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
POWER_KILO_WATT, POWER_KILO_WATT,
TIME_MINUTES, TIME_MINUTES,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -666,7 +666,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_A, key=DPCode.PHASE_A,
name="Phase A current", name="Phase A current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),
@ -690,7 +690,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_B, key=DPCode.PHASE_B,
name="Phase B current", name="Phase B current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),
@ -714,7 +714,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_C, key=DPCode.PHASE_C,
name="Phase C current", name="Phase C current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),
@ -748,7 +748,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_A, key=DPCode.PHASE_A,
name="Phase A current", name="Phase A current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),
@ -772,7 +772,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_B, key=DPCode.PHASE_B,
name="Phase B current", name="Phase B current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),
@ -796,7 +796,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
key=DPCode.PHASE_C, key=DPCode.PHASE_C,
name="Phase C current", name="Phase C current",
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey="electriccurrent", subkey="electriccurrent",
), ),

View File

@ -16,9 +16,9 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
DATA_BYTES, DATA_BYTES,
ELECTRIC_CURRENT_MILLIAMPERE,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfElectricCurrent,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -51,7 +51,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
WLEDSensorEntityDescription( WLEDSensorEntityDescription(
key="estimated_current", key="estimated_current",
name="Estimated current", name="Estimated current",
native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
@ -67,7 +67,7 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
WLEDSensorEntityDescription( WLEDSensorEntityDescription(
key="info_leds_max_power", key="info_leds_max_power",
name="Max current", name="Max current",
native_unit_of_measurement=ELECTRIC_CURRENT_MILLIAMPERE, native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
value_fn=lambda device: device.info.leds.max_power, value_fn=lambda device: device.info.leds.max_power,

View File

@ -92,8 +92,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_CURRENT_MILLIAMPERE,
ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
@ -105,6 +103,7 @@ from homeassistant.const import (
TIME_SECONDS, TIME_SECONDS,
VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE, VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE,
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
UnitOfElectricCurrent,
UnitOfEnergy, UnitOfEnergy,
UnitOfIrradiance, UnitOfIrradiance,
UnitOfLength, UnitOfLength,
@ -161,7 +160,7 @@ MULTILEVEL_SENSOR_DEVICE_CLASS_MAP: dict[str, set[MultilevelSensorType]] = {
} }
METER_UNIT_MAP: dict[str, set[MeterScaleType]] = { 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_FEET: UNIT_CUBIC_FEET,
UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER, UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER,
UnitOfVolume.GALLONS: UNIT_US_GALLON, UnitOfVolume.GALLONS: UNIT_US_GALLON,
@ -171,7 +170,7 @@ METER_UNIT_MAP: dict[str, set[MeterScaleType]] = {
} }
MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = { 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, UnitOfPower.BTU_PER_HOUR: UNIT_BTU_H,
UnitOfTemperature.CELSIUS: UNIT_CELSIUS, UnitOfTemperature.CELSIUS: UNIT_CELSIUS,
UnitOfLength.CENTIMETERS: UNIT_CENTIMETER, UnitOfLength.CENTIMETERS: UNIT_CENTIMETER,
@ -195,7 +194,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = {
UnitOfVolume.LITERS: UNIT_LITER, UnitOfVolume.LITERS: UNIT_LITER,
LIGHT_LUX: UNIT_LUX, LIGHT_LUX: UNIT_LUX,
UnitOfLength.METERS: UNIT_METER, UnitOfLength.METERS: UNIT_METER,
ELECTRIC_CURRENT_MILLIAMPERE: UNIT_MILLIAMPERE, UnitOfElectricCurrent.MILLIAMPERE: UNIT_MILLIAMPERE,
UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR, UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR,
ELECTRIC_POTENTIAL_MILLIVOLT: UNIT_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT: UNIT_MILLIVOLT,
UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH, UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH,