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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user