Fixes for release-candidate

This commit is contained in:
Otto Winter 2018-08-22 22:04:56 +02:00
parent 03249780fd
commit 2fc78a1b33
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
20 changed files with 64 additions and 54 deletions

View file

@ -135,7 +135,7 @@ ACTIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
}), }),
vol.Optional(CONF_OUTPUT_SET_LEVEL): { vol.Optional(CONF_OUTPUT_SET_LEVEL): {
vol.Required(CONF_ID): cv.use_variable_id(None), vol.Required(CONF_ID): cv.use_variable_id(None),
vol.Required(CONF_LEVEL): cv.zero_to_one_float, vol.Required(CONF_LEVEL): cv.percentage,
}, },
vol.Optional(CONF_DEEP_SLEEP_ENTER): maybe_simple_id({ vol.Optional(CONF_DEEP_SLEEP_ENTER): maybe_simple_id({
vol.Required(CONF_ID): cv.use_variable_id(deep_sleep.DeepSleepComponent), vol.Required(CONF_ID): cv.use_variable_id(deep_sleep.DeepSleepComponent),

View file

@ -1,8 +1,7 @@
import voluptuous as vol import voluptuous as vol
import esphomeyaml.config_validation as cv import esphomeyaml.config_validation as cv
from esphomeyaml.components import binary_sensor from esphomeyaml.components import binary_sensor, rdm6300
from esphomeyaml.components.rdm6300 import RDM6300Component
from esphomeyaml.const import CONF_NAME, CONF_UID from esphomeyaml.const import CONF_NAME, CONF_UID
from esphomeyaml.helpers import get_variable from esphomeyaml.helpers import get_variable
@ -12,7 +11,7 @@ CONF_RDM6300_ID = 'rdm6300_id'
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
vol.Required(CONF_UID): cv.uint32_t, vol.Required(CONF_UID): cv.uint32_t,
cv.GenerateID(CONF_RDM6300_ID): cv.use_variable_id(RDM6300Component) cv.GenerateID(CONF_RDM6300_ID): cv.use_variable_id(rdm6300.RDM6300Component)
})) }))
@ -20,5 +19,5 @@ def to_code(config):
hub = None hub = None
for hub in get_variable(config[CONF_RDM6300_ID]): for hub in get_variable(config[CONF_RDM6300_ID]):
yield yield
rhs = hub.make_tag(config[CONF_NAME], config[CONF_UID]) rhs = hub.make_card(config[CONF_NAME], config[CONF_UID])
binary_sensor.register_binary_sensor(rhs, config) binary_sensor.register_binary_sensor(rhs, config)

View file

@ -34,10 +34,10 @@ def validate_rotation(value):
BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
vol.Optional(CONF_LAMBDA): cv.lambda_,
}) })
FULL_DISPLAY_PLATFORM_SCHEMA = BASIC_DISPLAY_PLATFORM_SCHEMA.extend({ FULL_DISPLAY_PLATFORM_SCHEMA = BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
vol.Optional(CONF_LAMBDA): cv.lambda_,
vol.Optional(CONF_ROTATION): validate_rotation, vol.Optional(CONF_ROTATION): validate_rotation,
}) })

View file

