mirror of
https://github.com/esphome/esphome.git
synced 2025-11-16 23:05:46 +00:00
Merge branch 'integration' into memory_api
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import web_server_base
|
from esphome.components import web_server_base
|
||||||
from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID
|
from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID
|
||||||
from esphome.config_helpers import filter_source_files_from_platform
|
from esphome.config_helpers import filter_source_files_from_platform
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
|
CONF_AP,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
PLATFORM_BK72XX,
|
PLATFORM_BK72XX,
|
||||||
PLATFORM_ESP32,
|
PLATFORM_ESP32,
|
||||||
@@ -14,6 +17,10 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
from esphome.coroutine import CoroPriority
|
from esphome.coroutine import CoroPriority
|
||||||
|
import esphome.final_validate as fv
|
||||||
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def AUTO_LOAD() -> list[str]:
|
def AUTO_LOAD() -> list[str]:
|
||||||
@@ -50,6 +57,27 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _final_validate(config: ConfigType) -> ConfigType:
|
||||||
|
full_config = fv.full_config.get()
|
||||||
|
wifi_conf = full_config.get("wifi")
|
||||||
|
|
||||||
|
if wifi_conf is None:
|
||||||
|
# This shouldn't happen due to DEPENDENCIES = ["wifi"], but check anyway
|
||||||
|
raise cv.Invalid("Captive portal requires the wifi component to be configured")
|
||||||
|
|
||||||
|
if CONF_AP not in wifi_conf:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Captive portal is enabled but no WiFi AP is configured. "
|
||||||
|
"The captive portal will not be accessible. "
|
||||||
|
"Add 'ap:' to your WiFi configuration to enable the captive portal."
|
||||||
|
)
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
FINAL_VALIDATE_SCHEMA = _final_validate
|
||||||
|
|
||||||
|
|
||||||
@coroutine_with_priority(CoroPriority.CAPTIVE_PORTAL)
|
@coroutine_with_priority(CoroPriority.CAPTIVE_PORTAL)
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
paren = await cg.get_variable(config[CONF_WEB_SERVER_BASE_ID])
|
paren = await cg.get_variable(config[CONF_WEB_SERVER_BASE_ID])
|
||||||
|
|||||||
Reference in New Issue
Block a user