From a5b49dbfa66b1da90fabb0295321f10b4ea75a2f Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 12 Nov 2019 19:04:39 +0100 Subject: [PATCH] Adjust some units (#852) * Adjust some units Fixes https://github.com/esphome/issues/issues/843 * Lint --- esphome/components/atm90e32/sensor.py | 4 ++-- esphome/components/pzemac/sensor.py | 4 ++-- esphome/components/tx20/sensor.py | 4 ++-- esphome/const.py | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/esphome/components/atm90e32/sensor.py b/esphome/components/atm90e32/sensor.py index 7b62740f8e..51bda3292a 100644 --- a/esphome/components/atm90e32/sensor.py +++ b/esphome/components/atm90e32/sensor.py @@ -3,7 +3,7 @@ import esphome.config_validation as cv from esphome.components import sensor, spi from esphome.const import \ CONF_ID, CONF_VOLTAGE, CONF_CURRENT, CONF_POWER, CONF_FREQUENCY, \ - ICON_FLASH, UNIT_HZ, UNIT_VOLT, UNIT_AMPERE, UNIT_WATT + ICON_FLASH, UNIT_VOLT, UNIT_AMPERE, UNIT_WATT, UNIT_HERTZ, ICON_CURRENT_AC CONF_PHASE_A = 'phase_a' CONF_PHASE_B = 'phase_b' @@ -39,7 +39,7 @@ CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_PHASE_A): ATM90E32_PHASE_SCHEMA, cv.Optional(CONF_PHASE_B): ATM90E32_PHASE_SCHEMA, cv.Optional(CONF_PHASE_C): ATM90E32_PHASE_SCHEMA, - cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(UNIT_HZ, ICON_FLASH, 1), + cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(UNIT_HERTZ, ICON_CURRENT_AC, 1), cv.Required(CONF_LINE_FREQUENCY): cv.enum(LINE_FREQS, upper=True), cv.Optional(CONF_GAIN_PGA, default='2X'): cv.enum(PGA_GAINS, upper=True), }).extend(cv.polling_component_schema('60s')).extend(spi.SPI_DEVICE_SCHEMA) diff --git a/esphome/components/pzemac/sensor.py b/esphome/components/pzemac/sensor.py index 35d8069767..54eb01e085 100644 --- a/esphome/components/pzemac/sensor.py +++ b/esphome/components/pzemac/sensor.py @@ -3,7 +3,7 @@ import esphome.config_validation as cv from esphome.components import sensor, modbus from esphome.const import CONF_CURRENT, CONF_ID, CONF_POWER, CONF_VOLTAGE, \ CONF_FREQUENCY, UNIT_VOLT, ICON_FLASH, UNIT_AMPERE, UNIT_WATT, UNIT_EMPTY, \ - ICON_POWER, CONF_POWER_FACTOR, ICON_CURRENT_AC + ICON_POWER, CONF_POWER_FACTOR, ICON_CURRENT_AC, UNIT_HERTZ AUTO_LOAD = ['modbus'] @@ -15,7 +15,7 @@ CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_VOLTAGE): sensor.sensor_schema(UNIT_VOLT, ICON_FLASH, 1), cv.Optional(CONF_CURRENT): sensor.sensor_schema(UNIT_AMPERE, ICON_CURRENT_AC, 3), cv.Optional(CONF_POWER): sensor.sensor_schema(UNIT_WATT, ICON_POWER, 1), - cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(UNIT_EMPTY, ICON_CURRENT_AC, 1), + cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(UNIT_HERTZ, ICON_CURRENT_AC, 1), cv.Optional(CONF_POWER_FACTOR): sensor.sensor_schema(UNIT_EMPTY, ICON_FLASH, 2), }).extend(cv.polling_component_schema('60s')).extend(modbus.modbus_device_schema(0x01)) diff --git a/esphome/components/tx20/sensor.py b/esphome/components/tx20/sensor.py index daa6677196..3547cdf50c 100644 --- a/esphome/components/tx20/sensor.py +++ b/esphome/components/tx20/sensor.py @@ -4,7 +4,7 @@ from esphome import pins from esphome.components import sensor from esphome.const import CONF_ID, CONF_WIND_SPEED, CONF_PIN, \ CONF_WIND_DIRECTION_DEGREES, UNIT_KILOMETER_PER_HOUR, \ - UNIT_EMPTY, ICON_WEATHER_WINDY, ICON_SIGN_DIRECTION + ICON_WEATHER_WINDY, ICON_SIGN_DIRECTION, UNIT_DEGREES tx20_ns = cg.esphome_ns.namespace('tx20') Tx20Component = tx20_ns.class_('Tx20Component', cg.Component) @@ -14,7 +14,7 @@ CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_WIND_SPEED): sensor.sensor_schema(UNIT_KILOMETER_PER_HOUR, ICON_WEATHER_WINDY, 1), cv.Optional(CONF_WIND_DIRECTION_DEGREES): - sensor.sensor_schema(UNIT_EMPTY, ICON_SIGN_DIRECTION, 1), + sensor.sensor_schema(UNIT_DEGREES, ICON_SIGN_DIRECTION, 1), cv.Required(CONF_PIN): cv.All(pins.internal_gpio_input_pin_schema, pins.validate_has_interrupt), }).extend(cv.COMPONENT_SCHEMA) diff --git a/esphome/const.py b/esphome/const.py index 2069e51c0c..7298a4dca9 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -520,7 +520,7 @@ UNIT_DEGREE_PER_SECOND = u'°/s' UNIT_DEGREES = u'°' UNIT_EMPTY = '' UNIT_HECTOPASCAL = 'hPa' -UNIT_HZ = 'hz' +UNIT_HERTZ = 'hz' UNIT_KELVIN = 'K' UNIT_KILOMETER = 'km' UNIT_KILOMETER_PER_HOUR = 'km/h' @@ -538,6 +538,8 @@ UNIT_PULSES_PER_MINUTE = 'pulses/min' UNIT_SECOND = 's' UNIT_STEPS = 'steps' UNIT_VOLT = 'V' +UNIT_VOLT_AMPS = 'VA' +UNIT_VOLT_AMPS_REACTIVE = 'VAR' UNIT_WATT = 'W' DEVICE_CLASS_CONNECTIVITY = 'connectivity'