From 578671ea94c5dbc8aa10afd853be4931a5f0f6bf Mon Sep 17 00:00:00 2001 From: RoboMagus <68224306+RoboMagus@users.noreply.github.com> Date: Sun, 24 Jul 2022 22:23:55 +0200 Subject: [PATCH] Fix configuration constants in core. (#3652) --- esphome/const.py | 1 + esphome/core/__init__.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/const.py b/esphome/const.py index f711d6fbf0..df3654639d 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -749,6 +749,7 @@ CONF_WAND_ID = "wand_id" CONF_WARM_WHITE = "warm_white" CONF_WARM_WHITE_COLOR_TEMPERATURE = "warm_white_color_temperature" CONF_WATCHDOG_THRESHOLD = "watchdog_threshold" +CONF_WEB_SERVER = "web_server" CONF_WEIGHT = "weight" CONF_WHILE = "while" CONF_WHITE = "white" diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 2c91bb4c9c..3ee94efd64 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -9,6 +9,7 @@ from esphome.const import ( CONF_ESPHOME, CONF_USE_ADDRESS, CONF_ETHERNET, + CONF_WEB_SERVER, CONF_WIFI, CONF_PORT, KEY_CORE, @@ -512,7 +513,7 @@ class EsphomeCore: if self.config is None: raise ValueError("Config has not been loaded yet") - if "wifi" in self.config: + if CONF_WIFI in self.config: return self.config[CONF_WIFI][CONF_USE_ADDRESS] if CONF_ETHERNET in self.config: @@ -525,9 +526,9 @@ class EsphomeCore: if self.config is None: raise ValueError("Config has not been loaded yet") - if "web_server" in self.config: + if CONF_WEB_SERVER in self.config: try: - return self.config["web_server"][CONF_PORT] + return self.config[CONF_WEB_SERVER][CONF_PORT] except KeyError: return 80