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.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,
),

View file

@ -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

View file

@ -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(

View file

@ -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,

View file

@ -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]

View file

@ -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",

View file

@ -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,
),

View file

@ -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",

View file

@ -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,
),

View file

@ -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,
),

View file

@ -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,
),

View file

@ -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,
),

View file

@ -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,

View file

@ -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,
),

View file

@ -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,
),
),

View file

@ -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",

View file

@ -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,
),

View file

@ -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",

View file

@ -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,

View file

@ -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,
),

View file

@ -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,
),

View file

@ -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,
),

View file

@ -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",
),

View file

@ -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,

View file

@ -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,