diff --git a/code/data/index.html.gz b/code/data/index.html.gz
index 6a84e34f..ecad9c84 100644
Binary files a/code/data/index.html.gz and b/code/data/index.html.gz differ
diff --git a/code/html/index.html b/code/html/index.html
index 00b8bfc7..71524dbf 100644
--- a/code/html/index.html
+++ b/code/html/index.html
@@ -186,9 +186,10 @@
diff --git a/code/src/config/general.h b/code/src/config/general.h
index a1edee7f..8c497c9c 100644
--- a/code/src/config/general.h
+++ b/code/src/config/general.h
@@ -12,11 +12,20 @@
// RELAY
//--------------------------------------------------------------------------------
+#define RELAY_MODE_OFF 0
+#define RELAY_MODE_ON 1
+#define RELAY_MODE_SAME 2
+
+#define RELAY_SYNC_ANY 0
+#define RELAY_SYNC_NONE_OR_ONE 1
+#define RELAY_SYNC_ONE 2
+#define RELAY_SYNC_SAME 3
+
// 0 means OFF, 1 ON and 2 whatever was before
-#define RELAY_MODE 1
+#define RELAY_MODE RELAY_MODE_OFF
// 0 means ANY, 1 zero or one and 2 one and only one
-#define RELAY_SYNC 0
+#define RELAY_SYNC RELAY_SYNC_ANY
// -----------------------------------------------------------------------------
// WIFI & WEB
diff --git a/code/src/mqtt.ino b/code/src/mqtt.ino
index 5c0cbf17..4f20122f 100644
--- a/code/src/mqtt.ino
+++ b/code/src/mqtt.ino
@@ -86,7 +86,7 @@ void _mqttOnMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
if (isFirstMessage) {
isFirstMessage = false;
byte relayMode = getSetting("relayMode", String(RELAY_MODE)).toInt();
- if (relayMode != 2) return;
+ if (relayMode != RELAY_MODE_SAME) return;
}
// Get relay ID
diff --git a/code/src/relay.ino b/code/src/relay.ino
index 62a8a6e4..ae54048f 100644
--- a/code/src/relay.ino
+++ b/code/src/relay.ino
@@ -17,15 +17,6 @@ bool recursive = false;
unsigned char dualRelayStatus = 0;
#endif
-#define RELAY_MODE_OFF 0
-#define RELAY_MODE_ON 1
-#define RELAY_MODE_SAME 2
-
-#define RELAY_SYNC_ANY 0
-#define RELAY_SYNC_NONE_OR_ONE 1
-#define RELAY_SYNC_ONE 2
-
-
// -----------------------------------------------------------------------------
// RELAY
// -----------------------------------------------------------------------------
@@ -98,8 +89,14 @@ void relaySync(unsigned char id) {
byte relaySync = getSetting("relaySync", String(RELAY_SYNC)).toInt();
bool status = relayStatus(id);
+ // If RELAY_SYNC_SAME all relays should have the same state
+ if (relaySync == RELAY_SYNC_SAME) {
+ for (unsigned short i=0; i<_relays.size(); i++) {
+ if (i != id) relayStatus(i, status);
+ }
+
// If NONE_OR_ONE or ONE and setting ON we should set OFF all the others
- if (status) {
+ } else if (status) {
if (relaySync != RELAY_SYNC_ANY) {
for (unsigned short i=0; i<_relays.size(); i++) {
if (i != id) relayStatus(i, false);