1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-24 12:43:51 +01:00

web_server: Add cover calls to REST API (#999)

Add the GET and POST handler for cover components.  Also add covers to
the index page although the Open/Close buttons that are shown for covers
will need a few lines added to webserver-v1.js, without them they don't
do anything.
This commit is contained in:
Andrew Zaborowski
2020-04-09 16:12:42 +02:00
committed by GitHub
parent 8613c02d5c
commit 17fd9d5107
2 changed files with 95 additions and 0 deletions

View File

@@ -144,6 +144,16 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
std::string text_sensor_json(text_sensor::TextSensor *obj, const std::string &value);
#endif
#ifdef USE_COVER
void on_cover_update(cover::Cover *obj) override;
/// Handle a cover request under '/cover/<id>/<open/close/stop/set>'.
void handle_cover_request(AsyncWebServerRequest *request, UrlMatch match);
/// Dump the cover state as a JSON string.
std::string cover_json(cover::Cover *obj);
#endif
/// Override the web handler's canHandle method.
bool canHandle(AsyncWebServerRequest *request) override;
/// Override the web handler's handleRequest method.