|
| | WebServer (web_server_base::WebServerBase *base) |
| |
| void | set_css_url (const char *css_url) |
| | Set the URL to the CSS <link> that's sent to each client.
|
| |
| void | set_js_url (const char *js_url) |
| | Set the URL to the script that's embedded in the index page.
|
| |
| void | set_css_include (const char *css_include) |
| | Set local path to the script that's embedded in the index page.
|
| |
| void | set_js_include (const char *js_include) |
| | Set local path to the script that's embedded in the index page.
|
| |
| void | set_include_internal (bool include_internal) |
| | Determine whether internal components should be displayed on the web server.
|
| |
| void | set_expose_log (bool expose_log) |
| | Set whether or not the webserver should expose the Log.
|
| |
| void | setup () override |
| | Setup the internal web server and register handlers.
|
| |
| void | loop () override |
| |
| void | dump_config () override |
| |
| void | on_log (uint8_t level, const char *tag, const char *message, size_t message_len) override |
| |
| float | get_setup_priority () const override |
| | MQTT setup priority.
|
| |
| void | handle_index_request (AsyncWebServerRequest *request) |
| | Handle an index request under '/'.
|
| |
| std::string | get_config_json () |
| | Return the webserver configuration as JSON.
|
| |
| void | handle_css_request (AsyncWebServerRequest *request) |
| | Handle included css request under '/0.css'.
|
| |
| void | handle_js_request (AsyncWebServerRequest *request) |
| | Handle included js request under '/0.js'.
|
| |
| void | handle_pna_cors_request (AsyncWebServerRequest *request) |
| |
| void | on_sensor_update (sensor::Sensor *obj) override |
| |
| void | handle_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a sensor request under '/sensor/<id>'.
|
| |
| void | on_switch_update (switch_::Switch *obj) override |
| |
| void | handle_switch_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a switch request under '/switch/<id>/</turn_on/turn_off/toggle>'.
|
| |
| void | handle_button_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a button request under '/button/<id>/press'.
|
| |
| void | on_binary_sensor_update (binary_sensor::BinarySensor *obj) override |
| |
| void | handle_binary_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a binary sensor request under '/binary_sensor/<id>'.
|
| |
| void | on_fan_update (fan::Fan *obj) override |
| |
| void | handle_fan_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a fan request under '/fan/<id>/</turn_on/turn_off/toggle>'.
|
| |
| void | on_light_update (light::LightState *obj) override |
| |
| void | handle_light_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a light request under '/light/<id>/</turn_on/turn_off/toggle>'.
|
| |
| void | on_text_sensor_update (text_sensor::TextSensor *obj) override |
| |
| void | handle_text_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a text sensor request under '/text_sensor/<id>'.
|
| |
| void | on_cover_update (cover::Cover *obj) override |
| |
| void | handle_cover_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a cover request under '/cover/<id>/<open/close/stop/set>'.
|
| |
| void | on_number_update (number::Number *obj) override |
| |
| void | handle_number_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a number request under '/number/<id>'.
|
| |
| void | on_date_update (datetime::DateEntity *obj) override |
| |
| void | handle_date_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a date request under '/date/<id>'.
|
| |
| void | on_time_update (datetime::TimeEntity *obj) override |
| |
| void | handle_time_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a time request under '/time/<id>'.
|
| |
| void | on_datetime_update (datetime::DateTimeEntity *obj) override |
| |
| void | handle_datetime_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a datetime request under '/datetime/<id>'.
|
| |
| void | on_text_update (text::Text *obj) override |
| |
| void | handle_text_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a text input request under '/text/<id>'.
|
| |
| void | on_select_update (select::Select *obj) override |
| |
| void | handle_select_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a select request under '/select/<id>'.
|
| |
| void | on_climate_update (climate::Climate *obj) override |
| |
| void | handle_climate_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a climate request under '/climate/<id>'.
|
| |
| void | on_lock_update (lock::Lock *obj) override |
| |
| void | handle_lock_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a lock request under '/lock/<id>/</lock/unlock/open>'.
|
| |
| void | on_valve_update (valve::Valve *obj) override |
| |
| void | handle_valve_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a valve request under '/valve/<id>/<open/close/stop/set>'.
|
| |
| void | on_alarm_control_panel_update (alarm_control_panel::AlarmControlPanel *obj) override |
| |
| void | handle_alarm_control_panel_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a alarm_control_panel request under '/alarm_control_panel/<id>'.
|
| |
| void | on_water_heater_update (water_heater::WaterHeater *obj) override |
| |
| void | handle_water_heater_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a water_heater request under '/water_heater/<id>/<mode/set>'.
|
| |
| void | handle_infrared_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle an infrared request under '/infrared/<id>/transmit'.
|
| |
| void | on_event (event::Event *obj) override |
| |
| void | handle_event_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a event request under '/event<id>'.
|
| |
| void | on_update (update::UpdateEntity *obj) override |
| |
| void | handle_update_request (AsyncWebServerRequest *request, const UrlMatch &match) |
| | Handle a update request under '/update/<id>'.
|
| |
| bool | canHandle (AsyncWebServerRequest *request) const override |
| | Override the web handler's canHandle method.
|
| |
| void | handleRequest (AsyncWebServerRequest *request) override |
| | Override the web handler's handleRequest method.
|
| |
| bool | isRequestHandlerTrivial () const override |
| | This web handle is not trivial.
|
| |
| void | add_entity_config (EntityBase *entity, float weight, uint64_t group) |
| |
| void | add_sorting_group (uint64_t group_id, const std::string &group_name, float weight) |
| |
| virtual void | on_media_player_update (media_player::MediaPlayer *obj) |
| |
| float | get_actual_setup_priority () const |
| |
| void | set_setup_priority (float priority) |
| |
| virtual float | get_loop_priority () const |
| | priority of loop().
|
| |
| void | call () |
| |
| virtual void | on_shutdown () |
| |
| virtual void | on_safe_shutdown () |
| |
| virtual bool | teardown () |
| | Called during teardown to allow component to gracefully finish operations.
|
| |
| virtual void | on_powerdown () |
| | Called after teardown is complete to power down hardware.
|
| |
| uint8_t | get_component_state () const |
| |
| void | reset_to_construction_state () |
| | Reset this component back to the construction state to allow setup to run again.
|
| |
| bool | is_in_loop_state () const |
| | Check if this component has completed setup and is in the loop state.
|
| |
| bool | is_idle () const |
| | Check if this component is idle.
|
| |
| virtual void | mark_failed () |
| | Mark this component as failed.
|
| |
| | ESPDEPRECATED ("Use mark_failed(LOG_STR(\"static string literal\")) instead. Do NOT use .c_str() from temporary " "strings. Will stop working in 2026.6.0", "2025.12.0") void mark_failed(const char *message) |
| |
| void | mark_failed (const LogString *message) |
| |
| void | disable_loop () |
| | Disable this component's loop.
|
| |
| void | enable_loop () |
| | Enable this component's loop.
|
| |
| void | enable_loop_soon_any_context () |
| | Thread and ISR-safe version of enable_loop() that can be called from any context.
|
| |
| bool | is_failed () const |
| |
| bool | is_ready () const |
| |
| virtual bool | can_proceed () |
| |
| bool | status_has_warning () const |
| |
| bool | status_has_error () const |
| |
| void | status_set_warning (const char *message=nullptr) |
| |
| void | status_set_warning (const LogString *message) |
| |
| void | status_set_error () |
| |
| | ESPDEPRECATED ("Use status_set_error(LOG_STR(\"static string literal\")) instead. Do NOT use .c_str() from temporary " "strings. Will stop working in 2026.6.0", "2025.12.0") void status_set_error(const char *message) |
| |
| void | status_set_error (const LogString *message) |
| |
| void | status_clear_warning () |
| |
| void | status_clear_error () |
| |
| void | status_momentary_warning (const char *name, uint32_t length=5000) |
| | Set warning status flag and automatically clear it after a timeout.
|
| |
| void | status_momentary_error (const char *name, uint32_t length=5000) |
| | Set error status flag and automatically clear it after a timeout.
|
| |
| bool | has_overridden_loop () const |
| |
| void | set_component_source (const LogString *source) |
| | Set where this component was loaded from for some debug messages.
|
| |
| const LogString * | get_component_log_str () const |
| | Get the integration where this component was declared as a LogString for logging.
|
| |
| bool | should_warn_of_blocking (uint32_t blocking_time) |
| |
|
| static std::string | sensor_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | sensor_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | switch_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | switch_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | button_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | binary_sensor_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | binary_sensor_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | fan_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | fan_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | light_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | light_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | text_sensor_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | text_sensor_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | cover_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | cover_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | number_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | number_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | date_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | date_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | time_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | time_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | datetime_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | datetime_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | text_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | text_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | select_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | select_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | climate_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | climate_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | lock_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | lock_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | valve_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | valve_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | alarm_control_panel_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | alarm_control_panel_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | water_heater_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | water_heater_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | infrared_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | event_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | event_all_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | update_state_json_generator (WebServer *web_server, void *source) |
| |
| static std::string | update_all_json_generator (WebServer *web_server, void *source) |
| |
|
| void | add_sorting_info_ (JsonObject &root, EntityBase *entity) |
| |
| template<typename T , typename Ret > |
| void | parse_light_param_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(float), float scale=1.0f) |
| |
| template<typename T , typename Ret > |
| void | parse_light_param_uint_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(uint32_t), uint32_t scale=1) |
| |
| template<typename T , typename Ret > |
| void | parse_float_param_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(float)) |
| |
| template<typename T , typename Ret > |
| void | parse_int_param_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(int)) |
| |
| template<typename T , typename Ret > |
| void | parse_string_param_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(const std::string &)) |
| |
| template<typename T , typename Ret > |
| void | parse_bool_param_ (AsyncWebServerRequest *request, ParamNameType param_name, T &call, Ret(T::*setter)(bool)) |
| |
| virtual void | call_loop () |
| |
| virtual void | call_setup () |
| |
| virtual void | call_dump_config () |
| |
| void | set_component_state_ (uint8_t state) |
| | Helper to set component state (clears state bits and sets new state)
|
| |
| void | set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a numeric ID (zero heap allocation).
|
| |
| void | set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f) |
| |
| void | set_interval (uint32_t interval, std::function< void()> &&f) |
| |
| bool | cancel_interval (uint32_t id) |
| |
| bool | cancel_interval (InternalSchedulerID id) |
| |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std | ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const char *name |
| |
| | ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(uint32_t id |
| |
| | ESPDEPRECATED ("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(uint32_t initial_wait_time |
| |
| ESPDEPRECATED("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(const std | ESPDEPRECATED ("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(const char *name) |
| |
| | ESPDEPRECATED ("cancel_retry is deprecated and will be removed in 2026.8.0.", "2026.2.0") bool cancel_retry(uint32_t id) |
| |
| void | set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a numeric ID (zero heap allocation).
|
| |
| void | set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f) |
| |
| void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
| |
| bool | cancel_timeout (uint32_t id) |
| |
| bool | cancel_timeout (InternalSchedulerID id) |
| |
| void | defer (std::function< void()> &&f) |
| | Defer a callback to the next loop() call.
|
| |
| void | defer (uint32_t id, std::function< void()> &&f) |
| | Defer a callback with a numeric ID (zero heap allocation)
|
| |
| bool | cancel_defer (uint32_t id) |
| |
|
| web_server_base::WebServerBase * | base_ |
| |
| AsyncEventSource | events_ {"/events", this} |
| |
| DeferredUpdateEventSourceList | events_ |
| |
| const char * | css_url_ {nullptr} |
| |
| const char * | js_url_ {nullptr} |
| |
| const char * | css_include_ {nullptr} |
| |
| const char * | js_include_ {nullptr} |
| |
| bool | expose_log_ {true} |
| |
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi | set_interval )(const char *name, uint32_t interval, std::function< void()> &&f) |
| | Set an interval function with a unique name.
|
| |
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_interval(const std boo | cancel_interval )(const char *name) |
| | Cancel an interval function.
|
| |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t | initial_wait_time |
| |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t | max_attempts |
| |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && | f |
| |
| ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) |
| |
| uint32_t | initial_wait_time |
| |
| uint32_t uint8_t | max_attempts |
| |
| uint32_t uint8_t std::function< RetryResult(uint8_t)> && | f |
| |
| uint32_t uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) |
| |
| uint8_t | max_attempts |
| |
| uint8_t std::function< RetryResult(uint8_t)> && | f |
| |
| uint8_t std::function< RetryResult(uint8_t)> float | backoff_increase_factor = 1.0f) |
| |
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi | set_timeout )(const char *name, uint32_t timeout, std::function< void()> &&f) |
| | Set a timeout function with a unique name.
|
| |
| ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_timeout(const std boo | cancel_timeout )(const char *name) |
| | Cancel a timeout function.
|
| |
| ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") void defer(const std voi | defer )(const char *name, std::function< void()> &&f) |
| | Defer a callback to the next loop() call.
|
| |
| ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_defer(const std boo | cancel_defer )(const char *name) |
| | Cancel a defer callback using the specified name, name must not be empty.
|
| |
| const LogString * | component_source_ {nullptr} |
| |
| uint16_t | warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_MS} |
| | Warn if blocked for this many ms (max 65.5s)
|
| |
| uint8_t | component_state_ {0x00} |
| | State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bits 5-7: Unused - reserved for future expansion.
|
| |
| volatile bool | pending_enable_loop_ {false} |
| | ISR-safe flag for enable_loop_soon_any_context.
|
| |
This class allows users to create a web server with their ESP nodes.
Behind the scenes it's using AsyncWebServer to set up the server. It exposes 3 things: an index page under '/' that's used to show a simple web interface (the css/js is hosted by esphome.io by default), an event source under '/events' that automatically sends all state updates in real time + the debug log. Lastly, there's an REST API available under the '/light/...', '/sensor/...', ... URLs. A full documentation for this API can be found under https://esphome.io/web-api/.
Definition at line 189 of file web_server.h.