Fixed script error associated with unlinking remotes.

This commit is contained in:
Robert Strouse 2023-07-23 08:11:24 -07:00
parent 6711162c55
commit 5c06f2a6d4
5 changed files with 10 additions and 5 deletions

View file

@ -121,7 +121,7 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) {
shade->setMyPosition(shade->myPos, val); shade->setMyPosition(shade->myPos, val);
} }
else if(strncmp(command, "sunFlag", sizeof(command)) == 0) { 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); else shade->sendCommand(somfy_commands::Flag);
} }
} }
@ -138,6 +138,12 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) {
else else
group->sendCommand(somfy_commands::My); 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);
}
} }
} }
} }

Binary file not shown.

Binary file not shown.

View file

@ -1394,6 +1394,7 @@ void Web::begin() {
}); });
server.on("/unlinkRemote", []() { server.on("/unlinkRemote", []() {
webServer.sendCORSHeaders(); webServer.sendCORSHeaders();
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
HTTPMethod method = server.method(); HTTPMethod method = server.method();
if (method == HTTP_PUT || method == HTTP_POST) { if (method == HTTP_PUT || method == HTTP_POST) {
// We are updating an existing shade by adding a linked remote. // We are updating an existing shade by adding a linked remote.

View file

@ -3157,15 +3157,13 @@ class Somfy {
return div; return div;
} }
unlinkRemote(shadeId, remoteAddress) { 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 = { let obj = {
shadeId: shadeId, shadeId: shadeId,
remoteAddress: remoteAddress remoteAddress: remoteAddress
}; };
let overlay = ui.waitMessage(prompt); putJSONSync('/unlinkRemote', obj, (err, shade) => {
putJSON('/unlinkRemote', obj, (err, shade) => {
console.log(shade); console.log(shade);
overlay.remove();
prompt.remove(); prompt.remove();
this.setLinkedRemotesList(shade); this.setLinkedRemotesList(shade);
}); });