Skip to content

Commit

Permalink
Fixed script error associated with unlinking remotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstrouse committed Jul 23, 2023
1 parent 6711162 commit 5c06f2a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
8 changes: 7 additions & 1 deletion MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
}
}
Expand Down
Binary file modified SomfyController.ino.esp32.bin
Binary file not shown.
Binary file modified SomfyController.littlefs.bin
Binary file not shown.
1 change: 1 addition & 0 deletions Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 5c06f2a

Please sign in to comment.