@ -3,7 +3,7 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv import esphomeyaml.config_validation as cv
from esphomeyaml import pins from esphomeyaml import pins
from esphomeyaml.components import display from esphomeyaml.components import display
from esphomeyaml.const import CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, CONF_LAMBDA, CONF_PINS, \ from esphomeyaml.const import CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, CONF_LAMBDA, CONF_DATA_PINS, \
CONF_RS_PIN, CONF_RW_PIN CONF_RS_PIN, CONF_RW_PIN
from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression, process_lambda from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression, process_lambda
@ -32,12 +32,10 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(GPIOLCDDisplay), cv.GenerateID(): cv.declare_variable_id(GPIOLCDDisplay),
vol.Required(CONF_DIMENSIONS): validate_lcd_dimensions, vol.Required(CONF_DIMENSIONS): validate_lcd_dimensions,
vol.Required(CONF_PINS): vol.All([pins.gpio_output_pin_schema], validate_pin_length), vol.Required(CONF_DATA_PINS): vol.All([pins.gpio_output_pin_schema], validate_pin_length),
vol.Required(CONF_ENABLE_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_ENABLE_PIN): pins.gpio_output_pin_schema,
vol.Required(CONF_RS_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_RS_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_RW_PIN): pins.gpio_output_pin_schema, vol.Optional(CONF_RW_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_LAMBDA): cv.lambda_,
}) })
@ -45,7 +43,7 @@ def to_code(config):
rhs = App.make_gpio_lcd_display(config[CONF_DIMENSIONS][0], config[CONF_DIMENSIONS][1]) rhs = App.make_gpio_lcd_display(config[CONF_DIMENSIONS][0], config[CONF_DIMENSIONS][1])
lcd = Pvariable(config[CONF_ID], rhs) lcd = Pvariable(config[CONF_ID], rhs)
pins_ = [] pins_ = []
for conf in config[CONF_PINS]: for conf in config[CONF_DATA_PINS]:
for pin in gpio_output_pin_expression(conf): for pin in gpio_output_pin_expression(conf):
yield yield
pins_.append(pin) pins_.append(pin)

View file

@ -14,8 +14,6 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(PCF8574LCDDisplay), cv.GenerateID(): cv.declare_variable_id(PCF8574LCDDisplay),
vol.Required(CONF_DIMENSIONS): validate_lcd_dimensions, vol.Required(CONF_DIMENSIONS): validate_lcd_dimensions,
vol.Optional(CONF_ADDRESS): cv.i2c_address, vol.Optional(CONF_ADDRESS): cv.i2c_address,
vol.Optional(CONF_LAMBDA): cv.lambda_,
}) })

View file

@ -21,7 +21,6 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NUM_CHIPS): vol.All(cv.uint8_t, vol.Range(min=1)), vol.Optional(CONF_NUM_CHIPS): vol.All(cv.uint8_t, vol.Range(min=1)),
vol.Optional(CONF_INTENSITY): vol.All(cv.uint8_t, vol.Range(min=0, max=15)), vol.Optional(CONF_INTENSITY): vol.All(cv.uint8_t, vol.Range(min=0, max=15)),
vol.Optional(CONF_LAMBDA): cv.lambda_,
}) })

View file

@ -13,7 +13,7 @@ I2CSSD1306 = display.display_ns.I2CSSD1306
PLATFORM_SCHEMA = display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(I2CSSD1306), cv.GenerateID(): cv.declare_variable_id(I2CSSD1306),
vol.Required(CONF_MODEL): cv.one_of(*ssd1306_spi.MODELS), vol.Required(CONF_MODEL): ssd1306_spi.SSD1306_MODEL,
vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_EXTERNAL_VCC): cv.boolean, vol.Optional(CONF_EXTERNAL_VCC): cv.boolean,
vol.Optional(CONF_ADDRESS): cv.i2c_address, vol.Optional(CONF_ADDRESS): cv.i2c_address,

View file

@ -21,12 +21,14 @@ MODELS = {
'SH1106_96X16': display.display_ns.SH1106_MODEL_96_16, 'SH1106_96X16': display.display_ns.SH1106_MODEL_96_16,
} }
SSD1306_MODEL = vol.All(vol.Upper, vol.Replace(' ', '_'), cv.one_of(*MODELS))
PLATFORM_SCHEMA = display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(SPISSD1306), cv.GenerateID(): cv.declare_variable_id(SPISSD1306),
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent), cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
vol.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
vol.Required(CONF_MODEL): cv.one_of(*MODELS), vol.Required(CONF_MODEL): SSD1306_MODEL,
vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_EXTERNAL_VCC): cv.boolean, vol.Optional(CONF_EXTERNAL_VCC): cv.boolean,
}) })

