mirror of https://github.com/home-assistant/core
Use percentage constant in more integrations (#40165)
This commit is contained in:
parent
711ca6aff5
commit
7de1fe7416
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
|||
ELECTRICAL_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
VOLT,
|
||||
|
@ -231,7 +232,7 @@ STORAGE_SENSOR_TYPES = {
|
|||
),
|
||||
"storage_battery_percentage": (
|
||||
"Battery percentage",
|
||||
"%",
|
||||
PERCENTAGE,
|
||||
"capacity",
|
||||
{"device_class": DEVICE_CLASS_BATTERY},
|
||||
),
|
||||
|
@ -339,7 +340,7 @@ STORAGE_SENSOR_TYPES = {
|
|||
),
|
||||
"storage_load_percentage": (
|
||||
"Load percentage",
|
||||
"%",
|
||||
PERCENTAGE,
|
||||
"loadPercent",
|
||||
{"device_class": DEVICE_CLASS_BATTERY, "round": 2},
|
||||
),
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
CONF_SWITCHES,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
PERCENTAGE,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import load_platform
|
||||
|
@ -31,7 +32,6 @@ CONF_DST_UNIT = "unit"
|
|||
DEFAULT_INVERT_LOGIC = False
|
||||
DEFAULT_SRC_RANGE = [0, 1024]
|
||||
DEFAULT_DST_RANGE = [0.0, 100.0]
|
||||
DEFAULT_UNIT = "%"
|
||||
DEFAULT_DEV = [f"/dev/ttyACM{i}" for i in range(10)]
|
||||
|
||||
PORT_RANGE = range(1, 8) # ports 0-7 are ADC capable
|
||||
|
@ -82,7 +82,7 @@ ADC_SCHEMA = vol.Schema(
|
|||
vol.Required(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_SRC_RANGE, default=DEFAULT_SRC_RANGE): int_range,
|
||||
vol.Optional(CONF_DST_RANGE, default=DEFAULT_DST_RANGE): float_range,
|
||||
vol.Optional(CONF_DST_UNIT, default=DEFAULT_UNIT): cv.string,
|
||||
vol.Optional(CONF_DST_UNIT, default=PERCENTAGE): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ async def test_5e850i(hass):
|
|||
"device_class": "battery",
|
||||
"friendly_name": "Ups1 Battery Charge",
|
||||
"state": "Online",
|
||||
"unit_of_measurement": "%",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -97,7 +97,7 @@ async def test_5e650i(hass):
|
|||
"device_class": "battery",
|
||||
"friendly_name": "Ups1 Battery Charge",
|
||||
"state": "Online Battery Charging",
|
||||
"unit_of_measurement": "%",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -125,7 +125,7 @@ async def test_backupsses600m1(hass):
|
|||
"device_class": "battery",
|
||||
"friendly_name": "Ups1 Battery Charge",
|
||||
"state": "Online",
|
||||
"unit_of_measurement": "%",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
|
|
@ -22,7 +22,7 @@ UNITS_OF_MEASUREMENT = {
|
|||
sensor.DEVICE_CLASS_POWER: "kW", # power (W/kW)
|
||||
sensor.DEVICE_CLASS_CURRENT: "A", # current (A)
|
||||
sensor.DEVICE_CLASS_ENERGY: "kWh", # energy (Wh/kWh)
|
||||
sensor.DEVICE_CLASS_POWER_FACTOR: "%", # power factor (no unit, min: -1.0, max: 1.0)
|
||||
sensor.DEVICE_CLASS_POWER_FACTOR: PERCENTAGE, # power factor (no unit, min: -1.0, max: 1.0)
|
||||
sensor.DEVICE_CLASS_VOLTAGE: "V", # voltage (V)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue