From b386284180f33c0446fbb5033a99fe8e85d2fdd9 Mon Sep 17 00:00:00 2001 From: cvwillegen Date: Mon, 15 Nov 2021 20:06:55 +0100 Subject: [PATCH] Ignore secrets.yaml on command line (#2715) --- esphome/__main__.py | 16 ++++++++-------- esphome/const.py | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index c2a6dd343f..7c7c22dd1f 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -18,6 +18,7 @@ from esphome.const import ( CONF_PORT, CONF_ESPHOME, CONF_PLATFORMIO_OPTIONS, + SECRETS_FILES, ) from esphome.core import CORE, EsphomeError, coroutine from esphome.helpers import indent @@ -200,8 +201,7 @@ def upload_using_esptool(config, port): firmware_offset = "0x10000" if CORE.is_esp32 else "0x0" flash_images = [ platformio_api.FlashImage( - path=idedata.firmware_bin_path, - offset=firmware_offset, + path=idedata.firmware_bin_path, offset=firmware_offset ), *idedata.extra_flash_images, ] @@ -607,10 +607,7 @@ def parse_args(argv): "wizard", help="A helpful setup wizard that will guide you through setting up ESPHome.", ) - parser_wizard.add_argument( - "configuration", - help="Your YAML configuration file.", - ) + parser_wizard.add_argument("configuration", help="Your YAML configuration file.") parser_fingerprint = subparsers.add_parser( "mqtt-fingerprint", help="Get the SSL fingerprint from a MQTT broker." @@ -632,8 +629,7 @@ def parse_args(argv): "dashboard", help="Create a simple web server for a dashboard." ) parser_dashboard.add_argument( - "configuration", - help="Your YAML configuration file directory.", + "configuration", help="Your YAML configuration file directory." ) parser_dashboard.add_argument( "--port", @@ -789,6 +785,10 @@ def run_esphome(argv): return 1 for conf_path in args.configuration: + if any(os.path.basename(conf_path) == x for x in SECRETS_FILES): + _LOGGER.warning("Skipping secrets file %s", conf_path) + continue + CORE.config_path = conf_path CORE.dashboard = args.dashboard diff --git a/esphome/const.py b/esphome/const.py index 9a778edfeb..2a7942a2b4 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -11,6 +11,7 @@ TARGET_PLATFORMS = [PLATFORM_ESP32, PLATFORM_ESP8266] SOURCE_FILE_EXTENSIONS = {".cpp", ".hpp", ".h", ".c", ".tcc", ".ino"} HEADER_FILE_EXTENSIONS = {".h", ".hpp", ".tcc"} +SECRETS_FILES = {"secrets.yaml", "secrets.yml"} CONF_ABOVE = "above"