Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions homeassistant/components/apcupsd/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TIME_MINUTES,
TIME_SECONDS,
UNIT_PERCENTAGE,
UNIT_VOLT,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
Expand All @@ -29,7 +30,7 @@
"badbatts": ["Bad Batteries", "", "mdi:information-outline"],
"battdate": ["Battery Replaced", "", "mdi:calendar-clock"],
"battstat": ["Battery Status", "", "mdi:information-outline"],
"battv": ["Battery Voltage", "V", "mdi:flash"],
"battv": ["Battery Voltage", UNIT_VOLT, "mdi:flash"],
"bcharge": ["Battery", UNIT_PERCENTAGE, "mdi:battery"],
"cable": ["Cable Type", "", "mdi:ethernet-cable"],
"cumonbatt": ["Total Time on Battery", "", "mdi:timer"],
Expand All @@ -42,33 +43,33 @@
"endapc": ["Date and Time", "", "mdi:calendar-clock"],
"extbatts": ["External Batteries", "", "mdi:information-outline"],
"firmware": ["Firmware Version", "", "mdi:information-outline"],
"hitrans": ["Transfer High", "V", "mdi:flash"],
"hitrans": ["Transfer High", UNIT_VOLT, "mdi:flash"],
"hostname": ["Hostname", "", "mdi:information-outline"],
"humidity": ["Ambient Humidity", UNIT_PERCENTAGE, "mdi:water-percent"],
"itemp": ["Internal Temperature", TEMP_CELSIUS, "mdi:thermometer"],
"lastxfer": ["Last Transfer", "", "mdi:transfer"],
"linefail": ["Input Voltage Status", "", "mdi:information-outline"],
"linefreq": ["Line Frequency", "Hz", "mdi:information-outline"],
"linev": ["Input Voltage", "V", "mdi:flash"],
"linev": ["Input Voltage", UNIT_VOLT, "mdi:flash"],
"loadpct": ["Load", UNIT_PERCENTAGE, "mdi:gauge"],
"loadapnt": ["Load Apparent Power", UNIT_PERCENTAGE, "mdi:gauge"],
"lotrans": ["Transfer Low", "V", "mdi:flash"],
"lotrans": ["Transfer Low", UNIT_VOLT, "mdi:flash"],
"mandate": ["Manufacture Date", "", "mdi:calendar"],
"masterupd": ["Master Update", "", "mdi:information-outline"],
"maxlinev": ["Input Voltage High", "V", "mdi:flash"],
"maxlinev": ["Input Voltage High", UNIT_VOLT, "mdi:flash"],
"maxtime": ["Battery Timeout", "", "mdi:timer-off"],
"mbattchg": ["Battery Shutdown", UNIT_PERCENTAGE, "mdi:battery-alert"],
"minlinev": ["Input Voltage Low", "V", "mdi:flash"],
"minlinev": ["Input Voltage Low", UNIT_VOLT, "mdi:flash"],
"mintimel": ["Shutdown Time", "", "mdi:timer"],
"model": ["Model", "", "mdi:information-outline"],
"nombattv": ["Battery Nominal Voltage", "V", "mdi:flash"],
"nominv": ["Nominal Input Voltage", "V", "mdi:flash"],
"nomoutv": ["Nominal Output Voltage", "V", "mdi:flash"],
"nombattv": ["Battery Nominal Voltage", UNIT_VOLT, "mdi:flash"],
"nominv": ["Nominal Input Voltage", UNIT_VOLT, "mdi:flash"],
"nomoutv": ["Nominal Output Voltage", UNIT_VOLT, "mdi:flash"],
"nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash"],
"nomapnt": ["Nominal Apparent Power", "VA", "mdi:flash"],
"numxfers": ["Transfer Count", "", "mdi:counter"],
"outcurnt": ["Output Current", "A", "mdi:flash"],
"outputv": ["Output Voltage", "V", "mdi:flash"],
"outputv": ["Output Voltage", UNIT_VOLT, "mdi:flash"],
"reg1": ["Register 1 Fault", "", "mdi:information-outline"],
"reg2": ["Register 2 Fault", "", "mdi:information-outline"],
"reg3": ["Register 3 Fault", "", "mdi:information-outline"],
Expand All @@ -95,7 +96,7 @@
" Minutes": TIME_MINUTES,
" Seconds": TIME_SECONDS,
" Percent": UNIT_PERCENTAGE,
" Volts": "V",
" Volts": UNIT_VOLT,
" Ampere": "A",
" Volt-Ampere": "VA",
" Watts": POWER_WATT,
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/dsmr_reader/definitions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Definitions for DSMR Reader sensors added to MQTT."""

from homeassistant.const import ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UNIT_VOLT, VOLUME_CUBIC_METERS


def dsmr_transform(value):
Expand Down Expand Up @@ -86,17 +86,17 @@ def tariff_transform(value):
"dsmr/reading/phase_voltage_l1": {
"name": "Current voltage L1",
"icon": "mdi:flash",
"unit": "V",
"unit": UNIT_VOLT,
},
"dsmr/reading/phase_voltage_l2": {
"name": "Current voltage L2",
"icon": "mdi:flash",
"unit": "V",
"unit": UNIT_VOLT,
},
"dsmr/reading/phase_voltage_l3": {
"name": "Current voltage L3",
"icon": "mdi:flash",
"unit": "V",
"unit": UNIT_VOLT,
},
"dsmr/consumption/gas/delivered": {
"name": "Gas usage",
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/elkm1/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
)
from elkm1_lib.util import pretty_const, username

from homeassistant.const import UNIT_VOLT

from . import ElkAttachedEntity, create_elk_entities
from .const import DOMAIN

Expand Down Expand Up @@ -195,7 +197,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 "V"
return UNIT_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 @@ -6,7 +6,7 @@
import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_DISPLAY_OPTIONS, CONF_NAME, TEMP_CELSIUS
from homeassistant.const import CONF_DISPLAY_OPTIONS, CONF_NAME, TEMP_CELSIUS, UNIT_VOLT
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
Expand All @@ -31,10 +31,10 @@
"magnetometer_z": ["magnetometer_z", " ", "mdi:magnet"],
"temperature": ["temperature", TEMP_CELSIUS, "mdi:thermometer"],
"pressure": ["pressure", "hPa", "mdi:gauge"],
"voltage_0": ["voltage_0", "V", "mdi:flash"],
"voltage_1": ["voltage_1", "V", "mdi:flash"],
"voltage_2": ["voltage_2", "V", "mdi:flash"],
"voltage_3": ["voltage_3", "V", "mdi:flash"],
"voltage_0": ["voltage_0", UNIT_VOLT, "mdi:flash"],
"voltage_1": ["voltage_1", UNIT_VOLT, "mdi:flash"],
"voltage_2": ["voltage_2", UNIT_VOLT, "mdi:flash"],
"voltage_3": ["voltage_3", UNIT_VOLT, "mdi:flash"],
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/greeneye_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
TIME_HOURS,
TIME_MINUTES,
TIME_SECONDS,
UNIT_VOLT,
)
from homeassistant.helpers.entity import Entity

Expand Down Expand Up @@ -310,4 +311,4 @@ def state(self):
@property
def unit_of_measurement(self):
"""Return the unit of measurement for this sensor."""
return "V"
return UNIT_VOLT
9 changes: 5 additions & 4 deletions homeassistant/components/growatt_server/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CONF_PASSWORD,
CONF_USERNAME,
ENERGY_KILO_WATT_HOUR,
UNIT_VOLT,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
Expand Down Expand Up @@ -57,17 +58,17 @@
"e_total",
"power",
),
"inverter_voltage_input_1": ("Input 1 voltage", "V", "vpv1", None),
"inverter_voltage_input_1": ("Input 1 voltage", UNIT_VOLT, "vpv1", None),
"inverter_amperage_input_1": ("Input 1 Amperage", "A", "ipv1", None),
"inverter_wattage_input_1": ("Input 1 Wattage", "W", "ppv1", "power"),
"inverter_voltage_input_2": ("Input 2 voltage", "V", "vpv2", None),
"inverter_voltage_input_2": ("Input 2 voltage", UNIT_VOLT, "vpv2", None),
"inverter_amperage_input_2": ("Input 2 Amperage", "A", "ipv2", None),
"inverter_wattage_input_2": ("Input 2 Wattage", "W", "ppv2", "power"),
"inverter_voltage_input_3": ("Input 3 voltage", "V", "vpv3", None),
"inverter_voltage_input_3": ("Input 3 voltage", UNIT_VOLT, "vpv3", None),
"inverter_amperage_input_3": ("Input 3 Amperage", "A", "ipv3", None),
"inverter_wattage_input_3": ("Input 3 Wattage", "W", "ppv3", "power"),
"inverter_internal_wattage": ("Internal wattage", "W", "ppv", "power"),
"inverter_reactive_voltage": ("Reactive voltage", "V", "vacr", None),
"inverter_reactive_voltage": ("Reactive voltage", UNIT_VOLT, "vacr", None),
"inverter_inverter_reactive_amperage": ("Reactive amperage", "A", "iacr", None),
"inverter_frequency": ("AC frequency", "Hz", "fac", None),
"inverter_current_wattage": ("Output power", "W", "pac", "power"),
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/homematic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS,
UNIT_PERCENTAGE,
UNIT_VOLT,
VOLUME_CUBIC_METERS,
)

Expand Down Expand Up @@ -40,7 +41,7 @@
"BRIGHTNESS": "#",
"POWER": POWER_WATT,
"CURRENT": "mA",
"VOLTAGE": "V",
"VOLTAGE": UNIT_VOLT,
"ENERGY_COUNTER": ENERGY_WATT_HOUR,
"GAS_POWER": VOLUME_CUBIC_METERS,
"GAS_ENERGY_COUNTER": VOLUME_CUBIC_METERS,
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/isy994/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
TIME_YEARS,
UNIT_PERCENTAGE,
UNIT_UV_INDEX,
UNIT_VOLT,
)
from homeassistant.helpers.typing import ConfigType

Expand Down Expand Up @@ -91,7 +92,7 @@
"65": "SML",
"69": "gal",
"71": UNIT_UV_INDEX,
"72": "V",
"72": UNIT_VOLT,
"73": POWER_WATT,
"74": "W/m²",
"75": "weekday",
Expand Down
10 changes: 8 additions & 2 deletions homeassistant/components/juicenet/sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Support for monitoring juicenet/juicepoint/juicebox based EVSE sensors."""
import logging

