From 33f296e05b11786c48bfbe8cbb1bed9a6c559572 Mon Sep 17 00:00:00 2001
From: Guillermo Ruffino <glm.net@gmail.com>
Date: Tue, 20 Sep 2022 02:23:55 -0300
Subject: [PATCH 1/3] Fix-esphome-validation-line-number (#3815)

---
 esphome/config.py      | 22 +++++++++++++++-------
 esphome/core/config.py |  6 +++++-
 esphome/vscode.py      |  4 +++-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/esphome/config.py b/esphome/config.py
index 56fe75a4c7..04717be6f5 100644
--- a/esphome/config.py
+++ b/esphome/config.py
@@ -165,15 +165,19 @@ class Config(OrderedDict, fv.FinalValidateConfig):
                 return err
         return None
 
-    def get_deepest_document_range_for_path(self, path):
-        # type: (ConfigPath) -> Optional[ESPHomeDataBase]
+    def get_deepest_document_range_for_path(self, path, get_key=False):
+        # type: (ConfigPath, bool) -> Optional[ESPHomeDataBase]
         data = self
         doc_range = None
-        for item_index in path:
+        for index, path_item in enumerate(path):
             try:
-                if item_index in data:
-                    doc_range = [x for x in data.keys() if x == item_index][0].esp_range
-                data = data[item_index]
+                if path_item in data:
+                    key_data = [x for x in data.keys() if x == path_item][0]
+                    if isinstance(key_data, ESPHomeDataBase):
+                        doc_range = key_data.esp_range
+                        if get_key and index == len(path) - 1:
+                            return doc_range
+                data = data[path_item]
             except (KeyError, IndexError, TypeError, AttributeError):
                 return doc_range
             if isinstance(data, core.ID):
@@ -281,7 +285,7 @@ class ConfigValidationStep(abc.ABC):
 class LoadValidationStep(ConfigValidationStep):
     """Load step, this step is called once for each domain config fragment.
 
-    Responsibilties:
+    Responsibilities:
     - Load component code
     - Ensure all AUTO_LOADs are added
     - Set output paths of result
@@ -738,6 +742,10 @@ def validate_config(config, command_line_substitutions) -> Config:
             result.add_validation_step(LoadValidationStep(key, config[key]))
     result.run_validation_steps()
 
+    if result.errors:
+        # do not try to validate further as we don't know what the target is
+        return result
+
     for domain, conf in config.items():
         result.add_validation_step(LoadValidationStep(domain, conf))
     result.add_validation_step(IDPassValidationStep())
diff --git a/esphome/core/config.py b/esphome/core/config.py
index f1337be04b..82cf37d44d 100644
--- a/esphome/core/config.py
+++ b/esphome/core/config.py
@@ -179,7 +179,11 @@ def preload_core_config(config, result):
     ]
 
     if not has_oldstyle and not newstyle_found:
-        raise cv.Invalid("Platform missing for core options!", [CONF_ESPHOME])
+        raise cv.Invalid(
+            "Platform missing. You must include one of the available platform keys: "
+            + ", ".join(TARGET_PLATFORMS),
+            [CONF_ESPHOME],
+        )
     if has_oldstyle and newstyle_found:
         raise cv.Invalid(
             f"Please remove the `platform` key from the [esphome] block. You're already using the new style with the [{conf[CONF_PLATFORM]}] block",
diff --git a/esphome/vscode.py b/esphome/vscode.py
index 68d59abd02..6a43a654ed 100644
--- a/esphome/vscode.py
+++ b/esphome/vscode.py
@@ -12,7 +12,9 @@ from typing import Optional
 
 def _get_invalid_range(res, invalid):
     # type: (Config, cv.Invalid) -> Optional[DocumentRange]
-    return res.get_deepest_document_range_for_path(invalid.path)
+    return res.get_deepest_document_range_for_path(
+        invalid.path, invalid.error_message == "extra keys not allowed"
+    )
 
 
 def _dump_range(range):

From d56107e97fe72de58c26b2667cc42e9d08bc8fbc Mon Sep 17 00:00:00 2001
From: Paulus Schoutsen <balloob@gmail.com>
Date: Tue, 20 Sep 2022 15:35:46 -0400
Subject: [PATCH 2/3] Bump dashboard to 20220920.0 (#3831)

---
 requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/requirements.txt b/requirements.txt
index a81c38c44f..0a667bef10 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,7 +9,7 @@ pyserial==3.5
 platformio==6.0.2  # When updating platformio, also update Dockerfile
 esptool==3.3.1
 click==8.1.3
-esphome-dashboard==20220919.1
+esphome-dashboard==20220920.0
 aioesphomeapi==10.13.0
 zeroconf==0.39.1
 

From 63b42f36080c17ab51fc57325e2fd61dc71eac4a Mon Sep 17 00:00:00 2001
From: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Date: Wed, 21 Sep 2022 07:36:39 +1200
Subject: [PATCH 3/3] Bump version to 2022.9.0b4

---
 esphome/const.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/esphome/const.py b/esphome/const.py
index 02cbe02ba2..0fe271cd5a 100644
--- a/esphome/const.py
+++ b/esphome/const.py
@@ -1,6 +1,6 @@
 """Constants used by esphome."""
 
-__version__ = "2022.9.0b3"
+__version__ = "2022.9.0b4"
 
 ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"