diff --git a/MQTT.cpp b/MQTT.cpp index d10ffb9..778af84 100644 --- a/MQTT.cpp +++ b/MQTT.cpp @@ -121,7 +121,7 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) { shade->setMyPosition(shade->myPos, val); } else if(strncmp(command, "sunFlag", sizeof(command)) == 0) { - if(val >= 0) shade->sendCommand(somfy_commands::SunFlag); + if(val > 0) shade->sendCommand(somfy_commands::SunFlag); else shade->sendCommand(somfy_commands::Flag); } } @@ -138,6 +138,12 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) { else group->sendCommand(somfy_commands::My); } + else if(strncmp(command, "sunFlag", sizeof(command)) == 0) { + if(val > 0) + group->sendCommand(somfy_commands::Flag); + else + group->sendCommand(somfy_commands::SunFlag); + } } } } diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index 50bdbc9..5b29aff 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 da58e5f..13affa1 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/Web.cpp b/Web.cpp index 2e2f28e..009da9f 100644 --- a/Web.cpp +++ b/Web.cpp @@ -1394,6 +1394,7 @@ void Web::begin() { }); server.on("/unlinkRemote", []() { webServer.sendCORSHeaders(); + if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; } HTTPMethod method = server.method(); if (method == HTTP_PUT || method == HTTP_POST) { // We are updating an existing shade by adding a linked remote. diff --git a/data/index.js b/data/index.js index 34019d2..50fdc61 100644 --- a/data/index.js +++ b/data/index.js @@ -3157,15 +3157,13 @@ class Somfy { return div; } unlinkRemote(shadeId, remoteAddress) { - let prompt = ui.promptMessage(document.getElementById('fsSomfySettings'), 'Are you sure you want to unlink this remote from the shade?', () => { + let prompt = ui.promptMessage('Are you sure you want to unlink this remote from the shade?', () => { let obj = { shadeId: shadeId, remoteAddress: remoteAddress }; - let overlay = ui.waitMessage(prompt); - putJSON('/unlinkRemote', obj, (err, shade) => { + putJSONSync('/unlinkRemote', obj, (err, shade) => { console.log(shade); - overlay.remove(); prompt.remove(); this.setLinkedRemotesList(shade); });