mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add and use UNIT_VOLT constant (#33994)
* Add and use UNIT_VOLT constant * Run isort
This commit is contained in:
parent
32e87fc4c7
commit
04c4501455
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -29,7 +30,7 @@ SENSOR_TYPES = {
|
||||
"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"],
|
||||
@ -42,33 +43,33 @@ SENSOR_TYPES = {
|
||||
"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"],
|
||||
@ -95,7 +96,7 @@ INFERRED_UNITS = {
|
||||
" Minutes": TIME_MINUTES,
|
||||
" Seconds": TIME_SECONDS,
|
||||
" Percent": UNIT_PERCENTAGE,
|
||||
" Volts": "V",
|
||||
" Volts": UNIT_VOLT,
|
||||
" Ampere": "A",
|
||||
" Volt-Ampere": "VA",
|
||||
" Watts": POWER_WATT,
|
||||
|
@ -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):
|
||||
@ -86,17 +86,17 @@ DEFINITIONS = {
|
||||
"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",
|
||||
|
@ -7,6 +7,8 @@ from elkm1_lib.const import (
|
||||
)
|
||||
from elkm1_lib.util import pretty_const, username
|
||||
|
||||
from homeassistant.const import UNIT_VOLT
|
||||
|
||||
from . import ElkAttachedEntity, create_elk_entities
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -195,7 +197,7 @@ class ElkZone(ElkSensor):
|
||||
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):
|
||||
|
@ -6,7 +6,7 @@ import logging
|
||||
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
|
||||
@ -31,10 +31,10 @@ SENSOR_TYPES = {
|
||||
"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(
|
||||
|
@ -8,6 +8,7 @@ from homeassistant.const import (
|
||||
TIME_HOURS,
|
||||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
@ -310,4 +311,4 @@ class VoltageSensor(GEMSensor):
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement for this sensor."""
|
||||
return "V"
|
||||
return UNIT_VOLT
|
||||
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -57,17 +58,17 @@ INVERTER_SENSOR_TYPES = {
|
||||
"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"),
|
||||
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLUME_CUBIC_METERS,
|
||||
)
|
||||
|
||||
@ -40,7 +41,7 @@ HM_UNIT_HA_CAST = {
|
||||
"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,
|
||||
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||
TIME_YEARS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
@ -91,7 +92,7 @@ UOM_FRIENDLY_NAME = {
|
||||
"65": "SML",
|
||||
"69": "gal",
|
||||
"71": UNIT_UV_INDEX,
|
||||
"72": "V",
|
||||
"72": UNIT_VOLT,
|
||||
"73": POWER_WATT,
|
||||
"74": "W/m²",
|
||||
"75": "weekday",
|
||||
|
@ -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
|
||||
@ -11,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
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],
|
||||
|
@ -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"
|
||||
@ -157,7 +162,7 @@ VAR_UNITS = [
|
||||
"PERCENT",
|
||||
"PPM",
|
||||
"VOLT",
|
||||
"V",
|
||||
UNIT_VOLT,
|
||||
"AMPERE",
|
||||
"AMP",
|
||||
"A",
|
||||
|
@ -8,6 +8,7 @@ from homeassistant.const import (
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
|
||||
SENSORS = {
|
||||
@ -35,7 +36,7 @@ SENSORS = {
|
||||
"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],
|
||||
|
@ -4,7 +4,13 @@ from homeassistant.components.sensor import (
|
||||
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"
|
||||
|
||||
@ -94,10 +100,15 @@ SENSOR_TYPES = {
|
||||
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],
|
||||
@ -137,16 +148,16 @@ SENSOR_TYPES = {
|
||||
"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",
|
||||
@ -162,8 +173,8 @@ SENSOR_TYPES = {
|
||||
],
|
||||
"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],
|
||||
}
|
||||
|
@ -8,7 +8,13 @@ from pyownet import protocol
|
||||
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
|
||||
|
||||
@ -75,9 +81,9 @@ SENSOR_TYPES = {
|
||||
"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"],
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLUME_CUBIC_METERS,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -25,7 +26,7 @@ SENSOR_TYPES = {
|
||||
"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",
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
|
||||
from . import SmartThingsEntity
|
||||
@ -233,7 +234,7 @@ CAPABILITY_TO_SENSORS = {
|
||||
Map(Attribute.ultraviolet_index, "Ultraviolet Index", None, None)
|
||||
],
|
||||
Capability.voltage_measurement: [
|
||||
Map(Attribute.voltage, "Voltage Measurement", "V", None)
|
||||
Map(Attribute.voltage, "Voltage Measurement", UNIT_VOLT, None)
|
||||
],
|
||||
Capability.washer_mode: [Map(Attribute.washer_mode, "Washer Mode", None, None)],
|
||||
Capability.washer_operating_state: [
|
||||
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -40,8 +41,20 @@ INVERTER_MODES = (
|
||||
# Supported sensor types:
|
||||
# Key: ['json_key', 'name', unit, icon, attribute name]
|
||||
SENSOR_TYPES = {
|
||||
"current_AC_voltage": ["gridvoltage", "Grid Voltage", "V", "mdi:current-ac", None],
|
||||
"current_DC_voltage": ["dcvoltage", "DC Voltage", "V", "mdi:current-dc", None],
|
||||
"current_AC_voltage": [
|
||||
"gridvoltage",
|
||||
"Grid Voltage",
|
||||
UNIT_VOLT,
|
||||
"mdi:current-ac",
|
||||
None,
|
||||
],
|
||||
"current_DC_voltage": [
|
||||
"dcvoltage",
|
||||
"DC Voltage",
|
||||
UNIT_VOLT,
|
||||
"mdi:current-dc",
|
||||
None,
|
||||
],
|
||||
"current_frequency": [
|
||||
"gridfrequency",
|
||||
"Grid Frequency",
|
||||
@ -122,7 +135,7 @@ SENSOR_TYPES = {
|
||||
"optimizer_voltage": [
|
||||
"optimizervoltage",
|
||||
"Average Optimizer Voltage",
|
||||
"V",
|
||||
UNIT_VOLT,
|
||||
"mdi:solar-panel",
|
||||
None,
|
||||
],
|
||||
|
@ -1,7 +1,12 @@
|
||||
"""Constants for the Solar-Log integration."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT, UNIT_PERCENTAGE
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
|
||||
DOMAIN = "solarlog"
|
||||
|
||||
@ -17,8 +22,8 @@ SENSOR_TYPES = {
|
||||
"time": ["TIME", "last update", None, "mdi:calendar-clock"],
|
||||
"power_ac": ["powerAC", "power AC", POWER_WATT, "mdi:solar-power"],
|
||||
"power_dc": ["powerDC", "power DC", POWER_WATT, "mdi:solar-power"],
|
||||
"voltage_ac": ["voltageAC", "voltage AC", "V", "mdi:flash"],
|
||||
"voltage_dc": ["voltageDC", "voltage DC", "V", "mdi:flash"],
|
||||
"voltage_ac": ["voltageAC", "voltage AC", UNIT_VOLT, "mdi:flash"],
|
||||
"voltage_dc": ["voltageDC", "voltage DC", UNIT_VOLT, "mdi:flash"],
|
||||
"yield_day": ["yieldDAY", "yield day", ENERGY_KILO_WATT_HOUR, "mdi:solar-power"],
|
||||
"yield_yesterday": [
|
||||
"yieldYESTERDAY",
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Reads vehicle status from StarLine API."""
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE
|
||||
from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE
|
||||
from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE, UNIT_VOLT
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.icon import icon_for_battery_level, icon_for_signal_level
|
||||
|
||||
@ -9,7 +9,7 @@ from .const import DOMAIN
|
||||
from .entity import StarlineEntity
|
||||
|
||||
SENSOR_TYPES = {
|
||||
"battery": ["Battery", None, "V", None],
|
||||
"battery": ["Battery", None, UNIT_VOLT, None],
|
||||
"balance": ["Balance", None, None, "mdi:cash-multiple"],
|
||||
"ctemp": ["Interior Temperature", DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None],
|
||||
"etemp": ["Engine Temperature", DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None],
|
||||
|
@ -7,7 +7,7 @@ import voluptuous as vol
|
||||
import xmltodict
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT, UNIT_VOLT
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
dev = []
|
||||
for mtu in gateway.data:
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, POWER_WATT))
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, "V"))
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, UNIT_VOLT))
|
||||
|
||||
add_entities(dev)
|
||||
return True
|
||||
@ -54,7 +54,7 @@ class Ted5000Sensor(Entity):
|
||||
|
||||
def __init__(self, gateway, name, mtu, unit):
|
||||
"""Initialize the sensor."""
|
||||
units = {POWER_WATT: "power", "V": "voltage"}
|
||||
units = {POWER_WATT: "power", UNIT_VOLT: "voltage"}
|
||||
self._gateway = gateway
|
||||
self._name = "{} mtu{} {}".format(name, mtu, units[unit])
|
||||
self._mtu = mtu
|
||||
@ -108,4 +108,4 @@ class Ted5000Gateway:
|
||||
power = int(doc["LiveData"]["Power"]["MTU%d" % mtu]["PowerNow"])
|
||||
voltage = int(doc["LiveData"]["Voltage"]["MTU%d" % mtu]["VoltageNow"])
|
||||
|
||||
self.data[mtu] = {POWER_WATT: power, "V": voltage / 10}
|
||||
self.data[mtu] = {POWER_WATT: power, UNIT_VOLT: voltage / 10}
|
||||
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||
@ -280,7 +281,7 @@ class WirelessTagBaseSensor(Entity):
|
||||
"""Return the state attributes."""
|
||||
return {
|
||||
ATTR_BATTERY_LEVEL: int(self._tag.battery_remaining * 100),
|
||||
ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}V",
|
||||
ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{UNIT_VOLT}",
|
||||
ATTR_TAG_SIGNAL_STRENGTH: f"{self._tag.signal_strength}dBm",
|
||||
ATTR_TAG_OUT_OF_RANGE: not self._tag.is_in_range,
|
||||
ATTR_TAG_POWER_CONSUMPTION: f"{self._tag.power_consumption:.2f}{UNIT_PERCENTAGE}",
|
||||
|
@ -345,6 +345,9 @@ ATTR_TEMPERATURE = "temperature"
|
||||
# Power units
|
||||
POWER_WATT = "W"
|
||||
|
||||
# Voltage units
|
||||
UNIT_VOLT = "V"
|
||||
|
||||
# Energy units
|
||||
ENERGY_KILO_WATT_HOUR = "kWh"
|
||||
ENERGY_WATT_HOUR = "Wh"
|
||||
|
@ -2,6 +2,7 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import UNIT_VOLT
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component
|
||||
@ -11,7 +12,7 @@ BASE_CFG = {
|
||||
"platform": "sma",
|
||||
"host": "1.1.1.1",
|
||||
"password": "",
|
||||
"custom": {"my_sensor": {"key": "1234567890123", "unit": "V"}},
|
||||
"custom": {"my_sensor": {"key": "1234567890123", "unit": UNIT_VOLT}},
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user