View file

@ -38,7 +38,7 @@ PLATFORM_SCHEMA = vol.All(display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent), cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
vol.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
vol.Required(CONF_MODEL): cv.one_of(*MODELS), vol.Required(CONF_MODEL): vol.All(vol.Lower, cv.one_of(*MODELS)),
vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, vol.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_BUSY_PIN): pins.gpio_input_pin_schema, vol.Optional(CONF_BUSY_PIN): pins.gpio_input_pin_schema,
vol.Optional(CONF_FULL_UPDATE_EVERY): cv.uint32_t, vol.Optional(CONF_FULL_UPDATE_EVERY): cv.uint32_t,

View file

@ -58,7 +58,7 @@ def validate_pillow_installed(value):
def validate_truetype_file(value): def validate_truetype_file(value):
value = cv.string(value) value = cv.string(value)
path = os.path.join(core.CONFIG_PATH, value) path = os.path.join(os.path.dirname(core.CONFIG_PATH), value)
if not os.path.isfile(path): if not os.path.isfile(path):
raise vol.Invalid(u"Could not find file '{}'. Please make sure it exists.".format(path)) raise vol.Invalid(u"Could not find file '{}'. Please make sure it exists.".format(path))
if value.endswith('.zip'): # for Google Fonts downloads if value.endswith('.zip'): # for Google Fonts downloads
@ -77,7 +77,7 @@ FONT_SCHEMA = vol.Schema({
vol.Required(CONF_ID): cv.declare_variable_id(Font), vol.Required(CONF_ID): cv.declare_variable_id(Font),
vol.Required(CONF_FILE): validate_truetype_file, vol.Required(CONF_FILE): validate_truetype_file,
vol.Optional(CONF_GLYPHS, default=DEFAULT_GLYPHS): validate_glyphs, vol.Optional(CONF_GLYPHS, default=DEFAULT_GLYPHS): validate_glyphs,
vol.Optional(CONF_SIZE, default=12): vol.All(cv.int_, vol.Range(min=1)), vol.Optional(CONF_SIZE, default=20): vol.All(cv.int_, vol.Range(min=1)),
cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_variable_id(None), cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_variable_id(None),
}) })
@ -88,7 +88,7 @@ def to_code(config):
from PIL import ImageFont from PIL import ImageFont
for conf in config: for conf in config:
path = os.path.join(core.CONFIG_PATH, conf[CONF_FILE]) path = os.path.join(os.path.dirname(core.CONFIG_PATH), conf[CONF_FILE])
try: try:
font = ImageFont.truetype(path, conf[CONF_SIZE]) font = ImageFont.truetype(path, conf[CONF_SIZE])
except Exception as e: except Exception as e:

View file

