mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Adjust some units (#852)
* Adjust some units Fixes https://github.com/esphome/issues/issues/843 * Lint
This commit is contained in:
parent
7b142525b4
commit
4f1a28d460
4 changed files with 11 additions and 8 deletions
|
@ -4,7 +4,7 @@ from esphome.components import sensor, spi
|
||||||
from esphome.const import \
|
from esphome.const import \
|
||||||
CONF_ID, CONF_VOLTAGE, CONF_CURRENT, CONF_POWER, CONF_POWER_FACTOR, CONF_FREQUENCY, \
|
CONF_ID, CONF_VOLTAGE, CONF_CURRENT, CONF_POWER, CONF_POWER_FACTOR, CONF_FREQUENCY, \
|
||||||
ICON_FLASH, ICON_LIGHTBULB, ICON_CURRENT_AC, ICON_THERMOMETER, \
|
ICON_FLASH, ICON_LIGHTBULB, ICON_CURRENT_AC, ICON_THERMOMETER, \
|
||||||
UNIT_HZ, UNIT_VOLT, UNIT_AMPERE, UNIT_WATT, UNIT_EMPTY, UNIT_CELSIUS
|
UNIT_HERTZ, UNIT_VOLT, UNIT_AMPERE, UNIT_WATT, UNIT_EMPTY, UNIT_CELSIUS, UNIT_VOLT_AMPS_REACTIVE
|
||||||
|
|
||||||
CONF_PHASE_A = 'phase_a'
|
CONF_PHASE_A = 'phase_a'
|
||||||
CONF_PHASE_B = 'phase_b'
|
CONF_PHASE_B = 'phase_b'
|
||||||
|
@ -33,7 +33,8 @@ ATM90E32_PHASE_SCHEMA = cv.Schema({
|
||||||
cv.Optional(CONF_VOLTAGE): sensor.sensor_schema(UNIT_VOLT, ICON_FLASH, 2),
|
cv.Optional(CONF_VOLTAGE): sensor.sensor_schema(UNIT_VOLT, ICON_FLASH, 2),
|
||||||
cv.Optional(CONF_CURRENT): sensor.sensor_schema(UNIT_AMPERE, ICON_CURRENT_AC, 2),
|
cv.Optional(CONF_CURRENT): sensor.sensor_schema(UNIT_AMPERE, ICON_CURRENT_AC, 2),
|
||||||
cv.Optional(CONF_POWER): sensor.sensor_schema(UNIT_WATT, ICON_FLASH, 2),
|
cv.Optional(CONF_POWER): sensor.sensor_schema(UNIT_WATT, ICON_FLASH, 2),
|
||||||
cv.Optional(CONF_REACTIVE_POWER): sensor.sensor_schema(UNIT_EMPTY, ICON_LIGHTBULB, 2),
|
cv.Optional(CONF_REACTIVE_POWER): sensor.sensor_schema(UNIT_VOLT_AMPS_REACTIVE,
|
||||||
|
ICON_LIGHTBULB, 2),
|
||||||
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),
|
||||||
cv.Optional(CONF_GAIN_VOLTAGE, default=41820): cv.uint16_t,
|
cv.Optional(CONF_GAIN_VOLTAGE, default=41820): cv.uint16_t,
|
||||||
cv.Optional(CONF_GAIN_CT, default=25498): cv.uint16_t,
|
cv.Optional(CONF_GAIN_CT, default=25498): cv.uint16_t,
|
||||||
|
@ -44,7 +45,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_CURRENT_AC, 1),
|
cv.Optional(CONF_FREQUENCY): sensor.sensor_schema(UNIT_HERTZ, ICON_CURRENT_AC, 1),
|
||||||
cv.Optional(CONF_CHIP_TEMPERATURE): sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1),
|
cv.Optional(CONF_CHIP_TEMPERATURE): sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 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),
|
||||||
|
|
|
@ -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))
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -539,7 +539,7 @@ UNIT_DEGREES = u'°'
|
||||||
UNIT_EMPTY = ''
|
UNIT_EMPTY = ''
|
||||||
UNIT_G = 'G'
|
UNIT_G = 'G'
|
||||||
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'
|
||||||
|
@ -557,6 +557,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'
|
||||||
|
|
Loading…
Reference in a new issue