from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT, TEMP_CELSIUS, TIME_SECONDS
from homeassistant.const import (
ENERGY_WATT_HOUR,
POWER_WATT,
TEMP_CELSIUS,
TIME_SECONDS,
UNIT_VOLT,
)
from homeassistant.helpers.entity import Entity

from . import DOMAIN, JuicenetDevice
Expand All @@ -11,7 +17,7 @@
SENSOR_TYPES = {
"status": ["Charging Status", None],
"temperature": ["Temperature", TEMP_CELSIUS],
"voltage": ["Voltage", "V"],
"voltage": ["Voltage", UNIT_VOLT],
"amps": ["Amps", "A"],
"watts": ["Watts", POWER_WATT],
"charge_time": ["Charge time", TIME_SECONDS],
Expand Down
9 changes: 7 additions & 2 deletions homeassistant/components/lcn/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""Constants for the LCN component."""
from itertools import product

from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, UNIT_PERCENTAGE
from homeassistant.const import (
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UNIT_PERCENTAGE,
UNIT_VOLT,
)

DOMAIN = "lcn"
DATA_LCN = "lcn"
Expand Down Expand Up @@ -157,7 +162,7 @@
"PERCENT",
"PPM",
"VOLT",
"V",
UNIT_VOLT,
"AMPERE",
"AMP",
"A",
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/mysensors/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UNIT_PERCENTAGE,
UNIT_VOLT,
)

SENSORS = {
Expand Down Expand Up @@ -35,7 +36,7 @@
"S_VIBRATION": ["Hz", None],
"S_LIGHT_LEVEL": ["lx", "mdi:white-balance-sunny"],
},
"V_VOLTAGE": ["V", "mdi:flash"],
"V_VOLTAGE": [UNIT_VOLT, "mdi:flash"],
"V_CURRENT": ["A", "mdi:flash-auto"],
"V_PH": ["pH", None],
"V_ORP": ["mV", None],
Expand Down
33 changes: 22 additions & 11 deletions homeassistant/components/nut/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
)
from homeassistant.const import POWER_WATT, TEMP_CELSIUS, TIME_SECONDS, UNIT_PERCENTAGE
from homeassistant.const import (
POWER_WATT,
TEMP_CELSIUS,
TIME_SECONDS,
UNIT_PERCENTAGE,
UNIT_VOLT,
)

DOMAIN = "nut"

Expand Down Expand Up @@ -93,10 +99,15 @@
None,
],
"battery.charger.status": ["Charging Status", "", "mdi:information-outline", None],
"battery.voltage": ["Battery Voltage", "V", "mdi:flash", None],
"battery.voltage.nominal": ["Nominal Battery Voltage", "V", "mdi:flash", None],
"battery.voltage.low": ["Low Battery Voltage", "V", "mdi:flash", None],
"battery.voltage.high": ["High Battery Voltage", "V", "mdi:flash", None],
"battery.voltage": ["Battery Voltage", UNIT_VOLT, "mdi:flash", None],
"battery.voltage.nominal": [
"Nominal Battery Voltage",
UNIT_VOLT,
"mdi:flash",
None,
],
"battery.voltage.low": ["Low Battery Voltage", UNIT_VOLT, "mdi:flash", None],
"battery.voltage.high": ["High Battery Voltage", UNIT_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],
Expand Down Expand Up @@ -136,16 +147,16 @@
"mdi:information-outline",
None,
],
"input.transfer.low": ["Low Voltage Transfer", "V", "mdi:flash", None],
"input.transfer.high": ["High Voltage Transfer", "V", "mdi:flash", None],
"input.transfer.low": ["Low Voltage Transfer", UNIT_VOLT, "mdi:flash", None],
"input.transfer.high": ["High Voltage Transfer", UNIT_VOLT, "mdi:flash", None],
"input.transfer.reason": [
"Voltage Transfer Reason",
"",
"mdi:information-outline",
None,
],
"input.voltage": ["Input Voltage", "V", "mdi:flash", None],
"input.voltage.nominal": ["Nominal Input Voltage", "V", "mdi:flash", None],
"input.voltage": ["Input Voltage", UNIT_VOLT, "mdi:flash", None],
"input.voltage.nominal": ["Nominal Input Voltage", UNIT_VOLT, "mdi:flash", None],
"input.frequency": ["Input Line Frequency", "hz", "mdi:flash", None],
"input.frequency.nominal": [
"Nominal Input Line Frequency",
Expand All @@ -161,8 +172,8 @@
],
"output.current": ["Output Current", "A", "mdi:flash", None],
"output.current.nominal": ["Nominal Output Current", "A", "mdi:flash", None],
"output.voltage": ["Output Voltage", "V", "mdi:flash", None],
"output.voltage.nominal": ["Nominal Output Voltage", "V", "mdi:flash", None],
"output.voltage": ["Output Voltage", UNIT_VOLT, "mdi:flash", None],
"output.voltage.nominal": ["Nominal Output Voltage", UNIT_VOLT, "mdi:flash", None],
"output.frequency": ["Output Frequency", "hz", "mdi:flash", None],
"output.frequency.nominal": ["Nominal Output Frequency", "hz", "mdi:flash", None],
}
Expand Down
14 changes: 10 additions & 4 deletions homeassistant/components/onewire/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_HOST, CONF_PORT, TEMP_CELSIUS, UNIT_PERCENTAGE
from homeassistant.const import (
CONF_HOST,
CONF_PORT,
TEMP_CELSIUS,
UNIT_PERCENTAGE,
UNIT_VOLT,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity

Expand Down Expand Up @@ -75,9 +81,9 @@
"counter_a": ["counter", "count"],
"counter_b": ["counter", "count"],
"HobbyBoard": ["none", "none"],
"voltage": ["voltage", "V"],
"voltage_VAD": ["voltage", "V"],
"voltage_VDD": ["voltage", "V"],
"voltage": ["voltage", UNIT_VOLT],
"voltage_VAD": ["voltage", UNIT_VOLT],
"voltage_VDD": ["voltage", UNIT_VOLT],
"current": ["current", "A"],
}

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/smappee/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
UNIT_PERCENTAGE,
UNIT_VOLT,
VOLUME_CUBIC_METERS,
)
from homeassistant.helpers.entity import Entity
Expand All @@ -25,7 +26,7 @@
"active_power",
],
"current": ["Current", "mdi:gauge", "local", "A", "current"],
"voltage": ["Voltage", "mdi:gauge", "local", "V", "voltage"],
"voltage": ["Voltage", "mdi:gauge", "local", UNIT_VOLT, "voltage"],
"active_cosfi": [
"Power Factor",
"mdi:gauge",
Expand Down
Loading