mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
Miscellaneous Fixes
This commit is contained in:
parent
98bdfc821e
commit
4a74027848
@ -7,10 +7,10 @@ from esphomeyaml.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMAT
|
||||
CONF_BELOW, CONF_CONDITION, CONF_CONDITION_ID, CONF_DELAY, CONF_ELSE, CONF_ID, CONF_IF, \
|
||||
CONF_LAMBDA, CONF_OR, CONF_RANGE, CONF_THEN, CONF_TRIGGER_ID, CONF_WHILE
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, TemplateArguments, add, \
|
||||
get_variable, process_lambda, templatable
|
||||
from esphomeyaml.cpp_types import Action, App, Component, PollingComponent, Trigger, \
|
||||
esphomelib_ns, float_, uint32, void, bool_
|
||||
from esphomeyaml.cpp_generator import Pvariable, TemplateArguments, add, get_variable, \
|
||||
process_lambda, templatable
|
||||
from esphomeyaml.cpp_types import Action, App, Component, PollingComponent, Trigger, bool_, \
|
||||
esphomelib_ns, float_, uint32, void
|
||||
from esphomeyaml.util import ServiceRegistry
|
||||
|
||||
|
||||
@ -318,11 +318,10 @@ def build_action(full_config, arg_type):
|
||||
def build_actions(config, arg_type):
|
||||
actions = []
|
||||
for conf in config:
|
||||
action = None
|
||||
for action in build_action(conf, arg_type):
|
||||
yield None
|
||||
actions.append(action)
|
||||
yield ArrayInitializer(*actions, multiline=False)
|
||||
yield actions
|
||||
|
||||
|
||||
def build_condition(full_config, arg_type):
|
||||
@ -342,7 +341,7 @@ def build_conditions(config, arg_type):
|
||||
for condition in build_condition(conf, arg_type):
|
||||
yield None
|
||||
conditions.append(condition)
|
||||
yield ArrayInitializer(*conditions, multiline=False)
|
||||
yield conditions
|
||||
|
||||
|
||||
def build_automation_(trigger, arg_type, config):
|
||||
|
@ -5,7 +5,7 @@ import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_DATA, CONF_DATA_TEMPLATE, CONF_ID, CONF_PASSWORD, CONF_PORT, \
|
||||
CONF_SERVICE, CONF_VARIABLES, CONF_REBOOT_TIMEOUT
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, add, get_variable, process_lambda
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, get_variable, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Action, App, Component, StoringController, esphomelib_ns
|
||||
|
||||
@ -74,15 +74,15 @@ def homeassistant_service_to_code(config, action_id, arg_type, template_arg):
|
||||
add(act.set_service(config[CONF_SERVICE]))
|
||||
if CONF_DATA in config:
|
||||
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA].items()]
|
||||
add(act.set_data(ArrayInitializer(*datas)))
|
||||
add(act.set_data(datas))
|
||||
if CONF_DATA_TEMPLATE in config:
|
||||
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA_TEMPLATE].items()]
|
||||
add(act.set_data_template(ArrayInitializer(*datas)))
|
||||
add(act.set_data_template(datas))
|
||||
if CONF_VARIABLES in config:
|
||||
datas = []
|
||||
for key, value in config[CONF_VARIABLES].items():
|
||||
for value_ in process_lambda(value, []):
|
||||
yield None
|
||||
datas.append(TemplatableKeyValuePair(key, value_))
|
||||
add(act.set_variables(ArrayInitializer(*datas)))
|
||||
add(act.set_variables(datas))
|
||||
yield act
|
||||
|
@ -216,11 +216,10 @@ def setup_filter(config):
|
||||
def setup_filters(config):
|
||||
filters = []
|
||||
for conf in config:
|
||||
filter = None
|
||||
for filter in setup_filter(conf):
|
||||
yield None
|
||||
filters.append(filter)
|
||||
yield ArrayInitializer(*filters)
|
||||
yield filters
|
||||
|
||||
|
||||
def setup_binary_sensor_core_(binary_sensor_var, config):
|
||||
@ -231,7 +230,6 @@ def setup_binary_sensor_core_(binary_sensor_var, config):
|
||||
if CONF_INVERTED in config:
|
||||
add(binary_sensor_var.set_inverted(config[CONF_INVERTED]))
|
||||
if CONF_FILTERS in config:
|
||||
filters = None
|
||||
for filters in setup_filters(config[CONF_FILTERS]):
|
||||
yield
|
||||
add(binary_sensor_var.add_filters(filters))
|
||||
@ -266,7 +264,6 @@ def setup_binary_sensor_core_(binary_sensor_var, config):
|
||||
('min_length', tim[CONF_MIN_LENGTH]),
|
||||
('max_length', tim.get(CONF_MAX_LENGTH, 4294967294)),
|
||||
))
|
||||
timings = ArrayInitializer(*timings, multiline=False)
|
||||
rhs = App.register_component(binary_sensor_var.make_multi_click_trigger(timings))
|
||||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||
if CONF_INVALID_COOLDOWN in conf:
|
||||
|
@ -1,11 +1,11 @@
|
||||
import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.components import binary_sensor
|
||||
from esphomeyaml.components.pn532 import PN532Component
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_NAME, CONF_UID
|
||||
from esphomeyaml.core import HexInt
|
||||
from esphomeyaml.cpp_generator import get_variable, ArrayInitializer
|
||||
from esphomeyaml.cpp_generator import get_variable
|
||||
|
||||
DEPENDENCIES = ['pn532']
|
||||
|
||||
@ -41,7 +41,7 @@ def to_code(config):
|
||||
for hub in get_variable(config[CONF_PN532_ID]):
|
||||
yield
|
||||
addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')]
|
||||
rhs = hub.make_tag(config[CONF_NAME], ArrayInitializer(*addr, multiline=False))
|
||||
rhs = hub.make_tag(config[CONF_NAME], addr)
|
||||
binary_sensor.register_binary_sensor(rhs, config)
|
||||
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.components import binary_sensor
|
||||
from esphomeyaml.components.remote_receiver import RemoteReceiverComponent, remote_ns
|
||||
from esphomeyaml.components.remote_transmitter import RC_SWITCH_RAW_SCHEMA, \
|
||||
RC_SWITCH_TYPE_A_SCHEMA, RC_SWITCH_TYPE_B_SCHEMA, RC_SWITCH_TYPE_C_SCHEMA, \
|
||||
RC_SWITCH_TYPE_D_SCHEMA, binary_code, build_rc_switch_protocol
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_CHANNEL, CONF_CODE, CONF_COMMAND, CONF_DATA, \
|
||||
CONF_DEVICE, CONF_FAMILY, CONF_GROUP, CONF_LG, CONF_NAME, CONF_NBITS, CONF_NEC, \
|
||||
CONF_PANASONIC, CONF_PROTOCOL, CONF_RAW, CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, \
|
||||
CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_SAMSUNG, CONF_SONY, \
|
||||
CONF_STATE
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, get_variable, Pvariable
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
|
||||
DEPENDENCIES = ['remote_receiver']
|
||||
|
||||
@ -82,8 +82,7 @@ def receiver_base(full_config):
|
||||
if key == CONF_SONY:
|
||||
return SonyReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
||||
if key == CONF_RAW:
|
||||
data = ArrayInitializer(*config, multiline=False)
|
||||
return RawReceiver.new(name, data)
|
||||
return RawReceiver.new(name, *config)
|
||||
if key == CONF_RC_SWITCH_RAW:
|
||||
return RCSwitchRawReceiver.new(name, build_rc_switch_protocol(config[CONF_PROTOCOL]),
|
||||
binary_code(config[CONF_CODE]), len(config[CONF_CODE]))
|
||||
|
@ -2,7 +2,7 @@ import voluptuous as vol
|
||||
|
||||
from esphomeyaml import config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_SCAN_INTERVAL, CONF_TYPE, CONF_UUID, ESP_PLATFORM_ESP32
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, RawExpression, add
|
||||
from esphomeyaml.cpp_generator import Pvariable, RawExpression, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Component, esphomelib_ns
|
||||
|
||||
@ -26,7 +26,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)]
|
||||
rhs = App.make_esp32_ble_beacon(ArrayInitializer(*uuid_arr, multiline=False))
|
||||
rhs = App.make_esp32_ble_beacon(uuid_arr)
|
||||
ble = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_MAJOR in config:
|
||||
add(ble.set_major(config[CONF_MAJOR]))
|
||||
|
@ -4,7 +4,7 @@ from esphomeyaml import config_validation as cv
|
||||
from esphomeyaml.components import sensor
|
||||
from esphomeyaml.const import CONF_ID, CONF_SCAN_INTERVAL, ESP_PLATFORM_ESP32
|
||||
from esphomeyaml.core import HexInt
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, add
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Component, esphomelib_ns
|
||||
|
||||
@ -25,8 +25,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
|
||||
|
||||
def make_address_array(address):
|
||||
addr = [HexInt(i) for i in address.parts]
|
||||
return ArrayInitializer(*addr, multiline=False)
|
||||
return [HexInt(i) for i in address.parts]
|
||||
|
||||
|
||||
def to_code(config):
|
||||
|
@ -8,8 +8,9 @@ from esphomeyaml.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_NAME, C
|
||||
CONF_OSCILLATION_COMMAND_TOPIC, CONF_OSCILLATION_OUTPUT, CONF_OSCILLATION_STATE_TOPIC, \
|
||||
CONF_SPEED, CONF_SPEED_COMMAND_TOPIC, CONF_SPEED_STATE_TOPIC
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import add, Pvariable, get_variable, templatable
|
||||
from esphomeyaml.cpp_types import Application, Component, Nameable, esphomelib_ns, Action, bool_
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, get_variable, templatable
|
||||
from esphomeyaml.cpp_types import Action, Application, Component, Nameable, bool_, esphomelib_ns
|
||||
from esphomeyaml.py_compat import string_types
|
||||
|
||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||
|
||||
@ -125,6 +126,8 @@ def fan_turn_on_to_code(config, action_id, arg_type, template_arg):
|
||||
if CONF_SPEED in config:
|
||||
for template_ in templatable(config[CONF_SPEED], arg_type, FanSpeed):
|
||||
yield None
|
||||
if isinstance(template_, string_types):
|
||||
template_ = FAN_SPEEDS[template_]
|
||||
add(action.set_speed(template_))
|
||||
yield action
|
||||
|
||||
|
@ -6,7 +6,7 @@ from esphomeyaml.components import display
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_FILE, CONF_GLYPHS, CONF_ID, CONF_SIZE
|
||||
from esphomeyaml.core import CORE, HexInt
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, MockObj, Pvariable, RawExpression, add
|
||||
from esphomeyaml.cpp_generator import MockObj, Pvariable, RawExpression, add, safe_exp
|
||||
from esphomeyaml.cpp_types import App
|
||||
from esphomeyaml.py_compat import sort_by_cmp
|
||||
|
||||
@ -111,11 +111,11 @@ def to_code(config):
|
||||
raw_data = MockObj(config[CONF_RAW_DATA_ID])
|
||||
add(RawExpression('static const uint8_t {}[{}] PROGMEM = {}'.format(
|
||||
raw_data, len(data),
|
||||
ArrayInitializer(*[HexInt(x) for x in data], multiline=False))))
|
||||
safe_exp([HexInt(x) for x in data]))))
|
||||
|
||||
glyphs = []
|
||||
for glyph in config[CONF_GLYPHS]:
|
||||
glyphs.append(Glyph(glyph, raw_data, *glyph_args[glyph]))
|
||||
|
||||
rhs = App.make_font(ArrayInitializer(*glyphs), ascent, ascent + descent)
|
||||
rhs = App.make_font(glyphs, ascent, ascent + descent)
|
||||
Pvariable(config[CONF_ID], rhs)
|
||||
|
@ -8,7 +8,7 @@ from esphomeyaml.components import display, font
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_FILE, CONF_ID, CONF_RESIZE
|
||||
from esphomeyaml.core import CORE, HexInt
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, MockObj, Pvariable, RawExpression, add
|
||||
from esphomeyaml.cpp_generator import MockObj, Pvariable, RawExpression, add, safe_exp
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -59,7 +59,7 @@ def to_code(config):
|
||||
raw_data = MockObj(config[CONF_RAW_DATA_ID])
|
||||
add(RawExpression('static const uint8_t {}[{}] PROGMEM = {}'.format(
|
||||
raw_data, len(data),
|
||||
ArrayInitializer(*[HexInt(x) for x in data], multiline=False))))
|
||||
safe_exp([HexInt(x) for x in data]))))
|
||||
|
||||
rhs = App.make_image(raw_data, width, height)
|
||||
Pvariable(config[CONF_ID], rhs)
|
||||
|
@ -279,7 +279,7 @@ def build_effect(full_config):
|
||||
('duration', color[CONF_DURATION]),
|
||||
))
|
||||
if colors:
|
||||
add(effect.set_colors(ArrayInitializer(*colors)))
|
||||
add(effect.set_colors(colors))
|
||||
yield effect
|
||||
elif key == CONF_FLICKER:
|
||||
rhs = FlickerLightEffect.new(config[CONF_NAME])
|
||||
@ -322,7 +322,7 @@ def build_effect(full_config):
|
||||
('num_leds', color[CONF_NUM_LEDS]),
|
||||
))
|
||||
if colors:
|
||||
add(effect.set_colors(ArrayInitializer(*colors)))
|
||||
add(effect.set_colors(colors))
|
||||
yield effect
|
||||
elif key == CONF_ADDRESSABLE_SCAN:
|
||||
rhs = AddressableScanEffect.new(config[CONF_NAME])
|
||||
@ -383,7 +383,7 @@ def setup_light_core_(light_var, config):
|
||||
yield
|
||||
effects.append(effect)
|
||||
if effects:
|
||||
add(light_var.add_effects(ArrayInitializer(*effects)))
|
||||
add(light_var.add_effects(effects))
|
||||
|
||||
setup_mqtt_component(light_var.Pget_mqtt(), config)
|
||||
|
||||
|
@ -15,8 +15,8 @@ from esphomeyaml.const import CONF_AVAILABILITY, CONF_BIRTH_MESSAGE, CONF_BROKER
|
||||
CONF_RETAIN, CONF_SHUTDOWN_MESSAGE, CONF_SSL_FINGERPRINTS, CONF_STATE_TOPIC, CONF_TOPIC, \
|
||||
CONF_TOPIC_PREFIX, CONF_TRIGGER_ID, CONF_USERNAME, CONF_WILL_MESSAGE
|
||||
from esphomeyaml.core import EsphomeyamlError
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, RawExpression, \
|
||||
StructInitializer, TemplateArguments, add, process_lambda, templatable
|
||||
from esphomeyaml.cpp_generator import Pvariable, RawExpression, StructInitializer, \
|
||||
TemplateArguments, add, process_lambda, templatable
|
||||
from esphomeyaml.cpp_types import Action, App, Component, JsonObjectConstRef, JsonObjectRef, \
|
||||
Trigger, bool_, esphomelib_ns, optional, std_string, uint8, void
|
||||
|
||||
@ -169,7 +169,7 @@ def to_code(config):
|
||||
if CONF_SSL_FINGERPRINTS in config:
|
||||
for fingerprint in config[CONF_SSL_FINGERPRINTS]:
|
||||
arr = [RawExpression("0x{}".format(fingerprint[i:i + 2])) for i in range(0, 40, 2)]
|
||||
add(mqtt.add_ssl_fingerprint(ArrayInitializer(*arr, multiline=False)))
|
||||
add(mqtt.add_ssl_fingerprint(arr))
|
||||
|
||||
if CONF_KEEPALIVE in config:
|
||||
add(mqtt.set_keep_alive(config[CONF_KEEPALIVE]))
|
||||
@ -340,4 +340,4 @@ def setup_mqtt_component(obj, config):
|
||||
|
||||
|
||||
LIB_DEPS = 'AsyncMqttClient@0.8.2'
|
||||
REQUIRED_BUILD_FLAGS = '-DUSE_MQTT'
|
||||
BUILD_FLAGS = '-DUSE_MQTT'
|
||||
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
||||
from esphomeyaml.components import output
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_OUTPUTS, CONF_TYPE
|
||||
from esphomeyaml.cpp_generator import process_lambda, variable, Pvariable
|
||||
from esphomeyaml.cpp_generator import process_lambda, variable
|
||||
from esphomeyaml.cpp_types import std_vector
|
||||
|
||||
CustomBinaryOutputConstructor = output.output_ns.class_('CustomBinaryOutputConstructor')
|
||||
@ -62,8 +62,7 @@ def to_code(config):
|
||||
rhs = klass(template_)
|
||||
custom = variable(config[CONF_ID], rhs)
|
||||
for i, conf in enumerate(config[CONF_OUTPUTS]):
|
||||
var = Pvariable(conf[CONF_ID], custom.get_output(i))
|
||||
output.register_output(var, conf)
|
||||
output.register_output(custom.get_output(i), conf)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_CUSTOM_OUTPUT'
|
||||
|
@ -162,7 +162,7 @@ def setup_filters(config):
|
||||
for filter in setup_filter(conf):
|
||||
yield None
|
||||
filters.append(filter)
|
||||
yield ArrayInitializer(*filters)
|
||||
yield filters
|
||||
|
||||
|
||||
def setup_sensor_core_(sensor_var, config):
|
||||
|
@ -120,5 +120,5 @@ def stepper_report_position_to_code(config, action_id, arg_type, template_arg):
|
||||
action = Pvariable(action_id, rhs, type=type)
|
||||
for template_ in templatable(config[CONF_POSITION], arg_type, int32):
|
||||
yield None
|
||||
add(action.set_target(template_))
|
||||
add(action.set_position(template_))
|
||||
yield action
|
||||
|
@ -12,7 +12,7 @@ from esphomeyaml.const import CONF_ADDRESS, CONF_CARRIER_FREQUENCY, CONF_CHANNEL
|
||||
CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, \
|
||||
CONF_REPEAT, CONF_SAMSUNG, CONF_SONY, CONF_STATE, CONF_TIMES, \
|
||||
CONF_WAIT_TIME
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, add, get_variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, get_variable
|
||||
|
||||
DEPENDENCIES = ['remote_transmitter']
|
||||
|
||||
@ -100,7 +100,7 @@ def transmitter_base(full_config):
|
||||
else:
|
||||
data = config
|
||||
carrier_frequency = None
|
||||
return RawTransmitter.new(name, ArrayInitializer(*data, multiline=False),
|
||||
return RawTransmitter.new(name, data,
|
||||
carrier_frequency)
|
||||
if key == CONF_RC_SWITCH_RAW:
|
||||
return RCSwitchRawTransmitter.new(name, build_rc_switch_protocol(config[CONF_PROTOCOL]),
|
||||
|
@ -5,7 +5,7 @@ from esphomeyaml.components.uart import UARTComponent
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_DATA, CONF_ID, CONF_INVERTED, CONF_NAME, CONF_UART_ID
|
||||
from esphomeyaml.core import HexInt
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, get_variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_types import App
|
||||
from esphomeyaml.py_compat import text_type
|
||||
|
||||
@ -38,7 +38,7 @@ def to_code(config):
|
||||
data = config[CONF_DATA]
|
||||
if isinstance(data, str):
|
||||
data = [HexInt(ord(x)) for x in data]
|
||||
rhs = App.make_uart_switch(uart_, config[CONF_NAME], ArrayInitializer(*data, multiline=False))
|
||||
rhs = App.make_uart_switch(uart_, config[CONF_NAME], data)
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
switch.setup_switch(var, config)
|
||||
|
||||
|
@ -278,22 +278,22 @@ def setup_time_core_(time_var, config):
|
||||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||
|
||||
seconds = conf.get(CONF_SECONDS, [x for x in range(0, 61)])
|
||||
add(trigger.add_seconds(ArrayInitializer(*seconds, multiline=False)))
|
||||
add(trigger.add_seconds(seconds))
|
||||
|
||||
minutes = conf.get(CONF_MINUTES, [x for x in range(0, 60)])
|
||||
add(trigger.add_minutes(ArrayInitializer(*minutes, multiline=False)))
|
||||
add(trigger.add_minutes(minutes))
|
||||
|
||||
hours = conf.get(CONF_HOURS, [x for x in range(0, 24)])
|
||||
add(trigger.add_hours(ArrayInitializer(*hours, multiline=False)))
|
||||
add(trigger.add_hours(hours))
|
||||
|
||||
days_of_month = conf.get(CONF_DAYS_OF_MONTH, [x for x in range(1, 32)])
|
||||
add(trigger.add_days_of_month(ArrayInitializer(*days_of_month, multiline=False)))
|
||||
add(trigger.add_days_of_month(days_of_month))
|
||||
|
||||
months = conf.get(CONF_MONTHS, [x for x in range(1, 13)])
|
||||
add(trigger.add_months(ArrayInitializer(*months, multiline=False)))
|
||||
add(trigger.add_months(months))
|
||||
|
||||
days_of_week = conf.get(CONF_DAYS_OF_WEEK, [x for x in range(1, 8)])
|
||||
add(trigger.add_days_of_week(ArrayInitializer(*days_of_week, multiline=False)))
|
||||
add(trigger.add_days_of_week(days_of_week))
|
||||
|
||||
automation.build_automation(trigger, NoArg, conf)
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_AP, CONF_CHANNEL, CONF_DNS1, CONF_DNS2, CONF_DOMAIN, \
|
||||
CONF_GATEWAY, CONF_HOSTNAME, CONF_ID, CONF_MANUAL_IP, CONF_PASSWORD, CONF_POWER_SAVE_MODE, \
|
||||
CONF_REBOOT_TIMEOUT, CONF_SSID, CONF_STATIC_IP, CONF_SUBNET, CONF_NETWORKS, CONF_BSSID, \
|
||||
CONF_FAST_CONNECT
|
||||
from esphomeyaml.const import CONF_AP, CONF_BSSID, CONF_CHANNEL, CONF_DNS1, CONF_DNS2, \
|
||||
CONF_DOMAIN, \
|
||||
CONF_FAST_CONNECT, CONF_GATEWAY, CONF_HOSTNAME, CONF_ID, CONF_MANUAL_IP, CONF_NETWORKS, \
|
||||
CONF_PASSWORD, CONF_POWER_SAVE_MODE, CONF_REBOOT_TIMEOUT, CONF_SSID, CONF_STATIC_IP, CONF_SUBNET
|
||||
from esphomeyaml.core import CORE, HexInt
|
||||
from esphomeyaml.cpp_generator import Pvariable, StructInitializer, add, variable, ArrayInitializer
|
||||
from esphomeyaml.cpp_generator import Pvariable, StructInitializer, add, variable
|
||||
from esphomeyaml.cpp_types import App, Component, esphomelib_ns, global_ns
|
||||
|
||||
|
||||
IPAddress = global_ns.class_('IPAddress')
|
||||
ManualIP = esphomelib_ns.struct('ManualIP')
|
||||
WiFiComponent = esphomelib_ns.class_('WiFiComponent', Component)
|
||||
@ -141,8 +140,7 @@ def wifi_network(config, static_ip):
|
||||
if CONF_PASSWORD in config:
|
||||
add(ap.set_password(config[CONF_PASSWORD]))
|
||||
if CONF_BSSID in config:
|
||||
bssid = [HexInt(i) for i in config[CONF_BSSID].parts]
|
||||
add(ap.set_bssid(ArrayInitializer(*bssid, multiline=False)))
|
||||
add(ap.set_bssid([HexInt(i) for i in config[CONF_BSSID].parts]))
|
||||
if CONF_CHANNEL in config:
|
||||
add(ap.set_channel(config[CONF_CHANNEL]))
|
||||
if static_ip is not None:
|
||||
|
@ -134,7 +134,7 @@ class StructInitializer(Expression):
|
||||
class ArrayInitializer(Expression):
|
||||
def __init__(self, *args, **kwargs): # type: (*Any, **Any) -> None
|
||||
super(ArrayInitializer, self).__init__()
|
||||
self.multiline = kwargs.get('multiline', True)
|
||||
self.multiline = kwargs.get('multiline', False)
|
||||
self.args = []
|
||||
for arg in args:
|
||||
if arg is None:
|
||||
@ -264,7 +264,8 @@ class FloatLiteral(Literal):
|
||||
|
||||
|
||||
# pylint: disable=bad-continuation
|
||||
def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod]
|
||||
def safe_exp(
|
||||
obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod, list]
|
||||
):
|
||||
# type: (...) -> Expression
|
||||
if isinstance(obj, Expression):
|
||||
@ -285,6 +286,8 @@ def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float
|
||||
return IntLiteral(int(obj.total_milliseconds))
|
||||
if isinstance(obj, TimePeriodSeconds):
|
||||
return IntLiteral(int(obj.total_seconds))
|
||||
if isinstance(obj, (tuple, list)):
|
||||
return ArrayInitializer(*[safe_exp(o) for o in obj])
|
||||
raise ValueError(u"Object is not an expression", obj)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user