diff --git a/esphome/__main__.py b/esphome/__main__.py index ecf0092b05..ca5fc1c008 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -365,10 +365,16 @@ def command_wizard(args): def command_config(args, config): - _LOGGER.info("Configuration is valid!") if not CORE.verbose: config = strip_default_ids(config) - safe_print(yaml_util.dump(config, args.show_secrets)) + output = yaml_util.dump(config, args.show_secrets) + # add the console decoration so the front-end can hide the secrets + if not args.show_secrets: + output = re.sub( + r"(password|key|psk|ssid)\:\s(.*)", r"\1: \\033[5m\2\\033[6m", output + ) + safe_print(output) + _LOGGER.info("Configuration is valid!") return 0 diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index a3a44de9ed..b33cb2df5e 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -93,6 +93,10 @@ class DashboardSettings: def using_auth(self): return self.using_password or self.using_ha_addon_auth + @property + def streamer_mode(self): + return get_bool_env("ESPHOME_STREAMER_MODE") + def check_password(self, username, password): if not self.using_auth: return True @@ -131,7 +135,7 @@ def template_args(): "docs_link": docs_link, "get_static_file_url": get_static_file_url, "relative_url": settings.relative_url, - "streamer_mode": get_bool_env("ESPHOME_STREAMER_MODE"), + "streamer_mode": settings.streamer_mode, "config_dir": settings.config_dir, } @@ -396,7 +400,10 @@ class EsphomeCompileHandler(EsphomeCommandWebSocket): class EsphomeValidateHandler(EsphomeCommandWebSocket): def build_command(self, json_message): config_file = settings.rel_path(json_message["configuration"]) - return ["esphome", "--dashboard", "config", config_file] + command = ["esphome", "--dashboard", "config", config_file] + if not settings.streamer_mode: + command.append("--show-secrets") + return command class EsphomeCleanMqttHandler(EsphomeCommandWebSocket): @@ -1147,7 +1154,7 @@ class JsonConfigRequestHandler(BaseHandler): self.send_error(404) return - args = ["esphome", "config", settings.rel_path(configuration), "--show-secrets"] + args = ["esphome", "config", filename, "--show-secrets"] rc, stdout, _ = run_system_command(*args)