Use UnitOfElectricCurrent in integrations (#84231)

This commit is contained in:
epenet 2022-12-19 16:59:39 +01:00 committed by GitHub
parent 026f660889
commit 418be1eeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 17 deletions

View File

@ -23,13 +23,13 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_HPA, PRESSURE_HPA,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
Platform, Platform,
UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
@ -153,14 +153,14 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
name="Current", name="Current",
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,
), ),
CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20: HomeKitSensorEntityDescription( CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20: HomeKitSensorEntityDescription(
key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20, key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_AMPS_20,
name="Current", name="Current",
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,
), ),
CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR: HomeKitSensorEntityDescription( CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR: HomeKitSensorEntityDescription(
key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR, key=CharacteristicsTypes.VENDOR_CONNECTSENSE_ENERGY_KW_HOUR,
@ -195,7 +195,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
name="Amps", name="Amps",
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,
), ),
CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY: HomeKitSensorEntityDescription( CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY: HomeKitSensorEntityDescription(
key=CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY, key=CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY,

View File

@ -17,11 +17,11 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
@ -89,7 +89,7 @@ SENSORS: Final = {
("emeter", "current"): BlockSensorDescription( ("emeter", "current"): BlockSensorDescription(
key="emeter|current", key="emeter|current",
name="Current", name="Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
value=lambda value: value, value=lambda value: value,
device_class=SensorDeviceClass.CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

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 (
ELECTRIC_CURRENT_AMPERE,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfFrequency, UnitOfFrequency,
@ -64,7 +64,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
(Units.A, False): SensorEntityDescription( (Units.A, False): SensorEntityDescription(
key=f"{Units.A}_{False}", key=f"{Units.A}_{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,
), ),
(Units.W, False): SensorEntityDescription( (Units.W, False): SensorEntityDescription(

View File

@ -19,7 +19,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_HPA, PRESSURE_HPA,
@ -32,6 +31,7 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
TEMP_KELVIN, TEMP_KELVIN,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfFrequency, UnitOfFrequency,
@ -213,7 +213,7 @@ SENSOR_UNIT_MAP = {
hc.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, hc.CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
hc.CONCENTRATION_PARTS_PER_BILLION: CONCENTRATION_PARTS_PER_BILLION, hc.CONCENTRATION_PARTS_PER_BILLION: CONCENTRATION_PARTS_PER_BILLION,
hc.CONCENTRATION_PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION, hc.CONCENTRATION_PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION,
hc.ELECTRICAL_CURRENT_AMPERE: ELECTRIC_CURRENT_AMPERE, hc.ELECTRICAL_CURRENT_AMPERE: UnitOfElectricCurrent.AMPERE,
hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE, hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE,
hc.ENERGY_KILO_WATT_HOUR: UnitOfEnergy.KILO_WATT_HOUR, hc.ENERGY_KILO_WATT_HOUR: UnitOfEnergy.KILO_WATT_HOUR,
hc.FREQUENCY_HERTZ: UnitOfFrequency.HERTZ, hc.FREQUENCY_HERTZ: UnitOfFrequency.HERTZ,

View File

@ -15,7 +15,7 @@ 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 (
ATTR_VOLTAGE, ATTR_VOLTAGE,
ELECTRIC_CURRENT_AMPERE, UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
@ -81,7 +81,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
), ),
TPLinkSensorEntityDescription( TPLinkSensorEntityDescription(
key=ATTR_CURRENT_A, key=ATTR_CURRENT_A,
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,
name="Current", name="Current",

View File

@ -13,8 +13,8 @@ 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,
PERCENTAGE, PERCENTAGE,
UnitOfElectricCurrent,
UnitOfEnergy, UnitOfEnergy,
UnitOfLength, UnitOfLength,
UnitOfPower, UnitOfPower,
@ -70,7 +70,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
key=CHARGER_MAX_AVAILABLE_POWER_KEY, key=CHARGER_MAX_AVAILABLE_POWER_KEY,
name="Max Available Power", name="Max Available Power",
precision=0, precision=0,
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,
), ),
@ -146,7 +146,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
CHARGER_MAX_CHARGING_CURRENT_KEY: WallboxSensorEntityDescription( CHARGER_MAX_CHARGING_CURRENT_KEY: WallboxSensorEntityDescription(
key=CHARGER_MAX_CHARGING_CURRENT_KEY, key=CHARGER_MAX_CHARGING_CURRENT_KEY,
name="Max. Charging Current", name="Max. Charging 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

@ -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,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_KPA, PRESSURE_KPA,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
@ -72,7 +72,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
"meterElectric_ampere": ZWaveMeSensorEntityDescription( "meterElectric_ampere": ZWaveMeSensorEntityDescription(
key="meterElectric_ampere", key="meterElectric_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,
), ),
"meterElectric_kilowatt_hour": ZWaveMeSensorEntityDescription( "meterElectric_kilowatt_hour": ZWaveMeSensorEntityDescription(