ESPHome  2024.11.0
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::web_server::WebServer Class Reference

This class allows users to create a web server with their ESP nodes. More...

#include <web_server.h>

Inheritance diagram for esphome::web_server::WebServer:
esphome::Controller esphome::Component

Public Member Functions

 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. More...
 
void set_js_url (const char *js_url)
 Set the URL to the script that's embedded in the index page. More...
 
void set_css_include (const char *css_include)
 Set local path to the script that's embedded in the index page. More...
 
void set_js_include (const char *js_include)
 Set local path to the script that's embedded in the index page. More...
 
void set_include_internal (bool include_internal)
 Determine whether internal components should be displayed on the web server. More...
 
void set_allow_ota (bool allow_ota)
 Set whether or not the webserver should expose the OTA form and handler. More...
 
void set_expose_log (bool expose_log)
 Set whether or not the webserver should expose the Log. More...
 
void setup () override
 Setup the internal web server and register handlers. More...
 
void loop () override
 
void dump_config () override
 
float get_setup_priority () const override
 MQTT setup priority. More...
 
void handle_index_request (AsyncWebServerRequest *request)
 Handle an index request under '/'. More...
 
std::string get_config_json ()
 Return the webserver configuration as JSON. More...
 
void handle_css_request (AsyncWebServerRequest *request)
 Handle included css request under '/0.css'. More...
 
void handle_js_request (AsyncWebServerRequest *request)
 Handle included js request under '/0.js'. More...
 
void handle_pna_cors_request (AsyncWebServerRequest *request)
 
void on_sensor_update (sensor::Sensor *obj, float state) override
 
void handle_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a sensor request under '/sensor/<id>'. More...
 
std::string sensor_json (sensor::Sensor *obj, float value, JsonDetail start_config)
 Dump the sensor state with its value as a JSON string. More...
 
void on_switch_update (switch_::Switch *obj, bool state) override
 
void handle_switch_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a switch request under '/switch/<id>/</turn_on/turn_off/toggle>'. More...
 
std::string switch_json (switch_::Switch *obj, bool value, JsonDetail start_config)
 Dump the switch state with its value as a JSON string. More...
 
void handle_button_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a button request under '/button/<id>/press'. More...
 
std::string button_json (button::Button *obj, JsonDetail start_config)
 Dump the button details with its value as a JSON string. More...
 
void on_binary_sensor_update (binary_sensor::BinarySensor *obj, bool state) override
 
void handle_binary_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a binary sensor request under '/binary_sensor/<id>'. More...
 
std::string binary_sensor_json (binary_sensor::BinarySensor *obj, bool value, JsonDetail start_config)
 Dump the binary sensor state with its value as a JSON string. More...
 
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>'. More...
 
std::string fan_json (fan::Fan *obj, JsonDetail start_config)
 Dump the fan state as a JSON string. More...
 
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>'. More...
 
std::string light_json (light::LightState *obj, JsonDetail start_config)
 Dump the light state as a JSON string. More...
 
void on_text_sensor_update (text_sensor::TextSensor *obj, const std::string &state) override
 
void handle_text_sensor_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a text sensor request under '/text_sensor/<id>'. More...
 
std::string text_sensor_json (text_sensor::TextSensor *obj, const std::string &value, JsonDetail start_config)
 Dump the text sensor state with its value as a JSON string. More...
 
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>'. More...
 
std::string cover_json (cover::Cover *obj, JsonDetail start_config)
 Dump the cover state as a JSON string. More...
 
void on_number_update (number::Number *obj, float state) override
 
void handle_number_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a number request under '/number/<id>'. More...
 
std::string number_json (number::Number *obj, float value, JsonDetail start_config)
 Dump the number state with its value as a JSON string. More...
 
void on_date_update (datetime::DateEntity *obj) override
 
void handle_date_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a date request under '/date/<id>'. More...
 
std::string date_json (datetime::DateEntity *obj, JsonDetail start_config)
 Dump the date state with its value as a JSON string. More...
 
void on_time_update (datetime::TimeEntity *obj) override
 
void handle_time_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a time request under '/time/<id>'. More...
 
std::string time_json (datetime::TimeEntity *obj, JsonDetail start_config)
 Dump the time state with its value as a JSON string. More...
 
void on_datetime_update (datetime::DateTimeEntity *obj) override
 
void handle_datetime_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a datetime request under '/datetime/<id>'. More...
 
std::string datetime_json (datetime::DateTimeEntity *obj, JsonDetail start_config)
 Dump the datetime state with its value as a JSON string. More...
 
void on_text_update (text::Text *obj, const std::string &state) override
 
void handle_text_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a text input request under '/text/<id>'. More...
 
std::string text_json (text::Text *obj, const std::string &value, JsonDetail start_config)
 Dump the text state with its value as a JSON string. More...
 
void on_select_update (select::Select *obj, const std::string &state, size_t index) override
 
void handle_select_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a select request under '/select/<id>'. More...
 
std::string select_json (select::Select *obj, const std::string &value, JsonDetail start_config)
 Dump the select state with its value as a JSON string. More...
 
void on_climate_update (climate::Climate *obj) override
 
void handle_climate_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a climate request under '/climate/<id>'. More...
 
std::string climate_json (climate::Climate *obj, JsonDetail start_config)
 Dump the climate details. More...
 
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>'. More...
 
std::string lock_json (lock::Lock *obj, lock::LockState value, JsonDetail start_config)
 Dump the lock state with its value as a JSON string. More...
 
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>'. More...
 
std::string valve_json (valve::Valve *obj, JsonDetail start_config)
 Dump the valve state as a JSON string. More...
 
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>'. More...
 
std::string alarm_control_panel_json (alarm_control_panel::AlarmControlPanel *obj, alarm_control_panel::AlarmControlPanelState value, JsonDetail start_config)
 Dump the alarm_control_panel state with its value as a JSON string. More...
 
void on_event (event::Event *obj, const std::string &event_type) override
 
void handle_event_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a event request under '/event<id>'. More...
 
std::string event_json (event::Event *obj, const std::string &event_type, JsonDetail start_config)
 Dump the event details with its value as a JSON string. More...
 
void on_update (update::UpdateEntity *obj) override
 
void handle_update_request (AsyncWebServerRequest *request, const UrlMatch &match)
 Handle a update request under '/update/<id>'. More...
 
std::string update_json (update::UpdateEntity *obj, JsonDetail start_config)
 Dump the update state with its value as a JSON string. More...
 
bool canHandle (AsyncWebServerRequest *request) override
 Override the web handler's canHandle method. More...
 
void handleRequest (AsyncWebServerRequest *request) override
 Override the web handler's handleRequest method. More...
 
bool isRequestHandlerTrivial () override
 This web handle is not trivial. More...
 
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)
 
- Public Member Functions inherited from esphome::Controller
void setup_controller (bool include_internal=false)
 
virtual void on_media_player_update (media_player::MediaPlayer *obj)
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
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="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 

Protected Member Functions

void schedule_ (std::function< void()> &&f)
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_setup ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

friend ListEntitiesIterator
 
web_server_base::WebServerBasebase_
 
AsyncEventSource events_ {"/events"}
 
ListEntitiesIterator entities_iterator_
 
std::map< EntityBase *, SortingComponentssorting_entitys_
 
std::map< uint64_t, SortingGroupsorting_groups_
 
const char * css_url_ {nullptr}
 
const char * js_url_ {nullptr}
 
const char * css_include_ {nullptr}
 
const char * js_include_ {nullptr}
 
bool include_internal_ {false}
 
bool allow_ota_ {true}
 
bool expose_log_ {true}
 
std::deque< std::function< void()> > to_schedule_
 
SemaphoreHandle_t to_schedule_lock_
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 

Detailed Description

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/index.html.

Definition at line 66 of file web_server.h.

Constructor & Destructor Documentation

◆ WebServer()

esphome::web_server::WebServer::WebServer ( web_server_base::WebServerBase base)

Definition at line 75 of file web_server.cpp.

Member Function Documentation

◆ add_entity_config()

void esphome::web_server::WebServer::add_entity_config ( EntityBase entity,
float  weight,
uint64_t  group 
)

Definition at line 1849 of file web_server.cpp.

◆ add_sorting_group()

void esphome::web_server::WebServer::add_sorting_group ( uint64_t  group_id,
const std::string &  group_name,
float  weight 
)

Definition at line 1853 of file web_server.cpp.

◆ alarm_control_panel_json()

std::string esphome::web_server::WebServer::alarm_control_panel_json ( alarm_control_panel::AlarmControlPanel obj,
alarm_control_panel::AlarmControlPanelState  value,
JsonDetail  start_config 
)

Dump the alarm_control_panel state with its value as a JSON string.

Definition at line 1421 of file web_server.cpp.

◆ binary_sensor_json()

std::string esphome::web_server::WebServer::binary_sensor_json ( binary_sensor::BinarySensor obj,
bool  value,
JsonDetail  start_config 
)

Dump the binary sensor state with its value as a JSON string.

Definition at line 420 of file web_server.cpp.

◆ button_json()

std::string esphome::web_server::WebServer::button_json ( button::Button obj,
JsonDetail  start_config 
)

Dump the button details with its value as a JSON string.

Definition at line 382 of file web_server.cpp.

◆ canHandle()

bool esphome::web_server::WebServer::canHandle ( AsyncWebServerRequest *  request)
override

Override the web handler's canHandle method.

Definition at line 1552 of file web_server.cpp.

◆ climate_json()

std::string esphome::web_server::WebServer::climate_json ( climate::Climate obj,
JsonDetail  start_config 
)

Dump the climate details.

Definition at line 1177 of file web_server.cpp.

◆ cover_json()

std::string esphome::web_server::WebServer::cover_json ( cover::Cover obj,
JsonDetail  start_config 
)

Dump the cover state as a JSON string.

Definition at line 703 of file web_server.cpp.

◆ date_json()

std::string esphome::web_server::WebServer::date_json ( datetime::DateEntity obj,
JsonDetail  start_config 
)

Dump the date state with its value as a JSON string.

Definition at line 843 of file web_server.cpp.

◆ datetime_json()

std::string esphome::web_server::WebServer::datetime_json ( datetime::DateTimeEntity obj,
JsonDetail  start_config 
)

Dump the datetime state with its value as a JSON string.

Definition at line 965 of file web_server.cpp.

◆ dump_config()

void esphome::web_server::WebServer::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 152 of file web_server.cpp.

◆ event_json()

std::string esphome::web_server::WebServer::event_json ( event::Event obj,
const std::string &  event_type,
JsonDetail  start_config 
)

Dump the event details with its value as a JSON string.

Definition at line 1462 of file web_server.cpp.

◆ fan_json()

std::string esphome::web_server::WebServer::fan_json ( fan::Fan obj,
JsonDetail  start_config 
)

Dump the fan state as a JSON string.

Definition at line 499 of file web_server.cpp.

◆ get_config_json()

std::string esphome::web_server::WebServer::get_config_json ( )

Return the webserver configuration as JSON.

Definition at line 89 of file web_server.cpp.

◆ get_setup_priority()

float esphome::web_server::WebServer::get_setup_priority ( ) const
overridevirtual

MQTT setup priority.

Reimplemented from esphome::Component.

Definition at line 156 of file web_server.cpp.

◆ handle_alarm_control_panel_request()

void esphome::web_server::WebServer::handle_alarm_control_panel_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a alarm_control_panel request under '/alarm_control_panel/<id>'.

Definition at line 1403 of file web_server.cpp.

◆ handle_binary_sensor_request()

void esphome::web_server::WebServer::handle_binary_sensor_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a binary sensor request under '/binary_sensor/<id>'.

Definition at line 403 of file web_server.cpp.

◆ handle_button_request()

void esphome::web_server::WebServer::handle_button_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a button request under '/button/<id>/press'.

Definition at line 359 of file web_server.cpp.

◆ handle_climate_request()

void esphome::web_server::WebServer::handle_climate_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a climate request under '/climate/<id>'.

Definition at line 1116 of file web_server.cpp.

◆ handle_cover_request()

void esphome::web_server::WebServer::handle_cover_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a cover request under '/cover/<id>/<open/close/stop/set>'.

Definition at line 647 of file web_server.cpp.

◆ handle_css_request()

void esphome::web_server::WebServer::handle_css_request ( AsyncWebServerRequest *  request)

Handle included css request under '/0.css'.

Definition at line 185 of file web_server.cpp.

◆ handle_date_request()

void esphome::web_server::WebServer::handle_date_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a date request under '/date/<id>'.

Definition at line 805 of file web_server.cpp.

◆ handle_datetime_request()

void esphome::web_server::WebServer::handle_datetime_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a datetime request under '/datetime/<id>'.

Definition at line 928 of file web_server.cpp.

◆ handle_event_request()

void esphome::web_server::WebServer::handle_event_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a event request under '/event<id>'.

Definition at line 1444 of file web_server.cpp.

◆ handle_fan_request()

void esphome::web_server::WebServer::handle_fan_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a fan request under '/fan/<id>/</turn_on/turn_off/toggle>'.

Definition at line 442 of file web_server.cpp.

◆ handle_index_request()

void esphome::web_server::WebServer::handle_index_request ( AsyncWebServerRequest *  request)

Handle an index request under '/'.

Definition at line 159 of file web_server.cpp.

◆ handle_js_request()

void esphome::web_server::WebServer::handle_js_request ( AsyncWebServerRequest *  request)

Handle included js request under '/0.js'.

Definition at line 194 of file web_server.cpp.

◆ handle_light_request()

void esphome::web_server::WebServer::handle_light_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a light request under '/light/<id>/</turn_on/turn_off/toggle>'.

Definition at line 528 of file web_server.cpp.

◆ handle_lock_request()

void esphome::web_server::WebServer::handle_lock_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a lock request under '/lock/<id>/</lock/unlock/open>'.

Definition at line 1277 of file web_server.cpp.

◆ handle_number_request()

void esphome::web_server::WebServer::handle_number_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a number request under '/number/<id>'.

Definition at line 731 of file web_server.cpp.

◆ handle_pna_cors_request()

void esphome::web_server::WebServer::handle_pna_cors_request ( AsyncWebServerRequest *  request)

Definition at line 174 of file web_server.cpp.

◆ handle_select_request()

void esphome::web_server::WebServer::handle_select_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a select request under '/select/<id>'.

Definition at line 1054 of file web_server.cpp.

◆ handle_sensor_request()

void esphome::web_server::WebServer::handle_sensor_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a sensor request under '/sensor/<id>'.

Definition at line 226 of file web_server.cpp.

◆ handle_switch_request()

void esphome::web_server::WebServer::handle_switch_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a switch request under '/switch/<id>/</turn_on/turn_off/toggle>'.

Definition at line 313 of file web_server.cpp.

◆ handle_text_request()

void esphome::web_server::WebServer::handle_text_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a text input request under '/text/<id>'.

Definition at line 990 of file web_server.cpp.

◆ handle_text_sensor_request()

void esphome::web_server::WebServer::handle_text_sensor_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a text sensor request under '/text_sensor/<id>'.

Definition at line 274 of file web_server.cpp.

◆ handle_time_request()

void esphome::web_server::WebServer::handle_time_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a time request under '/time/<id>'.

Definition at line 867 of file web_server.cpp.

◆ handle_update_request()

void esphome::web_server::WebServer::handle_update_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a update request under '/update/<id>'.

Definition at line 1491 of file web_server.cpp.

◆ handle_valve_request()

void esphome::web_server::WebServer::handle_valve_request ( AsyncWebServerRequest *  request,
const UrlMatch match 
)

Handle a valve request under '/valve/<id>/<open/close/stop/set>'.

Definition at line 1328 of file web_server.cpp.

◆ handleRequest()

void esphome::web_server::WebServer::handleRequest ( AsyncWebServerRequest *  request)
override

Override the web handler's handleRequest method.

Definition at line 1683 of file web_server.cpp.

◆ isRequestHandlerTrivial()

bool esphome::web_server::WebServer::isRequestHandlerTrivial ( )
override

This web handle is not trivial.

Definition at line 1847 of file web_server.cpp.

◆ light_json()

std::string esphome::web_server::WebServer::light_json ( light::LightState obj,
JsonDetail  start_config 
)

Dump the light state as a JSON string.

Definition at line 618 of file web_server.cpp.

◆ lock_json()

std::string esphome::web_server::WebServer::lock_json ( lock::Lock obj,
lock::LockState  value,
JsonDetail  start_config 
)

Dump the lock state with its value as a JSON string.

Definition at line 1306 of file web_server.cpp.

◆ loop()

void esphome::web_server::WebServer::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 133 of file web_server.cpp.

◆ number_json()

std::string esphome::web_server::WebServer::number_json ( number::Number obj,
float  value,
JsonDetail  start_config 
)

Dump the number state with its value as a JSON string.

Definition at line 765 of file web_server.cpp.

◆ on_alarm_control_panel_update()

void esphome::web_server::WebServer::on_alarm_control_panel_update ( alarm_control_panel::AlarmControlPanel obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1398 of file web_server.cpp.

◆ on_binary_sensor_update()

void esphome::web_server::WebServer::on_binary_sensor_update ( binary_sensor::BinarySensor obj,
bool  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 398 of file web_server.cpp.

◆ on_climate_update()

void esphome::web_server::WebServer::on_climate_update ( climate::Climate obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1111 of file web_server.cpp.

◆ on_cover_update()

void esphome::web_server::WebServer::on_cover_update ( cover::Cover obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 642 of file web_server.cpp.

◆ on_date_update()

void esphome::web_server::WebServer::on_date_update ( datetime::DateEntity obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 800 of file web_server.cpp.

◆ on_datetime_update()

void esphome::web_server::WebServer::on_datetime_update ( datetime::DateTimeEntity obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 923 of file web_server.cpp.

◆ on_event()

void esphome::web_server::WebServer::on_event ( event::Event obj,
const std::string &  event_type 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1441 of file web_server.cpp.

◆ on_fan_update()

void esphome::web_server::WebServer::on_fan_update ( fan::Fan obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 437 of file web_server.cpp.

◆ on_light_update()

void esphome::web_server::WebServer::on_light_update ( light::LightState obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 523 of file web_server.cpp.

◆ on_lock_update()

void esphome::web_server::WebServer::on_lock_update ( lock::Lock obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1272 of file web_server.cpp.

◆ on_number_update()

void esphome::web_server::WebServer::on_number_update ( number::Number obj,
float  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 726 of file web_server.cpp.

◆ on_select_update()

void esphome::web_server::WebServer::on_select_update ( select::Select obj,
const std::string &  state,
size_t  index 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1049 of file web_server.cpp.

◆ on_sensor_update()

void esphome::web_server::WebServer::on_sensor_update ( sensor::Sensor obj,
float  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 221 of file web_server.cpp.

◆ on_switch_update()

void esphome::web_server::WebServer::on_switch_update ( switch_::Switch obj,
bool  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 308 of file web_server.cpp.

◆ on_text_sensor_update()

void esphome::web_server::WebServer::on_text_sensor_update ( text_sensor::TextSensor obj,
const std::string &  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 269 of file web_server.cpp.

◆ on_text_update()

void esphome::web_server::WebServer::on_text_update ( text::Text obj,
const std::string &  state 
)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 985 of file web_server.cpp.

◆ on_time_update()

void esphome::web_server::WebServer::on_time_update ( datetime::TimeEntity obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 862 of file web_server.cpp.

◆ on_update()

void esphome::web_server::WebServer::on_update ( update::UpdateEntity obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1486 of file web_server.cpp.

◆ on_valve_update()

void esphome::web_server::WebServer::on_valve_update ( valve::Valve obj)
overridevirtual

Reimplemented from esphome::Controller.

Definition at line 1323 of file web_server.cpp.

◆ schedule_()

void esphome::web_server::WebServer::schedule_ ( std::function< void()> &&  f)
protected

Definition at line 1857 of file web_server.cpp.

◆ select_json()

std::string esphome::web_server::WebServer::select_json ( select::Select obj,
const std::string &  value,
JsonDetail  start_config 
)

Dump the select state with its value as a JSON string.

Definition at line 1088 of file web_server.cpp.

◆ sensor_json()

std::string esphome::web_server::WebServer::sensor_json ( sensor::Sensor obj,
float  value,
JsonDetail  start_config 
)

Dump the sensor state with its value as a JSON string.

Definition at line 243 of file web_server.cpp.

◆ set_allow_ota()

void esphome::web_server::WebServer::set_allow_ota ( bool  allow_ota)
inline

Set whether or not the webserver should expose the OTA form and handler.

Parameters
allow_ota.

Definition at line 112 of file web_server.h.

◆ set_css_include()

void esphome::web_server::WebServer::set_css_include ( const char *  css_include)

Set local path to the script that's embedded in the index page.

Defaults to

Parameters
css_includeLocal path to web server script.

Definition at line 83 of file web_server.cpp.

◆ set_css_url()

void esphome::web_server::WebServer::set_css_url ( const char *  css_url)

Set the URL to the CSS <link> that's sent to each client.

Defaults to https://esphome.io/_static/webserver-v1.min.css

Parameters
css_urlThe url to the web server stylesheet.

Definition at line 30 of file web_server_v1.cpp.

◆ set_expose_log()

void esphome::web_server::WebServer::set_expose_log ( bool  expose_log)
inline

Set whether or not the webserver should expose the Log.

Parameters
expose_log.

Definition at line 117 of file web_server.h.

◆ set_include_internal()

void esphome::web_server::WebServer::set_include_internal ( bool  include_internal)
inline

Determine whether internal components should be displayed on the web server.

Defaults to false.

Parameters
include_internalWhether internal components should be displayed.

Definition at line 107 of file web_server.h.

◆ set_js_include()

void esphome::web_server::WebServer::set_js_include ( const char *  js_include)

Set local path to the script that's embedded in the index page.

Defaults to

Parameters
js_includeLocal path to web server script.

Definition at line 86 of file web_server.cpp.

◆ set_js_url()

void esphome::web_server::WebServer::set_js_url ( const char *  js_url)

Set the URL to the script that's embedded in the index page.

Defaults to https://esphome.io/_static/webserver-v1.min.js

Parameters
js_urlThe url to the web server script.

Definition at line 32 of file web_server_v1.cpp.

◆ setup()

void esphome::web_server::WebServer::setup ( )
overridevirtual

Setup the internal web server and register handlers.

Reimplemented from esphome::Component.

Definition at line 99 of file web_server.cpp.

◆ switch_json()

std::string esphome::web_server::WebServer::switch_json ( switch_::Switch obj,
bool  value,
JsonDetail  start_config 
)

Dump the switch state with its value as a JSON string.

Definition at line 342 of file web_server.cpp.

◆ text_json()

std::string esphome::web_server::WebServer::text_json ( text::Text obj,
const std::string &  value,
JsonDetail  start_config 
)

Dump the text state with its value as a JSON string.

Definition at line 1023 of file web_server.cpp.

◆ text_sensor_json()

std::string esphome::web_server::WebServer::text_sensor_json ( text_sensor::TextSensor obj,
const std::string &  value,
JsonDetail  start_config 
)

Dump the text sensor state with its value as a JSON string.

Definition at line 291 of file web_server.cpp.

◆ time_json()

std::string esphome::web_server::WebServer::time_json ( datetime::TimeEntity obj,
JsonDetail  start_config 
)

Dump the time state with its value as a JSON string.

Definition at line 904 of file web_server.cpp.

◆ update_json()

std::string esphome::web_server::WebServer::update_json ( update::UpdateEntity obj,
JsonDetail  start_config 
)

Dump the update state with its value as a JSON string.

Definition at line 1518 of file web_server.cpp.

◆ valve_json()

std::string esphome::web_server::WebServer::valve_json ( valve::Valve obj,
JsonDetail  start_config 
)

Dump the valve state as a JSON string.

Definition at line 1377 of file web_server.cpp.

Field Documentation

◆ allow_ota_

bool esphome::web_server::WebServer::allow_ota_ {true}
protected

Definition at line 372 of file web_server.h.

◆ base_

web_server_base::WebServerBase* esphome::web_server::WebServer::base_
protected

Definition at line 355 of file web_server.h.

◆ css_include_

const char* esphome::web_server::WebServer::css_include_ {nullptr}
protected

Definition at line 366 of file web_server.h.

◆ css_url_

const char* esphome::web_server::WebServer::css_url_ {nullptr}
protected

Definition at line 362 of file web_server.h.

◆ entities_iterator_

ListEntitiesIterator esphome::web_server::WebServer::entities_iterator_
protected

Definition at line 357 of file web_server.h.

◆ events_

AsyncEventSource esphome::web_server::WebServer::events_ {"/events"}
protected

Definition at line 356 of file web_server.h.

◆ expose_log_

bool esphome::web_server::WebServer::expose_log_ {true}
protected

Definition at line 373 of file web_server.h.

◆ include_internal_

bool esphome::web_server::WebServer::include_internal_ {false}
protected

Definition at line 371 of file web_server.h.

◆ js_include_

const char* esphome::web_server::WebServer::js_include_ {nullptr}
protected

Definition at line 369 of file web_server.h.

◆ js_url_

const char* esphome::web_server::WebServer::js_url_ {nullptr}
protected

Definition at line 363 of file web_server.h.

◆ ListEntitiesIterator

friend esphome::web_server::WebServer::ListEntitiesIterator
protected

Definition at line 354 of file web_server.h.

◆ sorting_entitys_

std::map<EntityBase *, SortingComponents> esphome::web_server::WebServer::sorting_entitys_
protected

Definition at line 358 of file web_server.h.

◆ sorting_groups_

std::map<uint64_t, SortingGroup> esphome::web_server::WebServer::sorting_groups_
protected

Definition at line 359 of file web_server.h.

◆ to_schedule_

std::deque<std::function<void()> > esphome::web_server::WebServer::to_schedule_
protected

Definition at line 375 of file web_server.h.

◆ to_schedule_lock_

SemaphoreHandle_t esphome::web_server::WebServer::to_schedule_lock_
protected

Definition at line 376 of file web_server.h.


The documentation for this class was generated from the following files: