diff --git a/homeassistant/components/apcupsd/sensor.py b/homeassistant/components/apcupsd/sensor.py index 44c1c498c28..3a8619a092f 100644 --- a/homeassistant/components/apcupsd/sensor.py +++ b/homeassistant/components/apcupsd/sensor.py @@ -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, diff --git a/homeassistant/components/growatt_server/sensor.py b/homeassistant/components/growatt_server/sensor.py index 6bfdf7f2552..c228bcbe4ab 100644 --- a/homeassistant/components/growatt_server/sensor.py +++ b/homeassistant/components/growatt_server/sensor.py @@ -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": ( diff --git a/homeassistant/components/juicenet/sensor.py b/homeassistant/components/juicenet/sensor.py index e7408cf9f85..c5d37cb8180 100644 --- a/homeassistant/components/juicenet/sensor.py +++ b/homeassistant/components/juicenet/sensor.py @@ -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], diff --git a/homeassistant/components/keba/sensor.py b/homeassistant/components/keba/sensor.py index d9e6118ff32..443e1bcd1bc 100644 --- a/homeassistant/components/keba/sensor.py +++ b/homeassistant/components/keba/sensor.py @@ -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", diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 15876163762..d170f476158 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -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], } diff --git a/homeassistant/components/nut/const.py b/homeassistant/components/nut/const.py index 9b4908530a8..47959108a2c 100644 --- a/homeassistant/components/nut/const.py +++ b/homeassistant/components/nut/const.py @@ -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], diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index 12a4546dbeb..f12d3ab2346 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -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( diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index cb252dda98b..9558bbc2e62 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -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", diff --git a/homeassistant/components/solaredge_local/sensor.py b/homeassistant/components/solaredge_local/sensor.py index 94aa06c2647..59b0a5e8856 100644 --- a/homeassistant/components/solaredge_local/sensor.py +++ b/homeassistant/components/solaredge_local/sensor.py @@ -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, ], diff --git a/homeassistant/const.py b/homeassistant/const.py index 11a99515d60..2ff1d65223b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -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 = "°"