mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 07:58:09 +01:00
Fixes
This commit is contained in:
parent
44f2b582b5
commit
dc516f7537
10 changed files with 66 additions and 15 deletions
|
@ -39,7 +39,7 @@ PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
hub = get_variable(None, type='ESP32TouchComponent')
|
hub = get_variable(None, type='binary_sensor::ESP32TouchComponent')
|
||||||
touch_pad = RawExpression(TOUCH_PADS[config[CONF_PIN]])
|
touch_pad = RawExpression(TOUCH_PADS[config[CONF_PIN]])
|
||||||
rhs = hub.make_touch_pad(config[CONF_NAME], touch_pad, config[CONF_THRESHOLD])
|
rhs = hub.make_touch_pad(config[CONF_NAME], touch_pad, config[CONF_THRESHOLD])
|
||||||
device = Pvariable('ESP32TouchBinarySensor', config[CONF_ID], rhs)
|
device = Pvariable('ESP32TouchBinarySensor', config[CONF_ID], rhs)
|
||||||
|
|
|
@ -47,7 +47,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||||
vol.Optional(CONF_SETUP_MODE): cv.boolean,
|
vol.Optional(CONF_SETUP_MODE): cv.boolean,
|
||||||
vol.Optional(CONF_IIR_FILTER): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_IIR_FILTER): cv.positive_time_period_milliseconds,
|
||||||
vol.Optional(CONF_SLEEP_DURATION):
|
vol.Optional(CONF_SLEEP_DURATION):
|
||||||
vol.All(cv.positive_time_period, vol.Range(max=TimePeriod(microseconds=436900))),
|
vol.All(cv.positive_time_period, vol.Range(max=TimePeriod(microseconds=436906))),
|
||||||
vol.Optional(CONF_MEASUREMENT_DURATION):
|
vol.Optional(CONF_MEASUREMENT_DURATION):
|
||||||
vol.All(cv.positive_time_period, vol.Range(max=TimePeriod(microseconds=8192))),
|
vol.All(cv.positive_time_period, vol.Range(max=TimePeriod(microseconds=8192))),
|
||||||
vol.Optional(CONF_LOW_VOLTAGE_REFERENCE): validate_voltage(LOW_VOLTAGE_REFERENCE),
|
vol.Optional(CONF_LOW_VOLTAGE_REFERENCE): validate_voltage(LOW_VOLTAGE_REFERENCE),
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml import pins, core
|
from esphomeyaml import pins
|
||||||
from esphomeyaml.components import light
|
from esphomeyaml.components import light
|
||||||
from esphomeyaml.const import CONF_CHIPSET, CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, \
|
from esphomeyaml.const import CONF_CHIPSET, CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, \
|
||||||
CONF_ID, CONF_MAX_REFRESH_RATE, CONF_NAME, CONF_NUM_LEDS, CONF_PIN, CONF_RGB_ORDER, \
|
CONF_ID, CONF_MAX_REFRESH_RATE, CONF_NAME, CONF_NUM_LEDS, CONF_PIN, CONF_RGB_ORDER
|
||||||
ESP_PLATFORM_ESP32
|
|
||||||
from esphomeyaml.helpers import App, RawExpression, TemplateArguments, add, setup_mqtt_component, \
|
from esphomeyaml.helpers import App, RawExpression, TemplateArguments, add, setup_mqtt_component, \
|
||||||
variable
|
variable
|
||||||
|
|
||||||
|
|
|
@ -66,4 +66,4 @@ def to_code(config):
|
||||||
light.setup_light_component(make.Pstate, config)
|
light.setup_light_component(make.Pstate, config)
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = 'DUSE_FAST_LED_LIGHT'
|
BUILD_FLAGS = '-DUSE_FAST_LED_LIGHT'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.components import light
|
from esphomeyaml.components import light
|
||||||
from esphomeyaml.const import CONF_BLUE, CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, \
|
from esphomeyaml.const import CONF_BLUE, CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, \
|
||||||
CONF_GREEN, CONF_ID, CONF_NAME, CONF_RED
|
CONF_GREEN, CONF_ID, CONF_NAME, CONF_RED
|
||||||
from esphomeyaml.helpers import App, add, get_variable, variable, setup_mqtt_component
|
from esphomeyaml.helpers import App, get_variable, setup_mqtt_component, variable
|
||||||
|
|
||||||
PLATFORM_SCHEMA = light.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = light.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID('rgb_light'): cv.register_variable_id,
|
cv.GenerateID('rgb_light'): cv.register_variable_id,
|
||||||
|
|
|
@ -38,7 +38,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_HUMIDITY): BME280_OVERSAMPLING_SENSOR_SCHEMA,
|
vol.Required(CONF_HUMIDITY): BME280_OVERSAMPLING_SENSOR_SCHEMA,
|
||||||
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, vol.Any(*IIR_FILTER_OPTIONS)),
|
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, vol.Any(*IIR_FILTER_OPTIONS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
}).extend(sensor.MQTT_SENSOR_SCHEMA.schema)
|
})
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
|
|
|
@ -43,7 +43,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, vol.Any(*IIR_FILTER_OPTIONS)),
|
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, vol.Any(*IIR_FILTER_OPTIONS)),
|
||||||
# TODO: Heater
|
# TODO: Heater
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
}).extend(sensor.MQTT_SENSOR_SCHEMA.schema)
|
})
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
|
|
45
esphomeyaml/components/sensor/sht3xd.py
Normal file
45
esphomeyaml/components/sensor/sht3xd.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.components import sensor
|
||||||
|
from esphomeyaml.components.sensor import MQTT_SENSOR_SCHEMA
|
||||||
|
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_NAME, CONF_TEMPERATURE, \
|
||||||
|
CONF_UPDATE_INTERVAL, CONF_ADDRESS, CONF_ACCURACY
|
||||||
|
from esphomeyaml.helpers import App, variable, RawExpression, add
|
||||||
|
|
||||||
|
DEPENDENCIES = ['i2c']
|
||||||
|
|
||||||
|
SHT_ACCURACIES = {
|
||||||
|
'LOW': 'sensor::SHT3XD_ACCURACY_LOW',
|
||||||
|
'MEDIUM': 'sensor::SHT3XD_ACCURACY_MEDIUM',
|
||||||
|
'HIGH': 'sensor::SHT3XD_ACCURACY_HIGH',
|
||||||
|
}
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID('sht3xd'): cv.register_variable_id,
|
||||||
|
vol.Required(CONF_TEMPERATURE): MQTT_SENSOR_SCHEMA,
|
||||||
|
vol.Required(CONF_HUMIDITY): MQTT_SENSOR_SCHEMA,
|
||||||
|
vol.Optional(CONF_ADDRESS, default=0x44): cv.i2c_address,
|
||||||
|
vol.Optional(CONF_ACCURACY): vol.All(vol.Upper, vol.Any(*SHT_ACCURACIES)),
|
||||||
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
rhs = App.make_sht3xd_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||||
|
config[CONF_HUMIDITY][CONF_NAME],
|
||||||
|
config.get(CONF_UPDATE_INTERVAL))
|
||||||
|
sht3xd = variable('Application::MakeSHT3XDSensor', config[CONF_ID], rhs)
|
||||||
|
|
||||||
|
if CONF_ACCURACY in config:
|
||||||
|
constant = RawExpression(SHT_ACCURACIES[config[CONF_ACCURACY]])
|
||||||
|
add(sht3xd.Psht3xd.set_accuracy(constant))
|
||||||
|
|
||||||
|
sensor.setup_sensor(sht3xd.Psht3xd.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||||
|
sensor.setup_mqtt_sensor_component(sht3xd.Pmqtt_temperature, config[CONF_TEMPERATURE])
|
||||||
|
|
||||||
|
sensor.setup_sensor(sht3xd.PPsht3xd.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||||
|
sensor.setup_mqtt_sensor_component(sht3xd.Pmqtt_humidity, config[CONF_HUMIDITY])
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_SHT3XD'
|
|
@ -4,15 +4,14 @@ import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.components import sensor
|
from esphomeyaml.components import sensor
|
||||||
from esphomeyaml.const import CONF_ADDRESS, CONF_GAIN, CONF_ID, CONF_INTEGRATION_TIME, CONF_NAME, \
|
from esphomeyaml.const import CONF_ADDRESS, CONF_GAIN, CONF_ID, CONF_INTEGRATION_TIME, CONF_NAME, \
|
||||||
CONF_UPDATE_INTERVAL
|
CONF_UPDATE_INTERVAL
|
||||||
from esphomeyaml.core import TimePeriod
|
|
||||||
from esphomeyaml.helpers import App, RawExpression, add, variable
|
from esphomeyaml.helpers import App, RawExpression, add, variable
|
||||||
|
|
||||||
DEPENDENCIES = ['i2c']
|
DEPENDENCIES = ['i2c']
|
||||||
|
|
||||||
INTEGRATION_TIMES = {
|
INTEGRATION_TIMES = {
|
||||||
TimePeriod(milliseconds=14): 'sensor::TSL2561_INTEGRATION_14MS',
|
14: 'sensor::TSL2561_INTEGRATION_14MS',
|
||||||
TimePeriod(milliseconds=101): 'sensor::TSL2561_INTEGRATION_101MS',
|
101: 'sensor::TSL2561_INTEGRATION_101MS',
|
||||||
TimePeriod(milliseconds=402): 'sensor::TSL2561_INTEGRATION_402MS',
|
402: 'sensor::TSL2561_INTEGRATION_402MS',
|
||||||
}
|
}
|
||||||
GAINS = {
|
GAINS = {
|
||||||
'1X': 'sensor::TSL2561_GAIN_1X',
|
'1X': 'sensor::TSL2561_GAIN_1X',
|
||||||
|
@ -21,11 +20,18 @@ GAINS = {
|
||||||
|
|
||||||
CONF_IS_CS_PACKAGE = 'is_cs_package'
|
CONF_IS_CS_PACKAGE = 'is_cs_package'
|
||||||
|
|
||||||
|
|
||||||
|
def validate_integration_time(value):
|
||||||
|
value = cv.positive_time_period_milliseconds(value).total_milliseconds
|
||||||
|
if value not in INTEGRATION_TIMES:
|
||||||
|
raise vol.Invalid(u"Unsupported integration time {}.".format(value))
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID('tsl2561_sensor'): cv.register_variable_id,
|
cv.GenerateID('tsl2561_sensor'): cv.register_variable_id,
|
||||||
vol.Optional(CONF_ADDRESS, default=0x39): cv.i2c_address,
|
vol.Optional(CONF_ADDRESS, default=0x39): cv.i2c_address,
|
||||||
vol.Optional(CONF_INTEGRATION_TIME): vol.All(cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_INTEGRATION_TIME): validate_integration_time,
|
||||||
vol.Any(*INTEGRATION_TIMES)),
|
|
||||||
vol.Optional(CONF_GAIN): vol.All(vol.Upper, vol.Any(*GAINS)),
|
vol.Optional(CONF_GAIN): vol.All(vol.Upper, vol.Any(*GAINS)),
|
||||||
vol.Optional(CONF_IS_CS_PACKAGE): cv.boolean,
|
vol.Optional(CONF_IS_CS_PACKAGE): cv.boolean,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
|
|
|
@ -184,6 +184,7 @@ CONF_CHIPSET = 'chipset'
|
||||||
CONF_DATA_PIN = 'data_pin'
|
CONF_DATA_PIN = 'data_pin'
|
||||||
CONF_CLOCK_PIN = 'clock_pin'
|
CONF_CLOCK_PIN = 'clock_pin'
|
||||||
CONF_RGB_ORDER = 'rgb_order'
|
CONF_RGB_ORDER = 'rgb_order'
|
||||||
|
CONF_ACCURACY = 'accuracy'
|
||||||
|
|
||||||
ESP32_BOARDS = [
|
ESP32_BOARDS = [
|
||||||
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',
|
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',
|
||||||
|
|
Loading…
Reference in a new issue