diff --git a/ConfigSettings.h b/ConfigSettings.h index 06eeee5..b2749a0 100644 --- a/ConfigSettings.h +++ b/ConfigSettings.h @@ -3,7 +3,7 @@ #ifndef configsettings_h #define configsettings_h -#define FW_VERSION "v1.3.1" +#define FW_VERSION "v1.3.2" enum DeviceStatus { DS_OK = 0, DS_ERROR = 1, diff --git a/Somfy.cpp b/Somfy.cpp index b93a962..56e6381 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -822,6 +822,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) { dir = 0; break; } + if(dir == 0 && this->hasTilt && this->tiltDirection != 0) this->setTiltMovement(0); this->setMovement(dir); } void SomfyShade::setTiltMovement(int8_t dir) { diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index 4121925..91f2f2f 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index c72c401..0821512 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/Web.cpp b/Web.cpp index 272648b..71089e7 100644 --- a/Web.cpp +++ b/Web.cpp @@ -177,6 +177,71 @@ void Web::begin() { apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"Shade with the specified id not found.\"}")); } }); + apiServer.on("/tiltCommand", []() { + webServer.sendCORSHeaders(); + HTTPMethod method = apiServer.method(); + uint8_t shadeId = 255; + uint8_t target = 255; + somfy_commands command = somfy_commands::My; + if (method == HTTP_GET || method == HTTP_PUT || method == HTTP_POST) { + if (server.hasArg("shadeId")) { + shadeId = atoi(apiServer.arg("shadeId").c_str()); + if (apiServer.hasArg("command")) command = translateSomfyCommand(apiServer.arg("command")); + else if(apiServer.hasArg("target")) target = atoi(apiServer.arg("target").c_str()); + } + else if (apiServer.hasArg("plain")) { + Serial.println("Sending Shade Tilt Command"); + DynamicJsonDocument doc(256); + DeserializationError err = deserializeJson(doc, apiServer.arg("plain")); + if (err) { + switch (err.code()) { + case DeserializationError::InvalidInput: + apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"Invalid JSON payload\"}")); + break; + case DeserializationError::NoMemory: + apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"Out of memory parsing JSON\"}")); + break; + default: + apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"General JSON Deserialization failed\"}")); + break; + } + return; + } + else { + JsonObject obj = doc.as(); + if (obj.containsKey("shadeId")) shadeId = obj["shadeId"]; + else apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"No shade id was supplied.\"}")); + if (obj.containsKey("command")) { + String scmd = obj["command"]; + command = translateSomfyCommand(scmd); + } + else if(obj.containsKey("target")) { + target = obj["target"].as(); + } + } + } + else apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"No shade object supplied.\"}")); + } + SomfyShade* shade = somfy.getShadeById(shadeId); + if (shade) { + Serial.print("Received:"); + Serial.println(apiServer.arg("plain")); + // Send the command to the shade. + if(target >= 0 && target <= 100) + shade->moveToTiltTarget(target); + else + shade->sendTiltCommand(command); + DynamicJsonDocument sdoc(256); + JsonObject sobj = sdoc.to(); + shade->toJSON(sobj); + serializeJson(sdoc, g_content); + apiServer.send(200, _encoding_json, g_content); + } + else { + apiServer.send(500, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"Shade with the specified id not found.\"}")); + } + }); + server.on("/upnp.xml", []() { SSDP.schema(server.client()); }); diff --git a/data/index.html b/data/index.html index 2f91841..2b54f4d 100644 --- a/data/index.html +++ b/data/index.html @@ -3,10 +3,10 @@ - - + + - +
diff --git a/data/index.js b/data/index.js index 65256fb..c28e81b 100644 --- a/data/index.js +++ b/data/index.js @@ -355,7 +355,7 @@ async function reopenSocket() { await initSockets(); } class General { - appVersion = 'v1.3.1'; + appVersion = 'v1.3.2'; reloadApp = false; async init() { this.setAppVersion();