Adjust some units (#852)

* Adjust some units

Fixes https://github.com/esphome/issues/issues/843

* Lint
This commit is contained in:
Otto Winter 2019-11-12 19:04:39 +01:00
parent 7c0d777173
commit a5b49dbfa6
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
4 changed files with 9 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import esphome.config_validation as cv
from esphome.components import sensor, spi from esphome.components import sensor, spi
from esphome.const import \ from esphome.const import \
CONF_ID, CONF_VOLTAGE, CONF_CURRENT, CONF_POWER, CONF_FREQUENCY, \ 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_A = 'phase_a'
CONF_PHASE_B = 'phase_b' 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_A): ATM90E32_PHASE_SCHEMA,
cv.Optional(CONF_PHASE_B): ATM90E32_PHASE_SCHEMA, cv.Optional(CONF_PHASE_B): ATM90E32_PHASE_SCHEMA,
cv.Optional(CONF_PHASE_C): 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.Required(CONF_LINE_FREQUENCY): cv.enum(LINE_FREQS, upper=True),
cv.Optional(CONF_GAIN_PGA, default='2X'): cv.enum(PGA_GAINS, 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) }).extend(cv.polling_component_schema('60s')).extend(spi.SPI_DEVICE_SCHEMA)

View file

@ -3,7 +3,7 @@ import esphome.config_validation as cv
from esphome.components import sensor, modbus from esphome.components import sensor, modbus
from esphome.const import CONF_CURRENT, CONF_ID, CONF_POWER, CONF_VOLTAGE, \ from esphome.const import CONF_CURRENT, CONF_ID, CONF_POWER, CONF_VOLTAGE, \
CONF_FREQUENCY, UNIT_VOLT, ICON_FLASH, UNIT_AMPERE, UNIT_WATT, UNIT_EMPTY, \ 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'] 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_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_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_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), 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)) }).extend(cv.polling_component_schema('60s')).extend(modbus.modbus_device_schema(0x01))

View file

@ -4,7 +4,7 @@ from esphome import pins
from esphome.components import sensor from esphome.components import sensor
from esphome.const import CONF_ID, CONF_WIND_SPEED, CONF_PIN, \ from esphome.const import CONF_ID, CONF_WIND_SPEED, CONF_PIN, \
CONF_WIND_DIRECTION_DEGREES, UNIT_KILOMETER_PER_HOUR, \ 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') tx20_ns = cg.esphome_ns.namespace('tx20')
Tx20Component = tx20_ns.class_('Tx20Component', cg.Component) Tx20Component = tx20_ns.class_('Tx20Component', cg.Component)
@ -14,7 +14,7 @@ CONFIG_SCHEMA = cv.Schema({
cv.Optional(CONF_WIND_SPEED): cv.Optional(CONF_WIND_SPEED):
sensor.sensor_schema(UNIT_KILOMETER_PER_HOUR, ICON_WEATHER_WINDY, 1), sensor.sensor_schema(UNIT_KILOMETER_PER_HOUR, ICON_WEATHER_WINDY, 1),
cv.Optional(CONF_WIND_DIRECTION_DEGREES): 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, cv.Required(CONF_PIN): cv.All(pins.internal_gpio_input_pin_schema,
pins.validate_has_interrupt), pins.validate_has_interrupt),
}).extend(cv.COMPONENT_SCHEMA) }).extend(cv.COMPONENT_SCHEMA)

View file

@ -520,7 +520,7 @@ UNIT_DEGREE_PER_SECOND = u'°/s'
UNIT_DEGREES = u'°' UNIT_DEGREES = u'°'
UNIT_EMPTY = '' UNIT_EMPTY = ''
UNIT_HECTOPASCAL = 'hPa' UNIT_HECTOPASCAL = 'hPa'
UNIT_HZ = 'hz' UNIT_HERTZ = 'hz'
UNIT_KELVIN = 'K' UNIT_KELVIN = 'K'
UNIT_KILOMETER = 'km' UNIT_KILOMETER = 'km'
UNIT_KILOMETER_PER_HOUR = 'km/h' UNIT_KILOMETER_PER_HOUR = 'km/h'
@ -538,6 +538,8 @@ UNIT_PULSES_PER_MINUTE = 'pulses/min'
UNIT_SECOND = 's' UNIT_SECOND = 's'
UNIT_STEPS = 'steps' UNIT_STEPS = 'steps'
UNIT_VOLT = 'V' UNIT_VOLT = 'V'
UNIT_VOLT_AMPS = 'VA'
UNIT_VOLT_AMPS_REACTIVE = 'VAR'
UNIT_WATT = 'W' UNIT_WATT = 'W'
DEVICE_CLASS_CONNECTIVITY = 'connectivity' DEVICE_CLASS_CONNECTIVITY = 'connectivity'