@ -31,7 +31,7 @@ def validate_pillow_installed(value):
def validate_image_file(value): def validate_image_file(value):
value = cv.string(value) value = cv.string(value)
path = os.path.join(core.CONFIG_PATH, value) path = os.path.join(os.path.dirname(core.CONFIG_PATH), value)
if not os.path.isfile(path): if not os.path.isfile(path):
raise vol.Invalid(u"Could not find file '{}'. Please make sure it exists.".format(path)) raise vol.Invalid(u"Could not find file '{}'. Please make sure it exists.".format(path))
return value return value
@ -53,7 +53,7 @@ def to_code(config):
from PIL import Image from PIL import Image
for conf in config: for conf in config:
path = os.path.join(core.CONFIG_PATH, conf[CONF_FILE]) path = os.path.join(os.path.dirname(core.CONFIG_PATH), conf[CONF_FILE])
try: try:
image = Image.open(path) image = Image.open(path)
except Exception as e: except Exception as e:
@ -62,7 +62,7 @@ def to_code(config):
if CONF_RESIZE in conf: if CONF_RESIZE in conf:
image.thumbnail(conf[CONF_RESIZE]) image.thumbnail(conf[CONF_RESIZE])
image = image.convert('1') image = image.convert('1', dither=Image.NONE)
width, height = image.size width, height = image.size
if width > 500 or height > 500: if width > 500 or height > 500:
_LOGGER.warning("The image you requested is very big. Please consider using the resize " _LOGGER.warning("The image you requested is very big. Please consider using the resize "

View file

@ -72,6 +72,7 @@ EFFECTS_SCHEMA = vol.Schema({
vol.Optional(CONF_LAMBDA): vol.Schema({ vol.Optional(CONF_LAMBDA): vol.Schema({
vol.Required(CONF_NAME): cv.string, vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_LAMBDA): cv.lambda_, vol.Required(CONF_LAMBDA): cv.lambda_,
vol.Optional(CONF_UPDATE_INTERVAL, default='0ms'): cv.positive_time_period_milliseconds,
}), }),
vol.Optional(CONF_RANDOM): vol.Schema({ vol.Optional(CONF_RANDOM): vol.Schema({
cv.GenerateID(CONF_EFFECT_ID): cv.declare_variable_id(RandomLightEffect), cv.GenerateID(CONF_EFFECT_ID): cv.declare_variable_id(RandomLightEffect),
@ -102,6 +103,7 @@ EFFECTS_SCHEMA = vol.Schema({
vol.Optional(CONF_FASTLED_LAMBDA): vol.Schema({ vol.Optional(CONF_FASTLED_LAMBDA): vol.Schema({
vol.Required(CONF_NAME): cv.string, vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_LAMBDA): cv.lambda_, vol.Required(CONF_LAMBDA): cv.lambda_,
vol.Optional(CONF_UPDATE_INTERVAL, default='0ms'): cv.positive_time_period_milliseconds,
}), }),
vol.Optional(CONF_FASTLED_RAINBOW): vol.Schema({ vol.Optional(CONF_FASTLED_RAINBOW): vol.Schema({
cv.GenerateID(CONF_EFFECT_ID): cv.declare_variable_id(FastLEDRainbowLightEffect), cv.GenerateID(CONF_EFFECT_ID): cv.declare_variable_id(FastLEDRainbowLightEffect),
@ -199,7 +201,7 @@ def build_effect(full_config):
lambda_ = None lambda_ = None
for lambda_ in process_lambda(config[CONF_LAMBDA], []): for lambda_ in process_lambda(config[CONF_LAMBDA], []):
yield None yield None
yield LambdaLightEffect.new(config[CONF_NAME], lambda_) yield LambdaLightEffect.new(config[CONF_NAME], lambda_, config[CONF_UPDATE_INTERVAL])
elif key == CONF_RANDOM: elif key == CONF_RANDOM:
rhs = RandomLightEffect.new(config[CONF_NAME]) rhs = RandomLightEffect.new(config[CONF_NAME])
effect = Pvariable(config[CONF_EFFECT_ID], rhs) effect = Pvariable(config[CONF_EFFECT_ID], rhs)
@ -233,10 +235,10 @@ def build_effect(full_config):
yield effect yield effect
elif key == CONF_FASTLED_LAMBDA: elif key == CONF_FASTLED_LAMBDA:
lambda_ = None lambda_ = None
args = [(RawExpression('FastLEDLightOutputComponent &'), 'fastled')] args = [(RawExpression('FastLEDLightOutputComponent &'), 'it')]
for lambda_ in process_lambda(config[CONF_LAMBDA], args): for lambda_ in process_lambda(config[CONF_LAMBDA], args):
yield None yield None
yield FastLEDLambdaLightEffect.new(config[CONF_NAME], lambda_) yield FastLEDLambdaLightEffect.new(config[CONF_NAME], lambda_, config[CONF_UPDATE_INTERVAL])
elif key == CONF_FASTLED_RAINBOW: elif key == CONF_FASTLED_RAINBOW:
rhs = FastLEDRainbowLightEffect.new(config[CONF_NAME]) rhs = FastLEDRainbowLightEffect.new(config[CONF_NAME])
effect = Pvariable(config[CONF_EFFECT_ID], rhs) effect = Pvariable(config[CONF_EFFECT_ID], rhs)

View file

@ -10,7 +10,7 @@ DEPENDENCIES = ['uart']
RDM6300Component = binary_sensor.binary_sensor_ns.RDM6300Component RDM6300Component = binary_sensor.binary_sensor_ns.RDM6300Component
CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({ CONFIG_SCHEMA = vol.All(cv.ensure_list_not_empty, [vol.Schema({
cv.GenerateID(): cv.declare_variable_id(RDM6300Component), cv.GenerateID(): cv.declare_variable_id(RDM6300Component),
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent), cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
})]) })])

View file

@ -1,10 +1,11 @@
import voluptuous as vol import voluptuous as vol
import esphomeyaml.config_validation as cv import esphomeyaml.config_validation as cv
from esphomeyaml import core
from esphomeyaml.components import sensor from esphomeyaml.components import sensor
from esphomeyaml.const import CONF_ADDRESS, CONF_GAS_RESISTANCE, CONF_HUMIDITY, CONF_IIR_FILTER, \ from esphomeyaml.const import CONF_ADDRESS, CONF_GAS_RESISTANCE, CONF_HUMIDITY, CONF_IIR_FILTER, \
CONF_MAKE_ID, CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, \ CONF_MAKE_ID, CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, \
CONF_UPDATE_INTERVAL CONF_UPDATE_INTERVAL, CONF_HEATER, CONF_DURATION
from esphomeyaml.helpers import App, Application, add, variable from esphomeyaml.helpers import App, Application, add, variable
DEPENDENCIES = ['i2c'] DEPENDENCIES = ['i2c']
@ -43,7 +44,11 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
vol.Required(CONF_HUMIDITY): cv.nameable(BME680_OVERSAMPLING_SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(BME680_OVERSAMPLING_SENSOR_SCHEMA),
vol.Required(CONF_GAS_RESISTANCE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_GAS_RESISTANCE): cv.nameable(sensor.SENSOR_SCHEMA),
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)), vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)),
# TODO: Heater vol.Optional(CONF_HEATER): vol.Any(None, vol.All(vol.Schema({
vol.Optional(CONF_TEMPERATURE, default=320): vol.All(vol.Coerce(int), vol.Range(200, 400)),
vol.Optional(CONF_DURATION, default='150ms'): vol.All(
cv.positive_time_period_milliseconds, vol.Range(max=core.TimePeriod(milliseconds=4032)))
}, cv.has_at_least_one_key(CONF_TEMPERATURE, CONF_DURATION)))),
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
}) })
@ -69,6 +74,12 @@ def to_code(config):
if CONF_IIR_FILTER in config: if CONF_IIR_FILTER in config:
constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]] constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]]
add(bme680.set_iir_filter(constant)) add(bme680.set_iir_filter(constant))
if CONF_HEATER in config:
conf = config[CONF_HEATER]
if not conf:
add(bme680.set_heater(0, 0))
else:
add(bme680.set_heater(conf[CONF_TEMPERATURE], conf[CONF_DURATION]))
sensor.setup_sensor(bme680.Pget_temperature_sensor(), make.Pmqtt_temperature, sensor.setup_sensor(bme680.Pget_temperature_sensor(), make.Pmqtt_temperature,
config[CONF_TEMPERATURE]) config[CONF_TEMPERATURE])

