WiFi Networks
++ Please give it some time to connect.
+ Note: Copy the changed network to your YAML file - the next OTA update will overwrite these settings. +
WiFi Settings
+ ++
+ +
diff --git a/esphome/components/captive_portal/__init__.py b/esphome/components/captive_portal/__init__.py new file mode 100644 index 0000000000..52885ae449 --- /dev/null +++ b/esphome/components/captive_portal/__init__.py @@ -0,0 +1,26 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import web_server_base +from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID +from esphome.const import CONF_ID +from esphome.core import coroutine_with_priority + +AUTO_LOAD = ['web_server_base'] +DEPENDENCIES = ['wifi'] + +captive_portal_ns = cg.esphome_ns.namespace('captive_portal') +CaptivePortal = captive_portal_ns.class_('CaptivePortal', cg.Component) + +CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(): cv.declare_id(CaptivePortal), + cv.GenerateID(CONF_WEB_SERVER_BASE_ID): cv.use_id(web_server_base.WebServerBase), +}).extend(cv.COMPONENT_SCHEMA) + + +@coroutine_with_priority(64.0) +def to_code(config): + paren = yield cg.get_variable(config[CONF_WEB_SERVER_BASE_ID]) + + var = cg.new_Pvariable(config[CONF_ID], paren) + yield cg.register_component(var, config) + cg.add_define('USE_CAPTIVE_PORTAL') diff --git a/esphome/components/captive_portal/captive_portal.cpp b/esphome/components/captive_portal/captive_portal.cpp new file mode 100644 index 0000000000..1b533b570e --- /dev/null +++ b/esphome/components/captive_portal/captive_portal.cpp @@ -0,0 +1,173 @@ +#include "captive_portal.h" +#include "esphome/core/log.h" +#include "esphome/core/application.h" +#include "esphome/components/wifi/wifi_component.h" + +namespace esphome { +namespace captive_portal { + +static const char *TAG = "captive_portal"; + +void CaptivePortal::handle_index(AsyncWebServerRequest *request) { + AsyncResponseStream *stream = request->beginResponseStream("text/html"); + stream->print(F("
See ESPHome Web API for " "REST API documentation.
" - "