From 97a71482a908f497e70d99369798fbeb38c1c5a5 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 11 May 2023 08:55:05 +1200 Subject: [PATCH] Validate project details are set for dashboard_import (#4802) --- esphome/components/dashboard_import/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/esphome/components/dashboard_import/__init__.py b/esphome/components/dashboard_import/__init__.py index 6b6750cbf4..e0994be6a0 100644 --- a/esphome/components/dashboard_import/__init__.py +++ b/esphome/components/dashboard_import/__init__.py @@ -7,9 +7,10 @@ import requests import esphome.codegen as cg import esphome.config_validation as cv +import esphome.final_validate as fv from esphome import git from esphome.components.packages import validate_source_shorthand -from esphome.const import CONF_REF, CONF_WIFI +from esphome.const import CONF_REF, CONF_WIFI, CONF_ESPHOME, CONF_PROJECT from esphome.wizard import wizard_file from esphome.yaml_util import dump @@ -52,6 +53,17 @@ CONFIG_SCHEMA = cv.All( validate_full_url, ) + +def _final_validate(config): + full_config = fv.full_config.get()[CONF_ESPHOME] + if CONF_PROJECT not in full_config: + raise cv.Invalid( + "Dashboard import requires the `esphome` -> `project` information to be provided." + ) + + +FINAL_VALIDATE_SCHEMA = _final_validate + WIFI_CONFIG = """ wifi: