Drop UNIT_ prefix for constants (#34164)
* Drop UNIT_ prefix for VOLT * Drop UNIT_ prefix for DEGREE * Drop UNIT_ prefix for CONDUCTIVITY * Drop UNIT_ prefix for UV_INDEX * Run isortpull/34509/head
parent
fbde040f59
commit
ef9d9b17bd
|
@ -12,11 +12,11 @@ from homeassistant.const import (
|
|||
ATTR_NAME,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
CONF_API_KEY,
|
||||
DEGREE,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
POWER_WATT,
|
||||
SPEED_MILES_PER_HOUR,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -219,10 +219,10 @@ SENSOR_TYPES = {
|
|||
TYPE_TOTALRAININ: ("Lifetime Rain", "in", TYPE_SENSOR, None),
|
||||
TYPE_UV: ("uv", "Index", TYPE_SENSOR, None),
|
||||
TYPE_WEEKLYRAININ: ("Weekly Rain", "in", TYPE_SENSOR, None),
|
||||
TYPE_WINDDIR: ("Wind Dir", UNIT_DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDDIR_AVG10M: ("Wind Dir Avg 10m", UNIT_DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDDIR: ("Wind Dir", DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDDIR_AVG10M: ("Wind Dir Avg 10m", DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDDIR_AVG2M: ("Wind Dir Avg 2m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None),
|
||||
TYPE_WINDGUSTDIR: ("Gust Dir", UNIT_DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDGUSTDIR: ("Gust Dir", DEGREE, TYPE_SENSOR, None),
|
||||
TYPE_WINDGUSTMPH: ("Wind Gust", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None),
|
||||
TYPE_WINDSPDMPH_AVG10M: ("Wind Avg 10m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None),
|
||||
TYPE_WINDSPDMPH_AVG2M: ("Wind Avg 2m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None),
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -31,7 +31,7 @@ SENSOR_TYPES = {
|
|||
"badbatts": ["Bad Batteries", "", "mdi:information-outline"],
|
||||
"battdate": ["Battery Replaced", "", "mdi:calendar-clock"],
|
||||
"battstat": ["Battery Status", "", "mdi:information-outline"],
|
||||
"battv": ["Battery Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"battv": ["Battery Voltage", VOLT, "mdi:flash"],
|
||||
"bcharge": ["Battery", UNIT_PERCENTAGE, "mdi:battery"],
|
||||
"cable": ["Cable Type", "", "mdi:ethernet-cable"],
|
||||
"cumonbatt": ["Total Time on Battery", "", "mdi:timer"],
|
||||
|
@ -44,33 +44,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", UNIT_VOLT, "mdi:flash"],
|
||||
"hitrans": ["Transfer High", 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", FREQUENCY_HERTZ, "mdi:information-outline"],
|
||||
"linev": ["Input Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"linev": ["Input Voltage", VOLT, "mdi:flash"],
|
||||
"loadpct": ["Load", UNIT_PERCENTAGE, "mdi:gauge"],
|
||||
"loadapnt": ["Load Apparent Power", UNIT_PERCENTAGE, "mdi:gauge"],
|
||||
"lotrans": ["Transfer Low", UNIT_VOLT, "mdi:flash"],
|
||||
"lotrans": ["Transfer Low", VOLT, "mdi:flash"],
|
||||
"mandate": ["Manufacture Date", "", "mdi:calendar"],
|
||||
"masterupd": ["Master Update", "", "mdi:information-outline"],
|
||||
"maxlinev": ["Input Voltage High", UNIT_VOLT, "mdi:flash"],
|
||||
"maxlinev": ["Input Voltage High", VOLT, "mdi:flash"],
|
||||
"maxtime": ["Battery Timeout", "", "mdi:timer-off"],
|
||||
"mbattchg": ["Battery Shutdown", UNIT_PERCENTAGE, "mdi:battery-alert"],
|
||||
"minlinev": ["Input Voltage Low", UNIT_VOLT, "mdi:flash"],
|
||||
"minlinev": ["Input Voltage Low", VOLT, "mdi:flash"],
|
||||
"mintimel": ["Shutdown Time", "", "mdi:timer"],
|
||||
"model": ["Model", "", "mdi:information-outline"],
|
||||
"nombattv": ["Battery Nominal Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"nominv": ["Nominal Input Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"nomoutv": ["Nominal Output Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash"],
|
||||
"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"],
|
||||
"numxfers": ["Transfer Count", "", "mdi:counter"],
|
||||
"outcurnt": ["Output Current", "A", "mdi:flash"],
|
||||
"outputv": ["Output Voltage", UNIT_VOLT, "mdi:flash"],
|
||||
"outputv": ["Output Voltage", VOLT, "mdi:flash"],
|
||||
"reg1": ["Register 1 Fault", "", "mdi:information-outline"],
|
||||
"reg2": ["Register 2 Fault", "", "mdi:information-outline"],
|
||||
"reg3": ["Register 3 Fault", "", "mdi:information-outline"],
|
||||
|
@ -97,7 +97,7 @@ INFERRED_UNITS = {
|
|||
" Minutes": TIME_MINUTES,
|
||||
" Seconds": TIME_SECONDS,
|
||||
" Percent": UNIT_PERCENTAGE,
|
||||
" Volts": UNIT_VOLT,
|
||||
" Volts": VOLT,
|
||||
" Ampere": "A",
|
||||
" Volt-Ampere": "VA",
|
||||
" Watts": POWER_WATT,
|
||||
|
|
|
@ -3,7 +3,7 @@ import json
|
|||
import logging
|
||||
|
||||
from homeassistant.components import mqtt
|
||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, UNIT_DEGREE
|
||||
from homeassistant.const import DEGREE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import slugify
|
||||
|
@ -45,7 +45,7 @@ def discover_sensors(topic, payload):
|
|||
return (
|
||||
ArwnSensor("Wind Speed", "speed", unit, "mdi:speedometer"),
|
||||
ArwnSensor("Wind Gust", "gust", unit, "mdi:speedometer"),
|
||||
ArwnSensor("Wind Direction", "direction", UNIT_DEGREE, "mdi:compass"),
|
||||
ArwnSensor("Wind Direction", "direction", DEGREE, "mdi:compass"),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ from homeassistant.const import (
|
|||
CONF_LONGITUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
IRRADIATION_WATTS_PER_SQUARE_METER,
|
||||
LENGTH_KILOMETERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
TIME_HOURS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -77,7 +77,7 @@ SENSOR_TYPES = {
|
|||
"windspeed": ["Wind speed", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
||||
"windforce": ["Wind force", "Bft", "mdi:weather-windy"],
|
||||
"winddirection": ["Wind direction", None, "mdi:compass-outline"],
|
||||
"windazimuth": ["Wind direction azimuth", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth": ["Wind direction azimuth", DEGREE, "mdi:compass-outline"],
|
||||
"pressure": ["Pressure", "hPa", "mdi:gauge"],
|
||||
"visibility": ["Visibility", LENGTH_KILOMETERS, None],
|
||||
"windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"],
|
||||
|
@ -149,11 +149,11 @@ SENSOR_TYPES = {
|
|||
"winddirection_3d": ["Wind direction 3d", None, "mdi:compass-outline"],
|
||||
"winddirection_4d": ["Wind direction 4d", None, "mdi:compass-outline"],
|
||||
"winddirection_5d": ["Wind direction 5d", None, "mdi:compass-outline"],
|
||||
"windazimuth_1d": ["Wind direction azimuth 1d", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_2d": ["Wind direction azimuth 2d", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_3d": ["Wind direction azimuth 3d", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_4d": ["Wind direction azimuth 4d", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_5d": ["Wind direction azimuth 5d", UNIT_DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_1d": ["Wind direction azimuth 1d", DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_2d": ["Wind direction azimuth 2d", DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_3d": ["Wind direction azimuth 3d", DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_4d": ["Wind direction azimuth 4d", DEGREE, "mdi:compass-outline"],
|
||||
"windazimuth_5d": ["Wind direction azimuth 5d", DEGREE, "mdi:compass-outline"],
|
||||
"condition_1d": ["Condition 1d", None, None],
|
||||
"condition_2d": ["Condition 2d", None, None],
|
||||
"condition_3d": ["Condition 3d", None, None],
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.const import (
|
|||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
CONF_SCAN_INTERVAL,
|
||||
DEGREE,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_KILOMETERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
|
@ -23,9 +24,8 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
TIME_HOURS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UV_INDEX,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -89,11 +89,11 @@ SENSOR_TYPES = {
|
|||
],
|
||||
"nearest_storm_bearing": [
|
||||
"Nearest Storm Bearing",
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
"mdi:weather-lightning",
|
||||
["currently"],
|
||||
],
|
||||
|
@ -179,11 +179,11 @@ SENSOR_TYPES = {
|
|||
],
|
||||
"wind_bearing": [
|
||||
"Wind Bearing",
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
UNIT_DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
DEGREE,
|
||||
"mdi:compass",
|
||||
["currently", "hourly", "daily"],
|
||||
],
|
||||
|
@ -339,11 +339,11 @@ SENSOR_TYPES = {
|
|||
],
|
||||
"uv_index": [
|
||||
"UV Index",
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX,
|
||||
UV_INDEX,
|
||||
UV_INDEX,
|
||||
UV_INDEX,
|
||||
UV_INDEX,
|
||||
UV_INDEX,
|
||||
"mdi:weather-sunny",
|
||||
["currently", "hourly", "daily"],
|
||||
],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Definitions for DSMR Reader sensors added to MQTT."""
|
||||
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UNIT_VOLT, VOLUME_CUBIC_METERS
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, 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": UNIT_VOLT,
|
||||
"unit": VOLT,
|
||||
},
|
||||
"dsmr/reading/phase_voltage_l2": {
|
||||
"name": "Current voltage L2",
|
||||
"icon": "mdi:flash",
|
||||
"unit": UNIT_VOLT,
|
||||
"unit": VOLT,
|
||||
},
|
||||
"dsmr/reading/phase_voltage_l3": {
|
||||
"name": "Current voltage L3",
|
||||
"icon": "mdi:flash",
|
||||
"unit": UNIT_VOLT,
|
||||
"unit": VOLT,
|
||||
},
|
||||
"dsmr/consumption/gas/delivered": {
|
||||
"name": "Gas usage",
|
||||
|
|
|
@ -7,7 +7,7 @@ from elkm1_lib.const import (
|
|||
)
|
||||
from elkm1_lib.util import pretty_const, username
|
||||
|
||||
from homeassistant.const import UNIT_VOLT
|
||||
from homeassistant.const import VOLT
|
||||
|
||||
from . import ElkAttachedEntity, create_elk_entities
|
||||
from .const import DOMAIN
|
||||
|
@ -197,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 UNIT_VOLT
|
||||
return 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, UNIT_VOLT
|
||||
from homeassistant.const import CONF_DISPLAY_OPTIONS, CONF_NAME, TEMP_CELSIUS, 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", 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"],
|
||||
"voltage_0": ["voltage_0", VOLT, "mdi:flash"],
|
||||
"voltage_1": ["voltage_1", VOLT, "mdi:flash"],
|
||||
"voltage_2": ["voltage_2", VOLT, "mdi:flash"],
|
||||
"voltage_3": ["voltage_3", VOLT, "mdi:flash"],
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.const import (
|
|||
TIME_HOURS,
|
||||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -311,4 +311,4 @@ class VoltageSensor(GEMSensor):
|
|||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement for this sensor."""
|
||||
return UNIT_VOLT
|
||||
return VOLT
|
||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
POWER_WATT,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -60,17 +60,17 @@ INVERTER_SENSOR_TYPES = {
|
|||
"e_total",
|
||||
"power",
|
||||
),
|
||||
"inverter_voltage_input_1": ("Input 1 voltage", UNIT_VOLT, "vpv1", None),
|
||||
"inverter_voltage_input_1": ("Input 1 voltage", VOLT, "vpv1", None),
|
||||
"inverter_amperage_input_1": ("Input 1 Amperage", "A", "ipv1", None),
|
||||
"inverter_wattage_input_1": ("Input 1 Wattage", POWER_WATT, "ppv1", "power"),
|
||||
"inverter_voltage_input_2": ("Input 2 voltage", UNIT_VOLT, "vpv2", None),
|
||||
"inverter_voltage_input_2": ("Input 2 voltage", VOLT, "vpv2", None),
|
||||
"inverter_amperage_input_2": ("Input 2 Amperage", "A", "ipv2", None),
|
||||
"inverter_wattage_input_2": ("Input 2 Wattage", POWER_WATT, "ppv2", "power"),
|
||||
"inverter_voltage_input_3": ("Input 3 voltage", UNIT_VOLT, "vpv3", None),
|
||||
"inverter_voltage_input_3": ("Input 3 voltage", VOLT, "vpv3", None),
|
||||
"inverter_amperage_input_3": ("Input 3 Amperage", "A", "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", UNIT_VOLT, "vacr", None),
|
||||
"inverter_reactive_voltage": ("Reactive voltage", VOLT, "vacr", None),
|
||||
"inverter_inverter_reactive_amperage": ("Reactive amperage", "A", "iacr", None),
|
||||
"inverter_frequency": ("AC frequency", FREQUENCY_HERTZ, "fac", None),
|
||||
"inverter_current_wattage": ("Output power", POWER_WATT, "pac", "power"),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
DEGREE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_POWER,
|
||||
|
@ -11,9 +12,8 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
VOLUME_CUBIC_METERS,
|
||||
)
|
||||
|
||||
|
@ -43,7 +43,7 @@ HM_UNIT_HA_CAST = {
|
|||
"BRIGHTNESS": "#",
|
||||
"POWER": POWER_WATT,
|
||||
"CURRENT": "mA",
|
||||
"VOLTAGE": UNIT_VOLT,
|
||||
"VOLTAGE": VOLT,
|
||||
"ENERGY_COUNTER": ENERGY_WATT_HOUR,
|
||||
"GAS_POWER": VOLUME_CUBIC_METERS,
|
||||
"GAS_ENERGY_COUNTER": VOLUME_CUBIC_METERS,
|
||||
|
@ -55,8 +55,8 @@ HM_UNIT_HA_CAST = {
|
|||
"HIGHEST_ILLUMINATION": "lx",
|
||||
"RAIN_COUNTER": "mm",
|
||||
"WIND_SPEED": SPEED_KILOMETERS_PER_HOUR,
|
||||
"WIND_DIRECTION": UNIT_DEGREE,
|
||||
"WIND_DIRECTION_RANGE": UNIT_DEGREE,
|
||||
"WIND_DIRECTION": DEGREE,
|
||||
"WIND_DIRECTION_RANGE": DEGREE,
|
||||
"SUNSHINEDURATION": "#",
|
||||
"AIR_PRESSURE": "hPa",
|
||||
"FREQUENCY": FREQUENCY_HERTZ,
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import Callable
|
|||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
DEGREE,
|
||||
FREQUENCY_HERTZ,
|
||||
LENGTH_CENTIMETERS,
|
||||
LENGTH_KILOMETERS,
|
||||
|
@ -23,10 +24,9 @@ from homeassistant.const import (
|
|||
TIME_MONTHS,
|
||||
TIME_SECONDS,
|
||||
TIME_YEARS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UNIT_VOLT,
|
||||
UV_INDEX,
|
||||
VOLT,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
|
@ -46,7 +46,7 @@ UOM_FRIENDLY_NAME = {
|
|||
"10": TIME_DAYS,
|
||||
"12": "dB",
|
||||
"13": "dB A",
|
||||
"14": UNIT_DEGREE,
|
||||
"14": DEGREE,
|
||||
"16": "macroseismic",
|
||||
"17": TEMP_FAHRENHEIT,
|
||||
"18": "ft",
|
||||
|
@ -97,12 +97,12 @@ UOM_FRIENDLY_NAME = {
|
|||
"64": "shindo",
|
||||
"65": "SML",
|
||||
"69": "gal",
|
||||
"71": UNIT_UV_INDEX,
|
||||
"72": UNIT_VOLT,
|
||||
"71": UV_INDEX,
|
||||
"72": VOLT,
|
||||
"73": POWER_WATT,
|
||||
"74": f"{POWER_WATT}/m²",
|
||||
"75": "weekday",
|
||||
"76": f"Wind Direction ({UNIT_DEGREE})",
|
||||
"76": f"Wind Direction ({DEGREE})",
|
||||
"77": TIME_YEARS,
|
||||
"82": "mm",
|
||||
"83": LENGTH_KILOMETERS,
|
||||
|
@ -112,8 +112,8 @@ UOM_FRIENDLY_NAME = {
|
|||
"88": "Water activity",
|
||||
"89": "RPM",
|
||||
"90": FREQUENCY_HERTZ,
|
||||
"91": f"{UNIT_DEGREE} (Relative to North)",
|
||||
"92": f"{UNIT_DEGREE} (Relative to South)",
|
||||
"91": f"{DEGREE} (Relative to North)",
|
||||
"92": f"{DEGREE} (Relative to South)",
|
||||
}
|
||||
|
||||
UOM_TO_STATES = {
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TIME_SECONDS,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -17,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
SENSOR_TYPES = {
|
||||
"status": ["Charging Status", None],
|
||||
"temperature": ["Temperature", TEMP_CELSIUS],
|
||||
"voltage": ["Voltage", UNIT_VOLT],
|
||||
"voltage": ["Voltage", VOLT],
|
||||
"amps": ["Amps", "A"],
|
||||
"watts": ["Watts", POWER_WATT],
|
||||
"charge_time": ["Charge time", TIME_SECONDS],
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
from itertools import product
|
||||
|
||||
from homeassistant.const import (
|
||||
DEGREE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
TEMP_KELVIN,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
|
||||
DOMAIN = "lcn"
|
||||
|
@ -164,12 +164,12 @@ VAR_UNITS = [
|
|||
"PERCENT",
|
||||
"PPM",
|
||||
"VOLT",
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
"AMPERE",
|
||||
"AMP",
|
||||
"A",
|
||||
"DEGREE",
|
||||
UNIT_DEGREE,
|
||||
DEGREE,
|
||||
]
|
||||
|
||||
RELVARREF = ["CURRENT", "PROG"]
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
SPEED_MILES_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UV_INDEX,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -73,7 +73,7 @@ SENSOR_TYPES = {
|
|||
"wind_gust": ["Wind Gust", SPEED_MILES_PER_HOUR],
|
||||
"visibility": ["Visibility", None],
|
||||
"visibility_distance": ["Visibility Distance", LENGTH_KILOMETERS],
|
||||
"uv": ["UV", UNIT_UV_INDEX],
|
||||
"uv": ["UV", UV_INDEX],
|
||||
"precipitation": ["Probability of Precipitation", UNIT_PERCENTAGE],
|
||||
"humidity": ["Humidity", UNIT_PERCENTAGE],
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONDUCTIVITY,
|
||||
CONF_FORCE_UPDATE,
|
||||
CONF_MAC,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
|
@ -18,7 +19,6 @@ from homeassistant.const import (
|
|||
EVENT_HOMEASSISTANT_START,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_CONDUCTIVITY,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -55,7 +55,7 @@ SENSOR_TYPES = {
|
|||
"temperature": ["Temperature", TEMP_CELSIUS, "mdi:thermometer"],
|
||||
"light": ["Light intensity", "lx", "mdi:white-balance-sunny"],
|
||||
"moisture": ["Moisture", UNIT_PERCENTAGE, "mdi:water-percent"],
|
||||
"conductivity": ["Conductivity", UNIT_CONDUCTIVITY, "mdi:flash-circle"],
|
||||
"conductivity": ["Conductivity", CONDUCTIVITY, "mdi:flash-circle"],
|
||||
"battery": ["Battery", UNIT_PERCENTAGE, "mdi:battery-charging"],
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
from homeassistant.components import mysensors
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONDUCTIVITY,
|
||||
DEGREE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
LENGTH_METERS,
|
||||
|
@ -9,10 +11,8 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_CONDUCTIVITY,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
|
||||
SENSORS = {
|
||||
|
@ -26,7 +26,7 @@ SENSORS = {
|
|||
"V_RAINRATE": [None, "mdi:weather-rainy"],
|
||||
"V_WIND": [None, "mdi:weather-windy"],
|
||||
"V_GUST": [None, "mdi:weather-windy"],
|
||||
"V_DIRECTION": [UNIT_DEGREE, "mdi:compass"],
|
||||
"V_DIRECTION": [DEGREE, "mdi:compass"],
|
||||
"V_WEIGHT": [MASS_KILOGRAMS, "mdi:weight-kilogram"],
|
||||
"V_DISTANCE": [LENGTH_METERS, "mdi:ruler"],
|
||||
"V_IMPEDANCE": ["ohm", None],
|
||||
|
@ -40,11 +40,11 @@ SENSORS = {
|
|||
"S_VIBRATION": [FREQUENCY_HERTZ, None],
|
||||
"S_LIGHT_LEVEL": ["lx", "mdi:white-balance-sunny"],
|
||||
},
|
||||
"V_VOLTAGE": [UNIT_VOLT, "mdi:flash"],
|
||||
"V_VOLTAGE": [VOLT, "mdi:flash"],
|
||||
"V_CURRENT": ["A", "mdi:flash-auto"],
|
||||
"V_PH": ["pH", None],
|
||||
"V_ORP": ["mV", None],
|
||||
"V_EC": [UNIT_CONDUCTIVITY, None],
|
||||
"V_EC": [CONDUCTIVITY, None],
|
||||
"V_VAR": ["var", None],
|
||||
"V_VA": ["VA", None],
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
TIME_SECONDS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
|
||||
DOMAIN = "nut"
|
||||
|
@ -102,15 +102,10 @@ SENSOR_TYPES = {
|
|||
None,
|
||||
],
|
||||
"battery.charger.status": ["Charging Status", "", "mdi:information-outline", 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.voltage": ["Battery Voltage", VOLT, "mdi:flash", None],
|
||||
"battery.voltage.nominal": ["Nominal Battery Voltage", VOLT, "mdi:flash", None],
|
||||
"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],
|
||||
|
@ -150,16 +145,16 @@ SENSOR_TYPES = {
|
|||
"mdi:information-outline",
|
||||
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.low": ["Low Voltage Transfer", VOLT, "mdi:flash", None],
|
||||
"input.transfer.high": ["High Voltage Transfer", VOLT, "mdi:flash", None],
|
||||
"input.transfer.reason": [
|
||||
"Voltage Transfer Reason",
|
||||
"",
|
||||
"mdi:information-outline",
|
||||
None,
|
||||
],
|
||||
"input.voltage": ["Input Voltage", UNIT_VOLT, "mdi:flash", None],
|
||||
"input.voltage.nominal": ["Nominal Input Voltage", UNIT_VOLT, "mdi:flash", None],
|
||||
"input.voltage": ["Input Voltage", VOLT, "mdi:flash", None],
|
||||
"input.voltage.nominal": ["Nominal Input Voltage", VOLT, "mdi:flash", None],
|
||||
"input.frequency": ["Input Line Frequency", FREQUENCY_HERTZ, "mdi:flash", None],
|
||||
"input.frequency.nominal": [
|
||||
"Nominal Input Line Frequency",
|
||||
|
@ -175,8 +170,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", UNIT_VOLT, "mdi:flash", None],
|
||||
"output.voltage.nominal": ["Nominal Output Voltage", UNIT_VOLT, "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],
|
||||
"output.frequency.nominal": [
|
||||
"Nominal Output Frequency",
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -81,9 +81,9 @@ SENSOR_TYPES = {
|
|||
"counter_a": ["counter", "count"],
|
||||
"counter_b": ["counter", "count"],
|
||||
"HobbyBoard": ["none", "none"],
|
||||
"voltage": ["voltage", UNIT_VOLT],
|
||||
"voltage_VAD": ["voltage", UNIT_VOLT],
|
||||
"voltage_VDD": ["voltage", UNIT_VOLT],
|
||||
"voltage": ["voltage", VOLT],
|
||||
"voltage_VAD": ["voltage", VOLT],
|
||||
"voltage_VDD": ["voltage", VOLT],
|
||||
"current": ["current", "A"],
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for OpenUV sensors."""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import TIME_MINUTES, UNIT_UV_INDEX
|
||||
from homeassistant.const import TIME_MINUTES, UV_INDEX
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util.dt import as_local, parse_datetime
|
||||
|
||||
|
@ -43,9 +43,9 @@ UV_LEVEL_LOW = "Low"
|
|||
|
||||
SENSORS = {
|
||||
TYPE_CURRENT_OZONE_LEVEL: ("Current Ozone Level", "mdi:vector-triangle", "du"),
|
||||
TYPE_CURRENT_UV_INDEX: ("Current UV Index", "mdi:weather-sunny", UNIT_UV_INDEX),
|
||||
TYPE_CURRENT_UV_INDEX: ("Current UV Index", "mdi:weather-sunny", UV_INDEX),
|
||||
TYPE_CURRENT_UV_LEVEL: ("Current UV Level", "mdi:weather-sunny", None),
|
||||
TYPE_MAX_UV_INDEX: ("Max UV Index", "mdi:weather-sunny", UNIT_UV_INDEX),
|
||||
TYPE_MAX_UV_INDEX: ("Max UV Index", "mdi:weather-sunny", UV_INDEX),
|
||||
TYPE_SAFE_EXPOSURE_TIME_1: (
|
||||
"Skin Type 1 Safe Exposure Time",
|
||||
"mdi:timer",
|
||||
|
|
|
@ -12,10 +12,10 @@ from homeassistant.const import (
|
|||
CONF_API_KEY,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -37,7 +37,7 @@ SENSOR_TYPES = {
|
|||
"weather": ["Condition", None],
|
||||
"temperature": ["Temperature", None],
|
||||
"wind_speed": ["Wind speed", SPEED_METERS_PER_SECOND],
|
||||
"wind_bearing": ["Wind bearing", UNIT_DEGREE],
|
||||
"wind_bearing": ["Wind bearing", DEGREE],
|
||||
"humidity": ["Humidity", UNIT_PERCENTAGE],
|
||||
"pressure": ["Pressure", "mbar"],
|
||||
"clouds": ["Cloud coverage", UNIT_PERCENTAGE],
|
||||
|
|
|
@ -10,13 +10,13 @@ from homeassistant.components.recorder.util import execute, session_scope
|
|||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONDUCTIVITY,
|
||||
CONF_SENSORS,
|
||||
STATE_OK,
|
||||
STATE_PROBLEM,
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_CONDUCTIVITY,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -148,7 +148,7 @@ class Plant(Entity):
|
|||
"max": CONF_MAX_MOISTURE,
|
||||
},
|
||||
READING_CONDUCTIVITY: {
|
||||
ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY,
|
||||
ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY,
|
||||
"min": CONF_MIN_CONDUCTIVITY,
|
||||
"max": CONF_MAX_CONDUCTIVITY,
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UV_INDEX,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -58,7 +58,7 @@ DATA_TYPES = OrderedDict(
|
|||
("Sound", ""),
|
||||
("Sensor Status", ""),
|
||||
("Counter value", ""),
|
||||
("UV", UNIT_UV_INDEX),
|
||||
("UV", UV_INDEX),
|
||||
("Humidity status", ""),
|
||||
("Forecast", ""),
|
||||
("Forecast numeric", ""),
|
||||
|
|
|
@ -3,11 +3,11 @@ from datetime import timedelta
|
|||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
DEGREE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
VOLUME_CUBIC_METERS,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -27,7 +27,7 @@ SENSOR_TYPES = {
|
|||
"active_power",
|
||||
],
|
||||
"current": ["Current", "mdi:gauge", "local", "A", "current"],
|
||||
"voltage": ["Voltage", "mdi:gauge", "local", UNIT_VOLT, "voltage"],
|
||||
"voltage": ["Voltage", "mdi:gauge", "local", VOLT, "voltage"],
|
||||
"active_cosfi": [
|
||||
"Power Factor",
|
||||
"mdi:gauge",
|
||||
|
@ -74,7 +74,7 @@ SENSOR_TYPES = {
|
|||
"Water Sensor Temperature",
|
||||
"mdi:temperature-celsius",
|
||||
"water",
|
||||
UNIT_DEGREE,
|
||||
DEGREE,
|
||||
"temperature",
|
||||
],
|
||||
"water_sensor_humidity": [
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
|
||||
from . import SmartThingsEntity
|
||||
|
@ -234,7 +234,7 @@ CAPABILITY_TO_SENSORS = {
|
|||
Map(Attribute.ultraviolet_index, "Ultraviolet Index", None, None)
|
||||
],
|
||||
Capability.voltage_measurement: [
|
||||
Map(Attribute.voltage, "Voltage Measurement", UNIT_VOLT, None)
|
||||
Map(Attribute.voltage, "Voltage Measurement", VOLT, None)
|
||||
],
|
||||
Capability.washer_mode: [Map(Attribute.washer_mode, "Washer Mode", None, None)],
|
||||
Capability.washer_operating_state: [
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -42,20 +42,8 @@ INVERTER_MODES = (
|
|||
# Supported sensor types:
|
||||
# Key: ['json_key', 'name', unit, icon, attribute name]
|
||||
SENSOR_TYPES = {
|
||||
"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_AC_voltage": ["gridvoltage", "Grid Voltage", VOLT, "mdi:current-ac", None],
|
||||
"current_DC_voltage": ["dcvoltage", "DC Voltage", VOLT, "mdi:current-dc", None],
|
||||
"current_frequency": [
|
||||
"gridfrequency",
|
||||
"Grid Frequency",
|
||||
|
@ -136,7 +124,7 @@ SENSOR_TYPES = {
|
|||
"optimizer_voltage": [
|
||||
"optimizervoltage",
|
||||
"Average Optimizer Voltage",
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
"mdi:solar-panel",
|
||||
None,
|
||||
],
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
"""Constants for the Solar-Log integration."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT, UNIT_PERCENTAGE, VOLT
|
||||
|
||||
DOMAIN = "solarlog"
|
||||
|
||||
|
@ -22,8 +17,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", UNIT_VOLT, "mdi:flash"],
|
||||
"voltage_dc": ["voltageDC", "voltage DC", UNIT_VOLT, "mdi:flash"],
|
||||
"voltage_ac": ["voltageAC", "voltage AC", VOLT, "mdi:flash"],
|
||||
"voltage_dc": ["voltageDC", "voltage DC", 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, UNIT_VOLT
|
||||
from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE, 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, UNIT_VOLT, None],
|
||||
"battery": ["Battery", None, 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, UNIT_VOLT
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT, 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, UNIT_VOLT))
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, 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", UNIT_VOLT: "voltage"}
|
||||
units = {POWER_WATT: "power", 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, UNIT_VOLT: voltage / 10}
|
||||
self.data[mtu] = {POWER_WATT: power, VOLT: voltage / 10}
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
TIME_HOURS,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_UV_INDEX,
|
||||
UV_INDEX,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -45,7 +45,7 @@ SENSOR_TYPES = {
|
|||
SENSOR_TYPE_WINDDIRECTION: ["Wind direction", "", "", None],
|
||||
SENSOR_TYPE_WINDAVERAGE: ["Wind average", SPEED_METERS_PER_SECOND, "", None],
|
||||
SENSOR_TYPE_WINDGUST: ["Wind gust", SPEED_METERS_PER_SECOND, "", None],
|
||||
SENSOR_TYPE_UV: ["UV", UNIT_UV_INDEX, "", None],
|
||||
SENSOR_TYPE_UV: ["UV", UV_INDEX, "", None],
|
||||
SENSOR_TYPE_WATT: ["Power", POWER_WATT, "", None],
|
||||
SENSOR_TYPE_LUMINANCE: ["Luminance", "lx", None, DEVICE_CLASS_ILLUMINANCE],
|
||||
SENSOR_TYPE_DEW_POINT: ["Dew Point", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE],
|
||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_EMAIL, CONF_NAME, UNIT_DEGREE
|
||||
from homeassistant.const import CONF_EMAIL, CONF_NAME, DEGREE
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -91,7 +91,7 @@ class TorqueReceiveDataView(HomeAssistantView):
|
|||
|
||||
temp_unit = data[key]
|
||||
if "\\xC2\\xB0" in temp_unit:
|
||||
temp_unit = temp_unit.replace("\\xC2\\xB0", UNIT_DEGREE)
|
||||
temp_unit = temp_unit.replace("\\xC2\\xB0", DEGREE)
|
||||
|
||||
units[pid] = temp_unit
|
||||
elif is_value:
|
||||
|
|
|
@ -14,11 +14,11 @@ from homeassistant.const import (
|
|||
CONF_API_KEY,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -62,7 +62,7 @@ SENSOR_TYPES = {
|
|||
],
|
||||
"wind_direction": [
|
||||
"Wind direction",
|
||||
UNIT_DEGREE,
|
||||
DEGREE,
|
||||
"winddirection",
|
||||
"mdi:flag-triangle",
|
||||
None,
|
||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
|||
|
||||
import pywink
|
||||
|
||||
from homeassistant.const import TEMP_CELSIUS, UNIT_DEGREE
|
||||
from homeassistant.const import DEGREE, TEMP_CELSIUS
|
||||
|
||||
from . import DOMAIN, WinkDevice
|
||||
|
||||
|
@ -48,7 +48,7 @@ class WinkSensorDevice(WinkDevice):
|
|||
"""Initialize the Wink device."""
|
||||
super().__init__(wink, hass)
|
||||
self.capability = self.wink.capability()
|
||||
if self.wink.unit() == UNIT_DEGREE:
|
||||
if self.wink.unit() == DEGREE:
|
||||
self._unit_of_measurement = TEMP_CELSIUS
|
||||
else:
|
||||
self._unit_of_measurement = self.wink.unit()
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
UNIT_PERCENTAGE,
|
||||
UNIT_VOLT,
|
||||
VOLT,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||
|
@ -281,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}{UNIT_VOLT}",
|
||||
ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{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}",
|
||||
|
|
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
|||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
DEGREE,
|
||||
IRRADIATION_WATTS_PER_SQUARE_METER,
|
||||
LENGTH_FEET,
|
||||
LENGTH_INCHES,
|
||||
|
@ -26,7 +27,6 @@ from homeassistant.const import (
|
|||
SPEED_MILES_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
|
@ -457,7 +457,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
"weather": WUCurrentConditionsSensorConfig("Weather Summary", "weather", None),
|
||||
"wind_degrees": WUCurrentConditionsSensorConfig(
|
||||
"Wind Degrees", "wind_degrees", "mdi:weather-windy", UNIT_DEGREE
|
||||
"Wind Degrees", "wind_degrees", "mdi:weather-windy", DEGREE
|
||||
),
|
||||
"wind_dir": WUCurrentConditionsSensorConfig(
|
||||
"Wind Direction", "wind_dir", "mdi:weather-windy"
|
||||
|
|
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
|||
CONF_LONGITUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
|
@ -24,7 +25,6 @@ from homeassistant.const import (
|
|||
PRESSURE_HPA,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -48,7 +48,7 @@ SENSOR_TYPES = {
|
|||
"windSpeed": ["Wind speed", SPEED_METERS_PER_SECOND, None],
|
||||
"windGust": ["Wind gust", SPEED_METERS_PER_SECOND, None],
|
||||
"pressure": ["Pressure", PRESSURE_HPA, DEVICE_CLASS_PRESSURE],
|
||||
"windDirection": ["Wind direction", UNIT_DEGREE, None],
|
||||
"windDirection": ["Wind direction", DEGREE, None],
|
||||
"humidity": ["Humidity", UNIT_PERCENTAGE, DEVICE_CLASS_HUMIDITY],
|
||||
"fog": ["Fog", UNIT_PERCENTAGE, None],
|
||||
"cloudiness": ["Cloudiness", UNIT_PERCENTAGE, None],
|
||||
|
|
|
@ -17,10 +17,10 @@ from homeassistant.const import (
|
|||
CONF_LONGITUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
LENGTH_METERS,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UNIT_DEGREE,
|
||||
UNIT_PERCENTAGE,
|
||||
__version__,
|
||||
)
|
||||
|
@ -50,14 +50,14 @@ SENSOR_TYPES = {
|
|||
f"WG {SPEED_KILOMETERS_PER_HOUR}",
|
||||
float,
|
||||
),
|
||||
"wind_bearing": ("Wind Bearing", UNIT_DEGREE, f"WR {UNIT_DEGREE}", int),
|
||||
"wind_bearing": ("Wind Bearing", DEGREE, f"WR {DEGREE}", int),
|
||||
"wind_max_speed": (
|
||||
"Top Wind Speed",
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
f"WSG {SPEED_KILOMETERS_PER_HOUR}",
|
||||
float,
|
||||
),
|
||||
"wind_max_bearing": ("Top Wind Bearing", UNIT_DEGREE, f"WSR {UNIT_DEGREE}", int),
|
||||
"wind_max_bearing": ("Top Wind Bearing", DEGREE, f"WSR {DEGREE}", int),
|
||||
"sun_last_hour": ("Sun Last Hour", UNIT_PERCENTAGE, f"SO {UNIT_PERCENTAGE}", int),
|
||||
"temperature": ("Temperature", TEMP_CELSIUS, f"T {TEMP_CELSIUS}", float),
|
||||
"precipitation": ("Precipitation", "l/m²", "N l/m²", float),
|
||||
|
|
|
@ -346,19 +346,19 @@ ATTR_TEMPERATURE = "temperature"
|
|||
POWER_WATT = "W"
|
||||
|
||||
# Voltage units
|
||||
UNIT_VOLT = "V"
|
||||
VOLT = "V"
|
||||
|
||||
# Energy units
|
||||
ENERGY_WATT_HOUR = f"{POWER_WATT}h"
|
||||
ENERGY_KILO_WATT_HOUR = f"k{ENERGY_WATT_HOUR}"
|
||||
|
||||
# Degree units
|
||||
UNIT_DEGREE = "°"
|
||||
DEGREE = "°"
|
||||
|
||||
# Temperature units
|
||||
TEMP_CELSIUS = f"{UNIT_DEGREE}C"
|
||||
TEMP_FAHRENHEIT = f"{UNIT_DEGREE}F"
|
||||
TEMP_KELVIN = f"{UNIT_DEGREE}K"
|
||||
TEMP_CELSIUS = f"{DEGREE}C"
|
||||
TEMP_FAHRENHEIT = f"{DEGREE}F"
|
||||
TEMP_KELVIN = f"{DEGREE}K"
|
||||
|
||||
# Time units
|
||||
TIME_MICROSECONDS = "μs"
|
||||
|
@ -414,10 +414,10 @@ MASS_OUNCES: str = "oz"
|
|||
MASS_POUNDS: str = "lb"
|
||||
|
||||
# Conductivity units
|
||||
UNIT_CONDUCTIVITY: str = f"µS/{LENGTH_CENTIMETERS}"
|
||||
CONDUCTIVITY: str = f"µS/{LENGTH_CENTIMETERS}"
|
||||
|
||||
# UV Index units
|
||||
UNIT_UV_INDEX: str = "UV index"
|
||||
UV_INDEX: str = "UV index"
|
||||
|
||||
# Percentage units
|
||||
UNIT_PERCENTAGE = "%"
|
||||
|
|
|
@ -9,11 +9,11 @@ from homeassistant.components import recorder
|
|||
import homeassistant.components.plant as plant
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONDUCTIVITY,
|
||||
STATE_OK,
|
||||
STATE_PROBLEM,
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN,
|
||||
UNIT_CONDUCTIVITY,
|
||||
)
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
|
@ -95,7 +95,7 @@ class TestPlant(unittest.TestCase):
|
|||
def test_initial_states(self):
|
||||
"""Test plant initialises attributes if sensor already exists."""
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY}
|
||||
MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY}
|
||||
)
|
||||
plant_name = "some_plant"
|
||||
assert setup_component(
|
||||
|
@ -115,7 +115,7 @@ class TestPlant(unittest.TestCase):
|
|||
self.hass, plant.DOMAIN, {plant.DOMAIN: {plant_name: GOOD_CONFIG}}
|
||||
)
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY}
|
||||
MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
|
@ -132,9 +132,7 @@ class TestPlant(unittest.TestCase):
|
|||
self.hass, plant.DOMAIN, {plant.DOMAIN: {plant_name: GOOD_CONFIG}}
|
||||
)
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY,
|
||||
STATE_UNAVAILABLE,
|
||||
{ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY},
|
||||
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
|
@ -151,16 +149,14 @@ class TestPlant(unittest.TestCase):
|
|||
self.hass, plant.DOMAIN, {plant.DOMAIN: {plant_name: GOOD_CONFIG}}
|
||||
)
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY, 42, {ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY}
|
||||
MOISTURE_ENTITY, 42, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert state.state == STATE_OK
|
||||
assert state.attributes[plant.READING_MOISTURE] == 42
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY,
|
||||
STATE_UNAVAILABLE,
|
||||
{ATTR_UNIT_OF_MEASUREMENT: UNIT_CONDUCTIVITY},
|
||||
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
|
|
|
@ -7,9 +7,9 @@ from homeassistant.components.demo.sensor import DemoSensor
|
|||
import homeassistant.components.prometheus as prometheus
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
DEGREE,
|
||||
DEVICE_CLASS_POWER,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UNIT_DEGREE,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -48,7 +48,7 @@ async def prometheus_client(loop, hass, hass_client):
|
|||
sensor3.entity_id = "sensor.electricity_price"
|
||||
await sensor3.async_update_ha_state()
|
||||
|
||||
sensor4 = DemoSensor(None, "Wind Direction", 25, None, UNIT_DEGREE, None)
|
||||
sensor4 = DemoSensor(None, "Wind Direction", 25, None, DEGREE, None)
|
||||
sensor4.hass = hass
|
||||
sensor4.entity_id = "sensor.wind_direction"
|
||||
await sensor4.async_update_ha_state()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import logging
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.const import UNIT_VOLT
|
||||
from homeassistant.const import VOLT
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component
|
||||
|
@ -12,7 +12,7 @@ BASE_CFG = {
|
|||
"platform": "sma",
|
||||
"host": "1.1.1.1",
|
||||
"password": "",
|
||||
"custom": {"my_sensor": {"key": "1234567890123", "unit": UNIT_VOLT}},
|
||||
"custom": {"my_sensor": {"key": "1234567890123", "unit": VOLT}},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import datetime
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.const import SPEED_METERS_PER_SECOND, UNIT_DEGREE, UNIT_PERCENTAGE
|
||||
from homeassistant.const import DEGREE, SPEED_METERS_PER_SECOND, UNIT_PERCENTAGE
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import assert_setup_component, load_fixture
|
||||
|
@ -59,7 +59,7 @@ async def test_custom_setup(hass, aioclient_mock):
|
|||
assert state.state == "1009.3"
|
||||
|
||||
state = hass.states.get("sensor.yr_wind_direction")
|
||||
assert state.attributes.get("unit_of_measurement") == UNIT_DEGREE
|
||||
assert state.attributes.get("unit_of_measurement") == DEGREE
|
||||
assert state.state == "103.6"
|
||||
|
||||
state = hass.states.get("sensor.yr_humidity")
|
||||
|
@ -105,7 +105,7 @@ async def test_forecast_setup(hass, aioclient_mock):
|
|||
assert state.state == "1008.3"
|
||||
|
||||
state = hass.states.get("sensor.yr_wind_direction")
|
||||
assert state.attributes.get("unit_of_measurement") == UNIT_DEGREE
|
||||
assert state.attributes.get("unit_of_measurement") == DEGREE
|
||||
assert state.state == "148.9"
|
||||
|
||||
state = hass.states.get("sensor.yr_humidity")
|
||||
|
|
Loading…
Reference in New Issue