Add and use ELECTRICAL_CURRENT_AMPERE, ELECTRICAL_VOLTAGE_AMPERE constants (#33990)

* Add and use ELECTRICAL_CURRENT_AMPERE constant

* Add and use ELECTRICAL_VOLTAGE_AMPERE constant

* Rename ELECTRICAL_VOLTAGE_AMPERE to ELECTRICAL_VOLT_AMPERE

* Fix imports
This commit is contained in:
springstan 2020-05-17 15:58:31 +02:00 committed by GitHub
parent dbd821a564
commit b42a197293
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 22 deletions

View file

@ -7,6 +7,8 @@ import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_RESOURCES,
ELECTRICAL_CURRENT_AMPERE,
ELECTRICAL_VOLT_AMPERE,
FREQUENCY_HERTZ,
POWER_WATT,
TEMP_CELSIUS,
@ -67,9 +69,9 @@ SENSOR_TYPES = {
"nominv": ["Nominal Input Voltage", VOLT, "mdi:flash"],
"nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash"],
"nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash"],
"nomapnt": ["Nominal Apparent Power", "VA", "mdi:flash"],
"nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash"],
"numxfers": ["Transfer Count", "", "mdi:counter"],
"outcurnt": ["Output Current", "A", "mdi:flash"],
"outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash"],
"outputv": ["Output Voltage", VOLT, "mdi:flash"],
"reg1": ["Register 1 Fault", "", "mdi:information-outline"],
"reg2": ["Register 2 Fault", "", "mdi:information-outline"],
@ -98,8 +100,8 @@ INFERRED_UNITS = {
" Seconds": TIME_SECONDS,
" Percent": UNIT_PERCENTAGE,
" Volts": VOLT,
" Ampere": "A",
" Volt-Ampere": "VA",
" Ampere": ELECTRICAL_CURRENT_AMPERE,
" Volt-Ampere": ELECTRICAL_VOLT_AMPERE,
" Watts": POWER_WATT,
" Hz": FREQUENCY_HERTZ,
" C": TEMP_CELSIUS,

View file

@ -12,6 +12,7 @@ from homeassistant.const import (
CONF_NAME,
CONF_PASSWORD,
CONF_USERNAME,
ELECTRICAL_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ,
POWER_WATT,
@ -61,17 +62,37 @@ INVERTER_SENSOR_TYPES = {
"power",
),
"inverter_voltage_input_1": ("Input 1 voltage", VOLT, "vpv1", None),
"inverter_amperage_input_1": ("Input 1 Amperage", "A", "ipv1", None),
"inverter_amperage_input_1": (
"Input 1 Amperage",
ELECTRICAL_CURRENT_AMPERE,
"ipv1",
None,
),
"inverter_wattage_input_1": ("Input 1 Wattage", POWER_WATT, "ppv1", "power"),
"inverter_voltage_input_2": ("Input 2 voltage", VOLT, "vpv2", None),
"inverter_amperage_input_2": ("Input 2 Amperage", "A", "ipv2", None),
"inverter_amperage_input_2": (
"Input 2 Amperage",
ELECTRICAL_CURRENT_AMPERE,
"ipv2",
None,
),
"inverter_wattage_input_2": ("Input 2 Wattage", POWER_WATT, "ppv2", "power"),
"inverter_voltage_input_3": ("Input 3 voltage", VOLT, "vpv3", None),
"inverter_amperage_input_3": ("Input 3 Amperage", "A", "ipv3", None),
"inverter_amperage_input_3": (
"Input 3 Amperage",
ELECTRICAL_CURRENT_AMPERE,
"ipv3",
None,
),
"inverter_wattage_input_3": ("Input 3 Wattage", POWER_WATT, "ppv3", "power"),
"inverter_internal_wattage": ("Internal wattage", POWER_WATT, "ppv", "power"),
"inverter_reactive_voltage": ("Reactive voltage", VOLT, "vacr", None),
"inverter_inverter_reactive_amperage": ("Reactive amperage", "A", "iacr", None),
"inverter_inverter_reactive_amperage": (
"Reactive amperage",
ELECTRICAL_CURRENT_AMPERE,
"iacr",
None,
),
"inverter_frequency": ("AC frequency", FREQUENCY_HERTZ, "fac", None),
"inverter_current_wattage": ("Output power", POWER_WATT, "pac", "power"),
"inverter_current_reactive_wattage": (

View file

@ -2,6 +2,7 @@
import logging
from homeassistant.const import (
ELECTRICAL_CURRENT_AMPERE,
ENERGY_WATT_HOUR,
POWER_WATT,
TEMP_CELSIUS,
@ -19,7 +20,7 @@ SENSOR_TYPES = {
"status": ["Charging Status", None],
"temperature": ["Temperature", TEMP_CELSIUS],
"voltage": ["Voltage", VOLT],
"amps": ["Amps", "A"],
"amps": ["Amps", ELECTRICAL_CURRENT_AMPERE],
"watts": ["Watts", POWER_WATT],
"charge_time": ["Charge time", TIME_SECONDS],
"energy_added": ["Energy added", ENERGY_WATT_HOUR],

View file

@ -1,7 +1,11 @@
"""Support for KEBA charging station sensors."""
import logging
from homeassistant.const import DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR
from homeassistant.const import (
DEVICE_CLASS_POWER,
ELECTRICAL_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR,
)
from homeassistant.helpers.entity import Entity
from . import DOMAIN
@ -17,7 +21,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
keba = hass.data[DOMAIN]
sensors = [
KebaSensor(keba, "Curr user", "Max Current", "max_current", "mdi:flash", "A"),
KebaSensor(
keba,
"Curr user",
"Max Current",
"max_current",
"mdi:flash",
ELECTRICAL_CURRENT_AMPERE,
),
KebaSensor(
keba,
"Setenergy",

View file

@ -4,6 +4,8 @@ from homeassistant.components.sensor import DOMAIN
from homeassistant.const import (
CONDUCTIVITY,
DEGREE,
ELECTRICAL_CURRENT_AMPERE,
ELECTRICAL_VOLT_AMPERE,
ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ,
LENGTH_METERS,
@ -41,12 +43,12 @@ SENSORS = {
"S_LIGHT_LEVEL": ["lx", "mdi:white-balance-sunny"],
},
"V_VOLTAGE": [VOLT, "mdi:flash"],
"V_CURRENT": ["A", "mdi:flash-auto"],
"V_CURRENT": [ELECTRICAL_CURRENT_AMPERE, "mdi:flash-auto"],
"V_PH": ["pH", None],
"V_ORP": ["mV", None],
"V_EC": [CONDUCTIVITY, None],
"V_VAR": ["var", None],
"V_VA": ["VA", None],
"V_VA": [ELECTRICAL_VOLT_AMPERE, None],
}

View file

@ -5,6 +5,8 @@ from homeassistant.components.sensor import (
DEVICE_CLASS_TEMPERATURE,
)
from homeassistant.const import (
ELECTRICAL_CURRENT_AMPERE,
ELECTRICAL_VOLT_AMPERE,
FREQUENCY_HERTZ,
POWER_WATT,
TEMP_CELSIUS,
@ -61,8 +63,8 @@ SENSOR_TYPES = {
"ups.display.language": ["Language", "", "mdi:information-outline", None],
"ups.contacts": ["External Contacts", "", "mdi:information-outline", None],
"ups.efficiency": ["Efficiency", UNIT_PERCENTAGE, "mdi:gauge", None],
"ups.power": ["Current Apparent Power", "VA", "mdi:flash", None],
"ups.power.nominal": ["Nominal Power", "VA", "mdi:flash", None],
"ups.power": ["Current Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash", None],
"ups.power.nominal": ["Nominal Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash", None],
"ups.realpower": [
"Current Real Power",
POWER_WATT,
@ -107,8 +109,18 @@ SENSOR_TYPES = {
"battery.voltage.low": ["Low Battery Voltage", VOLT, "mdi:flash", None],
"battery.voltage.high": ["High Battery Voltage", VOLT, "mdi:flash", None],
"battery.capacity": ["Battery Capacity", "Ah", "mdi:flash", None],
"battery.current": ["Battery Current", "A", "mdi:flash", None],
"battery.current.total": ["Total Battery Current", "A", "mdi:flash", None],
"battery.current": [
"Battery Current",
ELECTRICAL_CURRENT_AMPERE,
"mdi:flash",
None,
],
"battery.current.total": [
"Total Battery Current",
ELECTRICAL_CURRENT_AMPERE,
"mdi:flash",
None,
],
"battery.temperature": [
"Battery Temperature",
TEMP_CELSIUS,
@ -168,8 +180,13 @@ SENSOR_TYPES = {
"mdi:information-outline",
None,
],
"output.current": ["Output Current", "A", "mdi:flash", None],
"output.current.nominal": ["Nominal Output Current", "A", "mdi:flash", None],
"output.current": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash", None],
"output.current.nominal": [
"Nominal Output Current",
ELECTRICAL_CURRENT_AMPERE,
"mdi:flash",
None,
],
"output.voltage": ["Output Voltage", VOLT, "mdi:flash", None],
"output.voltage.nominal": ["Nominal Output Voltage", VOLT, "mdi:flash", None],
"output.frequency": ["Output Frequency", FREQUENCY_HERTZ, "mdi:flash", None],

View file

@ -11,6 +11,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_HOST,
CONF_PORT,
ELECTRICAL_CURRENT_AMPERE,
TEMP_CELSIUS,
UNIT_PERCENTAGE,
VOLT,
@ -84,7 +85,7 @@ SENSOR_TYPES = {
"voltage": ["voltage", VOLT],
"voltage_VAD": ["voltage", VOLT],
"voltage_VDD": ["voltage", VOLT],
"current": ["current", "A"],
"current": ["current", ELECTRICAL_CURRENT_AMPERE],
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(

View file

@ -4,6 +4,7 @@ import logging
from homeassistant.const import (
DEGREE,
ELECTRICAL_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
UNIT_PERCENTAGE,
@ -26,7 +27,7 @@ SENSOR_TYPES = {
POWER_WATT,
"active_power",
],
"current": ["Current", "mdi:gauge", "local", "A", "current"],
"current": ["Current", "mdi:gauge", "local", ELECTRICAL_CURRENT_AMPERE, "current"],
"voltage": ["Voltage", "mdi:gauge", "local", VOLT, "voltage"],
"active_cosfi": [
"Power Factor",

View file

@ -12,6 +12,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_NAME,
ELECTRICAL_CURRENT_AMPERE,
ENERGY_WATT_HOUR,
FREQUENCY_HERTZ,
POWER_WATT,
@ -103,7 +104,7 @@ SENSOR_TYPES = {
"optimizer_current": [
"optimizercurrent",
"Average Optimizer Current",
"A",
ELECTRICAL_CURRENT_AMPERE,
"mdi:solar-panel",
None,
],

View file

@ -357,6 +357,10 @@ VOLT = "V"
ENERGY_WATT_HOUR = f"{POWER_WATT}h"
ENERGY_KILO_WATT_HOUR = f"k{ENERGY_WATT_HOUR}"
# Electrical units
ELECTRICAL_CURRENT_AMPERE = "A"
ELECTRICAL_VOLT_AMPERE = f"{VOLT}{ELECTRICAL_CURRENT_AMPERE}"
# Degree units
DEGREE = "°"