Skip to content

Commit

Permalink
Rename and reorganize electric unit constants (#53243)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Jul 20, 2021
1 parent 6e88428 commit 074d762
Show file tree
Hide file tree
Showing 33 changed files with 242 additions and 176 deletions.
36 changes: 18 additions & 18 deletions homeassistant/components/apcupsd/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from homeassistant.const import (
CONF_RESOURCES,
DEVICE_CLASS_TEMPERATURE,
ELECTRICAL_CURRENT_AMPERE,
ELECTRICAL_VOLT_AMPERE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
FREQUENCY_HERTZ,
PERCENTAGE,
POWER_VOLT_AMPERE,
POWER_WATT,
TEMP_CELSIUS,
TIME_MINUTES,
TIME_SECONDS,
VOLT,
)
import homeassistant.helpers.config_validation as cv

Expand All @@ -33,7 +33,7 @@
"badbatts": ["Bad Batteries", "", "mdi:information-outline", None],
"battdate": ["Battery Replaced", "", "mdi:calendar-clock", None],
"battstat": ["Battery Status", "", "mdi:information-outline", None],
"battv": ["Battery Voltage", VOLT, "mdi:flash", None],
"battv": ["Battery Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"bcharge": ["Battery", PERCENTAGE, "mdi:battery", None],
"cable": ["Cable Type", "", "mdi:ethernet-cable", None],
"cumonbatt": ["Total Time on Battery", "", "mdi:timer-outline", None],
Expand All @@ -46,33 +46,33 @@
"endapc": ["Date and Time", "", "mdi:calendar-clock", None],
"extbatts": ["External Batteries", "", "mdi:information-outline", None],
"firmware": ["Firmware Version", "", "mdi:information-outline", None],
"hitrans": ["Transfer High", VOLT, "mdi:flash", None],
"hitrans": ["Transfer High", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"hostname": ["Hostname", "", "mdi:information-outline", None],
"humidity": ["Ambient Humidity", PERCENTAGE, "mdi:water-percent", None],
"itemp": ["Internal Temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
"lastxfer": ["Last Transfer", "", "mdi:transfer", None],
"linefail": ["Input Voltage Status", "", "mdi:information-outline", None],
"linefreq": ["Line Frequency", FREQUENCY_HERTZ, "mdi:information-outline", None],
"linev": ["Input Voltage", VOLT, "mdi:flash", None],
"linev": ["Input Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"loadpct": ["Load", PERCENTAGE, "mdi:gauge", None],
"loadapnt": ["Load Apparent Power", PERCENTAGE, "mdi:gauge", None],
"lotrans": ["Transfer Low", VOLT, "mdi:flash", None],
"lotrans": ["Transfer Low", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"mandate": ["Manufacture Date", "", "mdi:calendar", None],
"masterupd": ["Master Update", "", "mdi:information-outline", None],
"maxlinev": ["Input Voltage High", VOLT, "mdi:flash", None],
"maxlinev": ["Input Voltage High", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"maxtime": ["Battery Timeout", "", "mdi:timer-off-outline", None],
"mbattchg": ["Battery Shutdown", PERCENTAGE, "mdi:battery-alert", None],
"minlinev": ["Input Voltage Low", VOLT, "mdi:flash", None],
"minlinev": ["Input Voltage Low", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"mintimel": ["Shutdown Time", "", "mdi:timer-outline", None],
"model": ["Model", "", "mdi:information-outline", None],
"nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash", None],
"nominv": ["Nominal Input Voltage", VOLT, "mdi:flash", None],
"nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash", None],
"nombattv": ["Battery Nominal Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"nominv": ["Nominal Input Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"nomoutv": ["Nominal Output Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash", None],
"nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash", None],
"nomapnt": ["Nominal Apparent Power", POWER_VOLT_AMPERE, "mdi:flash", None],
"numxfers": ["Transfer Count", "", "mdi:counter", None],
"outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash", None],
"outputv": ["Output Voltage", VOLT, "mdi:flash", None],
"outcurnt": ["Output Current", ELECTRIC_CURRENT_AMPERE, "mdi:flash", None],
"outputv": ["Output Voltage", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"reg1": ["Register 1 Fault", "", "mdi:information-outline", None],
"reg2": ["Register 2 Fault", "", "mdi:information-outline", None],
"reg3": ["Register 3 Fault", "", "mdi:information-outline", None],
Expand All @@ -99,9 +99,9 @@
" Minutes": TIME_MINUTES,
" Seconds": TIME_SECONDS,
" Percent": PERCENTAGE,
" Volts": VOLT,
" Ampere": ELECTRICAL_CURRENT_AMPERE,
" Volt-Ampere": ELECTRICAL_VOLT_AMPERE,
" Volts": ELECTRIC_POTENTIAL_VOLT,
" Ampere": ELECTRIC_CURRENT_AMPERE,
" Volt-Ampere": POWER_VOLT_AMPERE,
" Watts": POWER_WATT,
" Hz": FREQUENCY_HERTZ,
" C": TEMP_CELSIUS,
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/dsmr_reader/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
DEVICE_CLASS_POWER,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLTAGE,
ELECTRICAL_CURRENT_AMPERE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR,
POWER_KILO_WATT,
VOLT,
VOLUME_CUBIC_METERS,
)

Expand Down Expand Up @@ -112,37 +112,37 @@ def tariff_transform(value):
"name": "Current voltage L1",
"enable_default": True,
"device_class": DEVICE_CLASS_VOLTAGE,
"unit": VOLT,
"unit": ELECTRIC_POTENTIAL_VOLT,
},
"dsmr/reading/phase_voltage_l2": {
"name": "Current voltage L2",
"enable_default": True,
"device_class": DEVICE_CLASS_VOLTAGE,
"unit": VOLT,
"unit": ELECTRIC_POTENTIAL_VOLT,
},
"dsmr/reading/phase_voltage_l3": {
"name": "Current voltage L3",
"enable_default": True,
"device_class": DEVICE_CLASS_VOLTAGE,
"unit": VOLT,
"unit": ELECTRIC_POTENTIAL_VOLT,
},
"dsmr/reading/phase_power_current_l1": {
"name": "Phase power current L1",
"enable_default": True,
"device_class": DEVICE_CLASS_CURRENT,
"unit": ELECTRICAL_CURRENT_AMPERE,
"unit": ELECTRIC_CURRENT_AMPERE,
},
"dsmr/reading/phase_power_current_l2": {
"name": "Phase power current L2",
"enable_default": True,
"device_class": DEVICE_CLASS_CURRENT,
"unit": ELECTRICAL_CURRENT_AMPERE,
"unit": ELECTRIC_CURRENT_AMPERE,
},
"dsmr/reading/phase_power_current_l3": {
"name": "Phase power current L3",
"enable_default": True,
"device_class": DEVICE_CLASS_CURRENT,
"unit": ELECTRICAL_CURRENT_AMPERE,
"unit": ELECTRIC_CURRENT_AMPERE,
},
"dsmr/reading/timestamp": {
"name": "Telegram timestamp",
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/elkm1/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import voluptuous as vol

from homeassistant.components.sensor import SensorEntity
from homeassistant.const import VOLT
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_platform

Expand Down Expand Up @@ -255,7 +255,7 @@ def unit_of_measurement(self):
if self._element.definition == ZoneType.TEMPERATURE.value:
return self._temperature_unit
if self._element.definition == ZoneType.ANALOG_ZONE.value:
return VOLT
return ELECTRIC_POTENTIAL_VOLT
return None

def _element_changed(self, element, changeset):
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/envirophat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
CONF_DISPLAY_OPTIONS,
CONF_NAME,
DEVICE_CLASS_TEMPERATURE,
ELECTRIC_POTENTIAL_VOLT,
PRESSURE_HPA,
TEMP_CELSIUS,
VOLT,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
Expand All @@ -37,10 +37,10 @@
"magnetometer_z": ["magnetometer_z", " ", "mdi:magnet", None],
"temperature": ["temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
"pressure": ["pressure", PRESSURE_HPA, "mdi:gauge", None],
"voltage_0": ["voltage_0", VOLT, "mdi:flash", None],
"voltage_1": ["voltage_1", VOLT, "mdi:flash", None],
"voltage_2": ["voltage_2", VOLT, "mdi:flash", None],
"voltage_3": ["voltage_3", VOLT, "mdi:flash", None],
"voltage_0": ["voltage_0", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"voltage_1": ["voltage_1", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"voltage_2": ["voltage_2", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
"voltage_3": ["voltage_3", ELECTRIC_POTENTIAL_VOLT, "mdi:flash", None],
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/goalzero/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
ATTR_DEVICE_CLASS,
ATTR_NAME,
ATTR_UNIT_OF_MEASUREMENT,
ELECTRICAL_CURRENT_AMPERE,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR,
PERCENTAGE,
POWER_WATT,
SIGNAL_STRENGTH_DECIBELS,
TEMP_CELSIUS,
TIME_MINUTES,
TIME_SECONDS,
VOLT,
)

ATTR_DEFAULT_ENABLED = "default_enabled"
Expand Down Expand Up @@ -66,7 +66,7 @@
"ampsIn": {
ATTR_NAME: "Amps In",
ATTR_DEVICE_CLASS: DEVICE_CLASS_CURRENT,
ATTR_UNIT_OF_MEASUREMENT: ELECTRICAL_CURRENT_AMPERE,
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_CURRENT_AMPERE,
ATTR_STATE_CLASS: STATE_CLASS_MEASUREMENT,
ATTR_DEFAULT_ENABLED: False,
},
Expand All @@ -80,7 +80,7 @@
"ampsOut": {
ATTR_NAME: "Amps Out",
ATTR_DEVICE_CLASS: DEVICE_CLASS_CURRENT,
ATTR_UNIT_OF_MEASUREMENT: ELECTRICAL_CURRENT_AMPERE,
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_CURRENT_AMPERE,
ATTR_STATE_CLASS: STATE_CLASS_MEASUREMENT,
ATTR_DEFAULT_ENABLED: False,
},
Expand All @@ -101,7 +101,7 @@
"volts": {
ATTR_NAME: "Volts",
ATTR_DEVICE_CLASS: DEVICE_CLASS_VOLTAGE,
ATTR_UNIT_OF_MEASUREMENT: VOLT,
ATTR_UNIT_OF_MEASUREMENT: ELECTRIC_POTENTIAL_VOLT,
ATTR_DEFAULT_ENABLED: False,
},
"socPercent": {
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/greeneye_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
CONF_SENSOR_TYPE,
CONF_TEMPERATURE_UNIT,
DEVICE_CLASS_TEMPERATURE,
ELECTRIC_POTENTIAL_VOLT,
POWER_WATT,
TIME_HOURS,
TIME_MINUTES,
TIME_SECONDS,
VOLT,
)

from . import (
Expand Down Expand Up @@ -270,7 +270,7 @@ class VoltageSensor(GEMSensor):
"""Entity showing voltage."""

_attr_icon = VOLTAGE_ICON
_attr_unit_of_measurement = VOLT
_attr_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT

def __init__(self, monitor_serial_number, number, name):
"""Construct the entity."""
Expand Down

0 comments on commit 074d762

Please sign in to comment.