1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-14 14:48:18 +00:00
This commit is contained in:
Otto Winter 2018-11-12 23:26:12 +01:00
parent ae42c5ff23
commit b3952b28f4
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
24 changed files with 76 additions and 80 deletions

View File

@ -1,11 +1,11 @@
import voluptuous as vol
from esphomeyaml import config_validation as cv, pins
from esphomeyaml.automation import maybe_simple_id, ACTION_REGISTRY
from esphomeyaml.automation import ACTION_REGISTRY, maybe_simple_id
from esphomeyaml.const import CONF_ID, CONF_NUMBER, CONF_RUN_CYCLES, CONF_RUN_DURATION, \
CONF_SLEEP_DURATION, CONF_WAKEUP_PIN, CONF_ACTION_ID
from esphomeyaml.helpers import App, Pvariable, add, gpio_input_pin_expression, esphomelib_ns, \
TemplateArguments, get_variable, setup_component, Component, Action
CONF_SLEEP_DURATION, CONF_WAKEUP_PIN
from esphomeyaml.helpers import Action, App, Component, Pvariable, TemplateArguments, add, \
esphomelib_ns, get_variable, gpio_input_pin_expression, setup_component
def validate_pin_number(value):
@ -62,7 +62,6 @@ def to_code(config):
BUILD_FLAGS = '-DUSE_DEEP_SLEEP'
CONF_DEEP_SLEEP_ENTER = 'deep_sleep.enter'
DEEP_SLEEP_ENTER_ACTION_SCHEMA = maybe_simple_id({
vol.Required(CONF_ID): cv.use_variable_id(DeepSleepComponent),

View File

@ -25,11 +25,11 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
def to_code(config):
for spi in get_variable(config[CONF_SPI_ID]):
for spi_ in get_variable(config[CONF_SPI_ID]):
yield
for cs in gpio_output_pin_expression(config[CONF_CS_PIN]):
yield
rhs = App.make_max7219(spi, cs)
rhs = App.make_max7219(spi_, cs)
max7219 = Pvariable(config[CONF_ID], rhs)
if CONF_NUM_CHIPS in config:

View File

@ -1,9 +1,10 @@
import esphomeyaml.config_validation as cv
from esphomeyaml.components import display, uart
from esphomeyaml.components.uart import UARTComponent
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_UART_ID
from esphomeyaml.helpers import App, Pvariable, add, get_variable, process_lambda, setup_component, \
PollingComponent
from esphomeyaml.helpers import App, PollingComponent, Pvariable, add, get_variable, \
process_lambda, \
setup_component
DEPENDENCIES = ['uart']
@ -17,9 +18,9 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
def to_code(config):
for uart in get_variable(config[CONF_UART_ID]):
for uart_ in get_variable(config[CONF_UART_ID]):
yield
rhs = App.make_nextion(uart)
rhs = App.make_nextion(uart_)
nextion = Pvariable(config[CONF_ID], rhs)
if CONF_LAMBDA in config:

View File

@ -41,14 +41,14 @@ PLATFORM_SCHEMA = display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({
def to_code(config):
for spi in get_variable(config[CONF_SPI_ID]):
for spi_ in get_variable(config[CONF_SPI_ID]):
yield
for cs in gpio_output_pin_expression(config[CONF_CS_PIN]):
yield
for dc in gpio_output_pin_expression(config[CONF_DC_PIN]):
yield
rhs = App.make_spi_ssd1306(spi, cs, dc)
rhs = App.make_spi_ssd1306(spi_, cs, dc)
ssd = Pvariable(config[CONF_ID], rhs)
add(ssd.set_model(MODELS[config[CONF_MODEL]]))

View File

@ -51,7 +51,7 @@ PLATFORM_SCHEMA = vol.All(display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({
def to_code(config):
for spi in get_variable(config[CONF_SPI_ID]):
for spi_ in get_variable(config[CONF_SPI_ID]):
yield
for cs in gpio_output_pin_expression(config[CONF_CS_PIN]):
yield
@ -60,10 +60,10 @@ def to_code(config):
model_type, model = MODELS[config[CONF_MODEL]]
if model_type == 'a':
rhs = App.make_waveshare_epaper_type_a(spi, cs, dc, model)
rhs = App.make_waveshare_epaper_type_a(spi_, cs, dc, model)
epaper = Pvariable(config[CONF_ID], rhs, type=WaveshareEPaperTypeA)
elif model_type == 'b':
rhs = App.make_waveshare_epaper_type_b(spi, cs, dc, model)
rhs = App.make_waveshare_epaper_type_b(spi_, cs, dc, model)
epaper = Pvariable(config[CONF_ID], rhs, type=WaveshareEPaper)
else:
raise NotImplementedError()

View File

@ -1,9 +1,9 @@
import voluptuous as vol
from esphomeyaml import config_validation as cv
from esphomeyaml.const import CONF_ID, CONF_SCAN_INTERVAL, ESP_PLATFORM_ESP32, CONF_UUID, CONF_TYPE
from esphomeyaml.helpers import App, Pvariable, add, esphomelib_ns, RawExpression, ArrayInitializer, \
setup_component, Component
from esphomeyaml.const import CONF_ID, CONF_SCAN_INTERVAL, CONF_TYPE, CONF_UUID, ESP_PLATFORM_ESP32
from esphomeyaml.helpers import App, ArrayInitializer, Component, Pvariable, RawExpression, add, \
esphomelib_ns, setup_component
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
@ -24,7 +24,7 @@ CONFIG_SCHEMA = vol.Schema({
def to_code(config):
uuid = config[CONF_UUID].hex
uuid_arr = [RawExpression('0x{}'.format(uuid[i:i+2])) for i in range(0, len(uuid), 2)]
uuid_arr = [RawExpression('0x{}'.format(uuid[i:i + 2])) for i in range(0, len(uuid), 2)]
rhs = App.make_esp32_ble_beacon(ArrayInitializer(*uuid_arr, multiline=False))
ble = Pvariable(config[CONF_ID], rhs)
if CONF_MAJOR in config:

View File

@ -13,12 +13,12 @@ PLATFORM_SCHEMA = cv.nameable(fan.FAN_PLATFORM_SCHEMA.extend({
def to_code(config):
for output in get_variable(config[CONF_OUTPUT]):
for output_ in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_fan(config[CONF_NAME])
fan_struct = variable(config[CONF_MAKE_ID], rhs)
add(fan_struct.Poutput.set_binary(output))
add(fan_struct.Poutput.set_binary(output_))
if CONF_OSCILLATION_OUTPUT in config:
for oscillation_output in get_variable(config[CONF_OSCILLATION_OUTPUT]):
yield

View File

@ -22,18 +22,18 @@ PLATFORM_SCHEMA = cv.nameable(fan.FAN_PLATFORM_SCHEMA.extend({
def to_code(config):
for output in get_variable(config[CONF_OUTPUT]):
for output_ in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_fan(config[CONF_NAME])
fan_struct = variable(config[CONF_MAKE_ID], rhs)
if CONF_SPEED in config:
speeds = config[CONF_SPEED]
add(fan_struct.Poutput.set_speed(output,
add(fan_struct.Poutput.set_speed(output_,
speeds[CONF_LOW],
speeds[CONF_MEDIUM],
speeds[CONF_HIGH]))
else:
add(fan_struct.Poutput.set_speed(output))
add(fan_struct.Poutput.set_speed(output_))
if CONF_OSCILLATION_OUTPUT in config:
for oscillation_output in get_variable(config[CONF_OSCILLATION_OUTPUT]):

View File

@ -1,9 +1,9 @@
import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import light, output
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT, CONF_EFFECTS
from esphomeyaml.helpers import App, get_variable, variable, setup_component
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_EFFECTS, CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT
from esphomeyaml.helpers import App, get_variable, setup_component, variable
PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight),
@ -13,9 +13,9 @@ PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
def to_code(config):
for output in get_variable(config[CONF_OUTPUT]):
for output_ in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_binary_light(config[CONF_NAME], output)
rhs = App.make_binary_light(config[CONF_NAME], output_)
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
setup_component(light_struct.Pstate, config)

View File

@ -1,10 +1,10 @@
import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import light, output
from esphomeyaml.const import CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, CONF_MAKE_ID, \
CONF_NAME, CONF_OUTPUT, CONF_EFFECTS
from esphomeyaml.helpers import App, get_variable, variable, setup_component
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_DEFAULT_TRANSITION_LENGTH, CONF_EFFECTS, CONF_GAMMA_CORRECT, \
CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT
from esphomeyaml.helpers import App, get_variable, setup_component, variable
PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight),
@ -16,9 +16,9 @@ PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
def to_code(config):
for output in get_variable(config[CONF_OUTPUT]):
for output_ in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_monochromatic_light(config[CONF_NAME], output)
rhs = App.make_monochromatic_light(config[CONF_NAME], output_)
light_struct = variable(config[CONF_MAKE_ID], rhs)
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
setup_component(light_struct.Pstate, config)

View File

@ -1,11 +1,9 @@
import voluptuous as vol
from esphomeyaml import pins
from esphomeyaml.components import i2c
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_PCF8575
from esphomeyaml.helpers import App, Pvariable, esphomelib_ns, setup_component, Component, \
GPIOInputPin, GPIOOutputPin, io_ns
from esphomeyaml.helpers import App, GPIOInputPin, GPIOOutputPin, Pvariable, io_ns, setup_component
DEPENDENCIES = ['i2c']

View File

@ -28,11 +28,11 @@ CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
def to_code(config):
for conf in config:
for spi in get_variable(conf[CONF_SPI_ID]):
for spi_ in get_variable(conf[CONF_SPI_ID]):
yield
for cs in gpio_output_pin_expression(conf[CONF_CS_PIN]):
yield
rhs = App.make_pn532_component(spi, cs, conf.get(CONF_UPDATE_INTERVAL))
rhs = App.make_pn532_component(spi_, cs, conf.get(CONF_UPDATE_INTERVAL))
pn532 = Pvariable(conf[CONF_ID], rhs)
for conf_ in conf.get(CONF_ON_TAG, []):

View File

@ -18,9 +18,9 @@ CONFIG_SCHEMA = vol.All(cv.ensure_list_not_empty, [vol.Schema({
def to_code(config):
for conf in config:
for uart in get_variable(conf[CONF_UART_ID]):
for uart_ in get_variable(conf[CONF_UART_ID]):
yield
rhs = App.make_rdm6300_component(uart)
rhs = App.make_rdm6300_component(uart_)
var = Pvariable(conf[CONF_ID], rhs)
setup_component(var, conf)

View File

@ -1,18 +1,18 @@
import voluptuous as vol
from esphomeyaml import automation
from esphomeyaml.components import mqtt
import esphomeyaml.config_validation as cv
from esphomeyaml import automation
from esphomeyaml.const import CONF_ABOVE, CONF_ACCURACY_DECIMALS, CONF_ALPHA, CONF_BELOW, \
CONF_DEBOUNCE, CONF_DELTA, CONF_EXPIRE_AFTER, CONF_EXPONENTIAL_MOVING_AVERAGE, CONF_FILTERS, \
CONF_FILTER_NAN, CONF_FILTER_OUT, CONF_HEARTBEAT, CONF_ICON, CONF_ID, CONF_INTERNAL, \
CONF_LAMBDA, CONF_MQTT_ID, CONF_MULTIPLY, CONF_OFFSET, CONF_ON_RAW_VALUE, CONF_ON_VALUE, \
CONF_ON_VALUE_RANGE, CONF_OR, CONF_SEND_EVERY, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \
CONF_THROTTLE, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, CONF_WINDOW_SIZE, \
CONF_SEND_FIRST_AT
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, add, add_job, esphomelib_ns, \
float_, process_lambda, setup_mqtt_component, templatable, Nameable, PollingComponent, Trigger, \
Component
CONF_ON_VALUE_RANGE, CONF_OR, CONF_SEND_EVERY, CONF_SEND_FIRST_AT, \
CONF_SLIDING_WINDOW_MOVING_AVERAGE, CONF_THROTTLE, CONF_TRIGGER_ID, CONF_UNIQUE, \
CONF_UNIT_OF_MEASUREMENT, CONF_WINDOW_SIZE
from esphomeyaml.helpers import App, ArrayInitializer, Component, Nameable, PollingComponent, \
Pvariable, Trigger, add, add_job, esphomelib_ns, float_, process_lambda, setup_mqtt_component, \
templatable
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
@ -73,7 +73,6 @@ SensorStateTrigger = sensor_ns.class_('SensorStateTrigger', Trigger.template(flo
SensorRawStateTrigger = sensor_ns.class_('SensorRawStateTrigger', Trigger.template(float_))
ValueRangeTrigger = sensor_ns.class_('ValueRangeTrigger', Trigger.template(float_))
# Filters
Filter = sensor_ns.class_('Filter')
SlidingWindowMovingAverageFilter = sensor_ns.class_('SlidingWindowMovingAverageFilter', Filter)
@ -90,7 +89,6 @@ DeltaFilter = sensor_ns.class_('DeltaFilter', Filter)
OrFilter = sensor_ns.class_('OrFilter', Filter)
UniqueFilter = sensor_ns.class_('UniqueFilter', Filter)
SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({
cv.GenerateID(CONF_MQTT_ID): cv.declare_variable_id(MQTTSensorComponent),
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string_strict,

View File

@ -35,10 +35,10 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
def to_code(config):
for uart in get_variable(config[CONF_UART_ID]):
for uart_ in get_variable(config[CONF_UART_ID]):
yield
rhs = App.make_cse7766(uart)
rhs = App.make_cse7766(uart_)
cse = Pvariable(config[CONF_ID], rhs)
if CONF_VOLTAGE in config:

View File

@ -23,11 +23,11 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
def to_code(config):
for spi in get_variable(config[CONF_SPI_ID]):
for spi_ in get_variable(config[CONF_SPI_ID]):
yield
for cs in gpio_output_pin_expression(config[CONF_CS_PIN]):
yield
rhs = App.make_max6675_sensor(config[CONF_NAME], spi, cs,
rhs = App.make_max6675_sensor(config[CONF_NAME], spi_, cs,
config.get(CONF_UPDATE_INTERVAL))
make = variable(config[CONF_MAKE_ID], rhs)
max6675 = make.Pmax6675

View File

@ -31,9 +31,9 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
def to_code(config):
for uart in get_variable(config[CONF_UART_ID]):
for uart_ in get_variable(config[CONF_UART_ID]):
yield
rhs = App.make_mhz19_sensor(uart, config[CONF_CO2][CONF_NAME],
rhs = App.make_mhz19_sensor(uart_, config[CONF_CO2][CONF_NAME],
config.get(CONF_UPDATE_INTERVAL))
make = variable(config[CONF_MAKE_ID], rhs)
mhz19 = make.Pmhz19

View File

@ -1,11 +1,12 @@
import voluptuous as vol
from esphomeyaml.components import i2c, sensor
import esphomeyaml.config_validation as cv
from esphomeyaml.components import sensor, i2c
from esphomeyaml.const import CONF_ADDRESS, CONF_MAKE_ID, CONF_NAME, CONF_PRESSURE, \
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL, CONF_ID
from esphomeyaml.helpers import App, Application, add, variable, setup_component, PollingComponent, \
Pvariable
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_MAKE_ID, CONF_NAME, CONF_PRESSURE, \
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
from esphomeyaml.helpers import App, Application, PollingComponent, Pvariable, add, \
setup_component, \
variable
DEPENDENCIES = ['i2c']

View File

@ -60,10 +60,10 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
def to_code(config):
for uart in get_variable(config[CONF_UART_ID]):
for uart_ in get_variable(config[CONF_UART_ID]):
yield
rhs = App.make_pmsx003(uart, PMSX003_TYPES[config[CONF_TYPE]])
rhs = App.make_pmsx003(uart_, PMSX003_TYPES[config[CONF_TYPE]])
pms = Pvariable(config[CONF_ID], rhs)
if CONF_PM_1_0 in config:

View File

@ -20,11 +20,11 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
def to_code(config):
for time in get_variable(config[CONF_TIME_ID]):
for time_ in get_variable(config[CONF_TIME_ID]):
yield
for sens in get_variable(config[CONF_POWER_ID]):
yield
rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time, sens)
rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens)
make = variable(config[CONF_MAKE_ID], rhs)
total_energy = make.Ptotal_energy

View File

@ -1,9 +1,9 @@
import voluptuous as vol
from esphomeyaml.components import output, switch
import esphomeyaml.config_validation as cv
from esphomeyaml.components import switch, output
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT
from esphomeyaml.helpers import App, Application, get_variable, variable, setup_component, Component
from esphomeyaml.helpers import App, Application, Component, get_variable, setup_component, variable
MakeOutputSwitch = Application.struct('MakeOutputSwitch')
OutputSwitch = switch.switch_ns.class_('OutputSwitch', switch.Switch, Component)
@ -16,12 +16,12 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
def to_code(config):
for output in get_variable(config[CONF_OUTPUT]):
for output_ in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_output_switch(config[CONF_NAME], output)
rhs = App.make_output_switch(config[CONF_NAME], output_)
make = variable(config[CONF_MAKE_ID], rhs)
switch_ = make.Pswitch_
switch.setup_switch(switch_, make.Pmqtt, config)
setup_component(switch, config)

View File

@ -1,12 +1,10 @@
import logging
import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml import core
from esphomeyaml.const import CONF_PORT, CONF_JS_URL, CONF_CSS_URL, CONF_ID, ESP_PLATFORM_ESP32
from esphomeyaml.helpers import App, add, Pvariable, esphomelib_ns, setup_component, Component, \
StoringController
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_CSS_URL, CONF_ID, CONF_JS_URL, CONF_PORT, ESP_PLATFORM_ESP32
from esphomeyaml.helpers import App, Component, Pvariable, StoringController, add, esphomelib_ns, \
setup_component
WebServer = esphomelib_ns.class_('WebServer', Component, StoringController)

View File

@ -108,7 +108,7 @@ def do_id_pass(result):
for id, prefix, config in searching_ids:
if id.id is not None:
# manually declared
match = next((v[0] for v in declare_ids if v[0].id == id.id ), None)
match = next((v[0] for v in declare_ids if v[0].id == id.id), None)
if match is None:
# No declared ID with this name
result.add_error("Couldn't find ID {}".format(id.id), '.'.join(prefix), config)

View File

@ -595,6 +595,7 @@ class MockObjClass(MockObj):
if not isinstance(paren, MockObjClass):
raise ValueError
self._parents.append(paren)
# pylint: disable=protected-access
self._parents += paren._parents
def inherits_from(self, other):