mirror of
https://github.com/esphome/esphome.git
synced 2025-03-13 22:28:14 +00:00
Fixes
This commit is contained in:
parent
971d121398
commit
a7366b5b5f
@ -310,13 +310,13 @@ def main():
|
||||
if exit_code != 0:
|
||||
return exit_code
|
||||
_LOGGER.info(u"Successfully compiled program.")
|
||||
if args.no_logs:
|
||||
return 0
|
||||
port = args.upload_port or discover_serial_ports()
|
||||
exit_code = upload_program(config, args, port)
|
||||
if exit_code != 0:
|
||||
return exit_code
|
||||
_LOGGER.info(u"Successfully uploaded program.")
|
||||
if args.no_logs:
|
||||
return 0
|
||||
return show_logs(config, args, port)
|
||||
elif args.command == 'version':
|
||||
print(u"Version: {}".format(const.__version__))
|
||||
|
@ -5,8 +5,6 @@ from esphomeyaml.const import CONF_ID, CONF_RUN_CYCLES, CONF_RUN_DURATION, CONF_
|
||||
CONF_WAKEUP_PIN
|
||||
from esphomeyaml.helpers import App, Pvariable, add, exp_gpio_input_pin
|
||||
|
||||
DEPENDENCIES = ['logger']
|
||||
|
||||
|
||||
def validate_pin_number(value):
|
||||
valid_pins = [0, 2, 4, 12, 13, 14, 15, 25, 26, 27, 32, 39]
|
||||
|
@ -45,7 +45,7 @@ def to_code(config):
|
||||
add(log.set_log_level(tag, exp_log_level(level)))
|
||||
|
||||
|
||||
def build_flags(config):
|
||||
def required_build_flags(config):
|
||||
if CONF_LEVEL in config:
|
||||
return u'-DESPHOMELIB_LOG_LEVEL={}'.format(esphomelib_log_level(config[CONF_LEVEL]))
|
||||
return None
|
||||
|
@ -4,11 +4,11 @@ import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_BIRTH_MESSAGE, CONF_BROKER, CONF_CLIENT_ID, CONF_DISCOVERY, \
|
||||
CONF_DISCOVERY_PREFIX, CONF_DISCOVERY_RETAIN, CONF_FINGERPRINTS, CONF_ID, CONF_LOG_TOPIC, \
|
||||
CONF_DISCOVERY_PREFIX, CONF_DISCOVERY_RETAIN, CONF_SSL_FINGERPRINTS, CONF_ID, CONF_LOG_TOPIC, \
|
||||
CONF_MQTT, CONF_PASSWORD, CONF_PAYLOAD, CONF_PORT, CONF_QOS, CONF_RETAIN, CONF_TOPIC, \
|
||||
CONF_TOPIC_PREFIX, CONF_USERNAME, CONF_WILL_MESSAGE
|
||||
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, StructInitializer, add, \
|
||||
exp_empty_optional
|
||||
exp_empty_optional, RawExpression
|
||||
|
||||
MQTT_WILL_BIRTH_SCHEMA = vol.Any(None, vol.Schema({
|
||||
vol.Required(CONF_TOPIC): cv.publish_topic,
|
||||
@ -51,8 +51,8 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
vol.Optional(CONF_WILL_MESSAGE): MQTT_WILL_BIRTH_SCHEMA,
|
||||
vol.Optional(CONF_TOPIC_PREFIX): cv.publish_topic,
|
||||
vol.Optional(CONF_LOG_TOPIC): cv.publish_topic,
|
||||
vol.Optional(CONF_FINGERPRINTS): vol.All(cv.only_on_esp8266,
|
||||
cv.ensure_list, [validate_fingerprint]),
|
||||
vol.Optional(CONF_SSL_FINGERPRINTS): vol.All(cv.only_on_esp8266,
|
||||
cv.ensure_list, [validate_fingerprint]),
|
||||
})
|
||||
|
||||
|
||||
@ -89,13 +89,13 @@ def to_code(config):
|
||||
add(mqtt.set_client_id(config[CONF_CLIENT_ID]))
|
||||
if CONF_LOG_TOPIC in config:
|
||||
add(mqtt.set_log_topic(config[CONF_LOG_TOPIC]))
|
||||
if CONF_FINGERPRINTS in config:
|
||||
for fingerprint in config[CONF_FINGERPRINTS]:
|
||||
arr = [fingerprint[i:i + 2] for i in range(0, 40, 2)]
|
||||
add(mqtt.add_ssl_fingerprint(ArrayInitializer(*arr)))
|
||||
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)))
|
||||
|
||||
|
||||
def build_flags(config):
|
||||
if CONF_FINGERPRINTS in config:
|
||||
return '-DASYNC_TCP_SSL_ENABLED'
|
||||
def required_build_flags(config):
|
||||
if CONF_SSL_FINGERPRINTS in config:
|
||||
return '-DASYNC_TCP_SSL_ENABLED=1'
|
||||
return None
|
||||
|
@ -30,7 +30,7 @@ STA_MANUAL_IP_SCHEMA = AP_MANUAL_IP_SCHEMA.extend({
|
||||
})
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
cv.GenerateID(CONF_WIFI): cv.register_variable_id,
|
||||
cv.GenerateID('wifi'): cv.register_variable_id,
|
||||
vol.Optional(CONF_SSID): cv.ssid,
|
||||
vol.Optional(CONF_PASSWORD): validate_password,
|
||||
vol.Optional(CONF_MANUAL_IP): STA_MANUAL_IP_SCHEMA,
|
||||
|
@ -137,7 +137,7 @@ def validate_config(config):
|
||||
validated = component.CONFIG_SCHEMA(conf)
|
||||
result[domain] = validated
|
||||
except vol.Invalid as ex:
|
||||
_comp_error(ex, domain, config)
|
||||
_comp_error(ex, domain, conf)
|
||||
continue
|
||||
|
||||
if not hasattr(component, 'PLATFORM_SCHEMA'):
|
||||
|
@ -63,6 +63,20 @@ PLATFORM_TO_PLATFORMIO = {
|
||||
}
|
||||
|
||||
|
||||
def get_build_flags(config, key):
|
||||
build_flags = set()
|
||||
for _, component, conf in iter_components(config):
|
||||
if not hasattr(component, key):
|
||||
continue
|
||||
flags = getattr(component, key)(conf)
|
||||
if flags is None:
|
||||
continue
|
||||
if isinstance(flags, (str, unicode)):
|
||||
flags = [flags]
|
||||
build_flags |= set(flags)
|
||||
return build_flags
|
||||
|
||||
|
||||
def get_ini_content(config):
|
||||
platform = config[CONF_ESPHOMEYAML][CONF_PLATFORM]
|
||||
if platform in PLATFORM_TO_PLATFORMIO:
|
||||
@ -74,20 +88,15 @@ def get_ini_content(config):
|
||||
u'esphomeyaml_uri': config[CONF_ESPHOMEYAML][CONF_LIBRARY_URI],
|
||||
u'build_flags': u'',
|
||||
}
|
||||
build_flags = set()
|
||||
if config[CONF_ESPHOMEYAML][CONF_USE_BUILD_FLAGS]:
|
||||
build_flags = set()
|
||||
build_flags |= get_build_flags(config, 'build_flags')
|
||||
build_flags.add(u"-DESPHOMEYAML_USE")
|
||||
for _, component, conf in iter_components(config):
|
||||
if not hasattr(component, u'build_flags'):
|
||||
continue
|
||||
flags = component.build_flags(conf)
|
||||
if flags is None:
|
||||
continue
|
||||
if isinstance(flags, (str, unicode)):
|
||||
flags = [flags]
|
||||
build_flags |= set(flags)
|
||||
# avoid changing build flags order
|
||||
build_flags = sorted(list(build_flags))
|
||||
build_flags |= get_build_flags(config, 'required_build_flags')
|
||||
|
||||
# avoid changing build flags order
|
||||
build_flags = sorted(list(build_flags))
|
||||
if build_flags:
|
||||
options[u'build_flags'] = u'\n '.join(build_flags)
|
||||
return INI_CONTENT_FORMAT.format(**options)
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
import fnmatch
|
||||
import logging
|
||||
from collections import OrderedDict
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
import yaml
|
||||
|
||||
@ -79,9 +80,8 @@ def _ordered_dict(loader, node):
|
||||
|
||||
if key in seen:
|
||||
fname = getattr(loader.stream, 'name', '')
|
||||
_LOGGER.error(
|
||||
u'YAML file %s contains duplicate key "%s". '
|
||||
u'Check lines %d and %d.', fname, key, seen[key], line)
|
||||
raise ESPHomeYAMLError(u'YAML file {} contains duplicate key "{}". '
|
||||
u'Check lines {} and {}.'.format(fname, key, seen[key], line))
|
||||
seen[key] = line
|
||||
|
||||
return _add_reference(OrderedDict(nodes), loader, node)
|
||||
|
Loading…
x
Reference in New Issue
Block a user