Fix configuration constants in core. (#3652)

This commit is contained in:
RoboMagus 2022-07-24 22:23:55 +02:00 committed by GitHub
parent d10300c330
commit 578671ea94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -749,6 +749,7 @@ CONF_WAND_ID = "wand_id"
CONF_WARM_WHITE = "warm_white" CONF_WARM_WHITE = "warm_white"
CONF_WARM_WHITE_COLOR_TEMPERATURE = "warm_white_color_temperature" CONF_WARM_WHITE_COLOR_TEMPERATURE = "warm_white_color_temperature"
CONF_WATCHDOG_THRESHOLD = "watchdog_threshold" CONF_WATCHDOG_THRESHOLD = "watchdog_threshold"
CONF_WEB_SERVER = "web_server"
CONF_WEIGHT = "weight" CONF_WEIGHT = "weight"
CONF_WHILE = "while" CONF_WHILE = "while"
CONF_WHITE = "white" CONF_WHITE = "white"

View file

@ -9,6 +9,7 @@ from esphome.const import (
CONF_ESPHOME, CONF_ESPHOME,
CONF_USE_ADDRESS, CONF_USE_ADDRESS,
CONF_ETHERNET, CONF_ETHERNET,
CONF_WEB_SERVER,
CONF_WIFI, CONF_WIFI,
CONF_PORT, CONF_PORT,
KEY_CORE, KEY_CORE,
@ -512,7 +513,7 @@ class EsphomeCore:
if self.config is None: if self.config is None:
raise ValueError("Config has not been loaded yet") 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] return self.config[CONF_WIFI][CONF_USE_ADDRESS]
if CONF_ETHERNET in self.config: if CONF_ETHERNET in self.config:
@ -525,9 +526,9 @@ class EsphomeCore:
if self.config is None: if self.config is None:
raise ValueError("Config has not been loaded yet") raise ValueError("Config has not been loaded yet")
if "web_server" in self.config: if CONF_WEB_SERVER in self.config:
try: try:
return self.config["web_server"][CONF_PORT] return self.config[CONF_WEB_SERVER][CONF_PORT]
except KeyError: except KeyError:
return 80 return 80