View file

@ -3,13 +3,12 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv import esphomeyaml.config_validation as cv
from esphomeyaml import pins from esphomeyaml import pins
from esphomeyaml.components import sensor from esphomeyaml.components import sensor
from esphomeyaml.const import CONF_GAIN, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL from esphomeyaml.const import CONF_GAIN, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL, CONF_CLK_PIN
from esphomeyaml.helpers import App, Application, add, gpio_input_pin_expression, variable from esphomeyaml.helpers import App, Application, add, gpio_input_pin_expression, variable
MakeHX711Sensor = Application.MakeHX711Sensor MakeHX711Sensor = Application.MakeHX711Sensor
CONF_DOUT_PIN = 'dout_pin' CONF_DOUT_PIN = 'dout_pin'
CONF_SCK_PIN = 'sck_pin'
GAINS = { GAINS = {
128: sensor.sensor_ns.HX711_GAIN_128, 128: sensor.sensor_ns.HX711_GAIN_128,
@ -20,7 +19,7 @@ GAINS = {
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHX711Sensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHX711Sensor),
vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema, vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema,
vol.Required(CONF_SCK_PIN): pins.gpio_output_pin_schema, vol.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema,
vol.Optional(CONF_GAIN): vol.All(cv.int_, cv.one_of(*GAINS)), vol.Optional(CONF_GAIN): vol.All(cv.int_, cv.one_of(*GAINS)),
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
})) }))
@ -31,7 +30,7 @@ def to_code(config):
for dout_pin in gpio_input_pin_expression(config[CONF_DOUT_PIN]): for dout_pin in gpio_input_pin_expression(config[CONF_DOUT_PIN]):
yield yield
sck_pin = None sck_pin = None
for sck_pin in gpio_input_pin_expression(config[CONF_SCK_PIN]): for sck_pin in gpio_input_pin_expression(config[CONF_CLK_PIN]):
yield yield
rhs = App.make_hx711_sensor(config[CONF_NAME], dout_pin, sck_pin, rhs = App.make_hx711_sensor(config[CONF_NAME], dout_pin, sck_pin,

View file

@ -16,10 +16,10 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(XiaomiMiFloraDevice), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(XiaomiMiFloraDevice),
cv.GenerateID(CONF_ESP32_BLE_ID): cv.use_variable_id(ESP32BLETracker), cv.GenerateID(CONF_ESP32_BLE_ID): cv.use_variable_id(ESP32BLETracker),
vol.Required(CONF_MAC_ADDRESS): cv.mac_address, vol.Required(CONF_MAC_ADDRESS): cv.mac_address,
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
vol.Required(CONF_MOISTURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_MOISTURE): cv.nameable(sensor.SENSOR_SCHEMA),
vol.Required(CONF_ILLUMINANCE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_ILLUMINANCE): cv.nameable(sensor.SENSOR_SCHEMA),
vol.Required(CONF_CONDUCTIVITY): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_CONDUCTIVITY): cv.nameable(sensor.SENSOR_SCHEMA),
vol.Optional(CONF_BATTERY_LEVEL): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_BATTERY_LEVEL): cv.nameable(sensor.SENSOR_SCHEMA),
}) })

