1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-17 01:03:46 +01:00

Expose web_server port via the API (#2467)

This commit is contained in:
Alex Iribarren
2021-10-28 00:46:55 +02:00
committed by GitHub
parent b3d7cc637b
commit 0d3e6b2c4c
3 changed files with 30 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ from esphome.const import (
CONF_USE_ADDRESS,
CONF_ETHERNET,
CONF_WIFI,
CONF_PORT,
KEY_CORE,
KEY_TARGET_FRAMEWORK,
KEY_TARGET_PLATFORM,
@@ -519,6 +520,19 @@ class EsphomeCore:
return None
@property
def web_port(self) -> Optional[int]:
if self.config is None:
raise ValueError("Config has not been loaded yet")
if "web_server" in self.config:
try:
return self.config["web_server"][CONF_PORT]
except KeyError:
return 80
return None
@property
def comment(self) -> Optional[str]:
if self.config is None: