4 #if USE_WEBSERVER_VERSION == 1 9 void write_row(AsyncResponseStream *stream,
EntityBase *obj,
const std::string &klass,
const std::string &action,
10 const std::function<
void(AsyncResponseStream &stream,
EntityBase *obj)> &action_func =
nullptr) {
11 stream->print(
"<tr class=\"");
12 stream->print(klass.c_str());
14 stream->print(
" internal");
15 stream->print(
"\" id=\"");
16 stream->print(klass.c_str());
19 stream->print(
"\"><td>");
21 stream->print(
"</td><td></td><td>");
22 stream->print(action.c_str());
24 action_func(*stream, obj);
26 stream->print(
"</td>");
27 stream->print(
"</tr>");
35 AsyncResponseStream *stream = request->beginResponseStream(
"text/html");
37 stream->print(F(
"<!DOCTYPE html><html lang=\"en\"><head><meta charset=UTF-8><meta " 38 "name=viewport content=\"width=device-width, initial-scale=1,user-scalable=no\"><title>"));
39 stream->print(title.c_str());
40 stream->print(F(
"</title>"));
41 #ifdef USE_WEBSERVER_CSS_INCLUDE 42 stream->print(F(
"<link rel=\"stylesheet\" href=\"/0.css\">"));
45 stream->print(F(R
"(<link rel="stylesheet" href=")")); 47 stream->print(F("\">"));
49 stream->print(F(
"</head><body>"));
50 stream->print(F(
"<article class=\"markdown-body\"><h1>"));
51 stream->print(title.c_str());
52 stream->print(F(
"</h1>"));
53 stream->print(F(
"<h2>States</h2><table id=\"states\"><thead><tr><th>Name<th>State<th>Actions<tbody>"));
65 write_row(stream, obj,
"switch",
"<button>Toggle</button>");
71 write_row(stream, obj,
"button",
"<button>Press</button>");
74 #ifdef USE_BINARY_SENSOR 77 write_row(stream, obj,
"binary_sensor",
"");
84 write_row(stream, obj,
"fan",
"<button>Toggle</button>");
91 write_row(stream, obj,
"light",
"<button>Toggle</button>");
95 #ifdef USE_TEXT_SENSOR 98 write_row(stream, obj,
"text_sensor",
"");
105 write_row(stream, obj,
"cover",
"<button>Open</button><button>Close</button>");
114 stream.print(R
"(<input type="number" min=")"); 116 stream.print(R"(" max=")"); 118 stream.print(R"(" step=")"); 120 stream.print(R"(" value=")"); 121 stream.print(number->state); 122 stream.print(R"("/>)"); 134 stream.print(R
"(<input type=")"); 136 stream.print(R
"(password)"); 138 stream.print(R
"(text)"); 140 stream.print(R"(" minlength=")"); 142 stream.print(R"(" maxlength=")"); 144 stream.print(R"(" pattern=")"); 146 stream.print(R"(" value=")"); 147 stream.print(text->state.c_str()); 148 stream.print(R"("/>)"); 159 stream.print(
"<select>");
160 stream.print(
"<option></option>");
162 stream.print(
"<option>");
163 stream.print(option.c_str());
164 stream.print(
"</option>");
166 stream.print(
"</select>");
177 stream.print(
"<button>Lock</button><button>Unlock</button>");
179 stream.print(
"<button>Open</button>");
193 stream->print(F(
"</tbody></table><p>See <a href=\"https://esphome.io/web-api/index.html\">ESPHome Web API</a> for " 194 "REST API documentation.</p>"));
197 F(
"<h2>OTA Update</h2><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input " 198 "type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"));
200 stream->print(F(
"<h2>Debug Log</h2><pre id=\"log\"></pre>"));
201 #ifdef USE_WEBSERVER_JS_INCLUDE 203 stream->print(F(
"<script type=\"module\" src=\"/0.js\"></script>"));
206 if (strlen(this->
js_url_) > 0) {
207 stream->print(F(
"<script src=\""));
209 stream->print(F(
"\"></script>"));
211 stream->print(F(
"</article></body></html>"));
212 request->send(stream);
TextMode get_mode() const
const std::vector< climate::Climate * > & get_climates()
void write_row(AsyncResponseStream *stream, EntityBase *obj, const std::string &klass, const std::string &action, const std::function< void(AsyncResponseStream &stream, EntityBase *obj)> &action_func=nullptr)
const std::vector< fan::Fan * > & get_fans()
int get_max_length() const
Base-class for all text inputs.
std::string get_object_id() const
const std::vector< lock::Lock * > & get_locks()
const std::vector< button::Button * > & get_buttons()
std::vector< std::string > get_options() const
const std::vector< switch_::Switch * > & get_switches()
Base-class for all numbers.
BedjetMode mode
BedJet operating mode.
const std::vector< text_sensor::TextSensor * > & get_text_sensors()
const std::vector< sensor::Sensor * > & get_sensors()
Application App
Global storage of Application pointer - only one Application can exist.
const std::vector< binary_sensor::BinarySensor * > & get_binary_sensors()
const std::string & get_name() const
Get the name of this Application set by pre_setup().
const std::vector< text::Text * > & get_texts()
void handle_index_request(AsyncWebServerRequest *request)
Handle an index request under '/'.
const std::vector< cover::Cover * > & get_covers()
constexpr const char * c_str() const
void set_js_url(const char *js_url)
Set the URL to the script that's embedded in the index page.
void set_css_url(const char *css_url)
Set the URL to the CSS <link> that's sent to each client.
const std::vector< light::LightState * > & get_lights()
Base-class for all selects.
Implementation of SPI Controller mode.
float get_min_value() const
int get_min_length() const
const std::vector< select::Select * > & get_selects()
const std::vector< number::Number * > & get_numbers()
float get_max_value() const
bool get_supports_open() const
std::string get_pattern() const
const StringRef & get_name() const
Base class for all locks.