Add and use percentage constant (#32094)

* Add and use percentage constant

* Fix pylint error and broken test
This commit is contained in:
springstan 2020-02-28 20:46:48 +01:00 committed by GitHub
parent c7f128f286
commit f1a0ca7cd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 735 additions and 459 deletions

View file

@ -4,7 +4,12 @@ import logging
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_MONITORED_CONDITIONS, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.const import (
CONF_MONITORED_CONDITIONS,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UNIT_PERCENTAGE,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
@ -25,7 +30,7 @@ SENSOR_TYPES = [
# Sensor units - these do not currently align with the API documentation
SENSOR_UNITS_IMPERIAL = {
"Temperature": TEMP_FAHRENHEIT,
"Humidity": "%",
"Humidity": UNIT_PERCENTAGE,
"Pressure": "inHg",
"Luminance": "cd/m²",
"Voltage": "mV",
@ -34,7 +39,7 @@ SENSOR_UNITS_IMPERIAL = {
# Metric units
SENSOR_UNITS_METRIC = {
"Temperature": TEMP_CELSIUS,
"Humidity": "%",
"Humidity": UNIT_PERCENTAGE,
"Pressure": "mbar",
"Luminance": "cd/m²",
"Voltage": "mV",