View file

@ -8,7 +8,7 @@ from esphomeyaml.helpers import App, Pvariable
SNTPComponent = time_.time_ns.SNTPComponent SNTPComponent = time_.time_ns.SNTPComponent
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(SNTPComponent), vol.Required(CONF_ID): cv.declare_variable_id(SNTPComponent),
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(max=3)), vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(max=3)),
vol.Optional(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_LAMBDA): cv.lambda_,
}) })

View file

@ -2,30 +2,25 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv import esphomeyaml.config_validation as cv
from esphomeyaml import pins from esphomeyaml import pins
from esphomeyaml.const import CONF_BAUD_RATE, CONF_ID, CONF_RX, CONF_TX from esphomeyaml.const import CONF_BAUD_RATE, CONF_ID, CONF_RX_PIN, CONF_TX_PIN
from esphomeyaml.helpers import App, Pvariable, esphomelib_ns, gpio_input_pin_expression, \ from esphomeyaml.helpers import App, Pvariable, esphomelib_ns
gpio_output_pin_expression
UARTComponent = esphomelib_ns.UARTComponent UARTComponent = esphomelib_ns.UARTComponent
SPI_SCHEMA = vol.Schema({ SPI_SCHEMA = vol.All(vol.Schema({
cv.GenerateID(): cv.declare_variable_id(UARTComponent), cv.GenerateID(): cv.declare_variable_id(UARTComponent),
vol.Required(CONF_TX): pins.gpio_output_pin_schema, vol.Optional(CONF_TX_PIN): pins.output_pin,
vol.Required(CONF_RX): pins.gpio_input_pin_schema, vol.Optional(CONF_RX_PIN): pins.input_pin,
vol.Required(CONF_BAUD_RATE): cv.positive_int, vol.Required(CONF_BAUD_RATE): cv.positive_int,
}) }), cv.has_at_least_one_key(CONF_TX_PIN, CONF_RX_PIN))
CONFIG_SCHEMA = vol.All(cv.ensure_list, [SPI_SCHEMA]) CONFIG_SCHEMA = vol.All(cv.ensure_list, [SPI_SCHEMA])
def to_code(config): def to_code(config):
for conf in config: for conf in config:
tx = None tx = conf.get(CONF_TX_PIN, -1)
for tx in gpio_output_pin_expression(conf[CONF_TX]): rx = conf.get(CONF_RX_PIN, -1)
yield
rx = None
for rx in gpio_input_pin_expression(conf[CONF_RX]):
yield
rhs = App.init_uart(tx, rx, conf[CONF_BAUD_RATE]) rhs = App.init_uart(tx, rx, conf[CONF_BAUD_RATE])
Pvariable(conf[CONF_ID], rhs) Pvariable(conf[CONF_ID], rhs)

View file

@ -109,6 +109,12 @@ def ensure_list(value):
return [value] return [value]
def ensure_list_not_empty(value):
if isinstance(value, list):
return value
return [value]
def ensure_dict(value): def ensure_dict(value):
if value is None: if value is None:
return {} return {}

View file

@ -251,8 +251,8 @@ CONF_TYPE = 'type'
CONF_SPI_ID = 'spi_id' CONF_SPI_ID = 'spi_id'
CONF_UART_ID = 'uart_id' CONF_UART_ID = 'uart_id'
CONF_UID = 'uid' CONF_UID = 'uid'
CONF_TX = 'tx' CONF_TX_PIN = 'tx_pin'
CONF_RX = 'rx' CONF_RX_PIN = 'rx_pin'
CONF_CO2 = 'co2' CONF_CO2 = 'co2'
CONF_SHUNT_RESISTANCE = 'shunt_resistance' CONF_SHUNT_RESISTANCE = 'shunt_resistance'
CONF_MAX_CURRENT = 'max_current' CONF_MAX_CURRENT = 'max_current'
@ -298,7 +298,7 @@ CONF_DC_PIN = 'dc_pin'
CONF_RESET_PIN = 'reset_pin' CONF_RESET_PIN = 'reset_pin'
CONF_BUSY_PIN = 'busy_pin' CONF_BUSY_PIN = 'busy_pin'
CONF_FULL_UPDATE_EVERY = 'full_update_every' CONF_FULL_UPDATE_EVERY = 'full_update_every'
CONF_PINS = 'pins' CONF_DATA_PINS = 'data_pins'
CONF_ENABLE_PIN = 'enable_pin' CONF_ENABLE_PIN = 'enable_pin'
CONF_RS_PIN = 'rs_pin' CONF_RS_PIN = 'rs_pin'
CONF_RW_PIN = 'rw_pin' CONF_RW_PIN = 'rw_pin'
@ -308,6 +308,7 @@ CONF_INTENSITY = 'intensity'
CONF_EXTERNAL_VCC = 'external_vcc' CONF_EXTERNAL_VCC = 'external_vcc'
CONF_TIMEZONE = 'timezone' CONF_TIMEZONE = 'timezone'
CONF_SERVERS = 'servers' CONF_SERVERS = 'servers'
CONF_HEATER = 'heater'
ESP32_BOARDS = [ ESP32_BOARDS = [
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1', 'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',