xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.98k stars 637 forks source link

SONOFF_T1_2CH relay switches lock up #2574

Open tita2000 opened 1 year ago

tita2000 commented 1 year ago

image

my configuration for the relays looks like this

image

the moment I reboot, the first switch switches on, pulses for 30 seconds and switches off, although I configured boot mode off. Then after a short while maybe about 5 seconds both switches turn grey.

Regards Timo

tita2000 commented 1 year ago

here is the debug output of the issue, hope it is useful

[026447] [WEBSOCKET] #1 connected, ip: 192.168.100.1, url: /ws
[060197] [MAIN] Resetting stability counter
[084105] [MQTT] Sending ESPROL08/relay/0 => 1 (PID 7)
[084107] [MQTT] Sending ESPROL08/relay/0/set => 1 (PID 8)
[084110] [RELAY] #0 pulse OFF scheduled in 30000 (ms)
[084111] [RELAY] #0 set to ON
[084159] [MQTT] Received ESPROL08/relay/0 => 1
[084165] [MQTT] Received ESPROL08/relay/0/set => 1
[085120] [RELAY] Relay mask: 0b1
[114174] [MQTT] Sending ESPROL08/relay/0 => 0 (PID 9)
[114176] [MQTT] Sending ESPROL08/relay/0/set => 0 (PID 10)
[114180] [RELAY] #0 set to OFF
[114227] [MQTT] Received ESPROL08/relay/0 => 0
[114233] [MQTT] Received ESPROL08/relay/0/set => 0
[115189] [RELAY] Relay mask: 0b0
relay
relay0 {Prov=gpio TargetStatus=off CurrentStatus=off Lock=off}
relay1 {Prov=gpio TargetStatus=off CurrentStatus=off Lock=off}
+OK

Regards

PS Sorry for the format, I tried my best, but I was not able to figure out how to do CR+LF in a quote. The issue is still there in github230112 With a SP202 dual power socket I could not notice a problem with the relay switches. Guessing it has to do with the "zero-or-one" or pulse option?

tita2000 commented 1 year ago

Ok, i figured out, that I have to set the INTERLOCK DELAY greater than 0 for normal operation. If this is a feature, feel free to close this issue. Regards Timo

mcspr commented 1 year ago

the moment I reboot, the first switch switches on,

Do you mean on boot it automatically switches relay to ON without any interaction?

Ok, i figured out, that I have to set the INTERLOCK DELAY greater than 0 for normal operation. If this is a feature, feel free to close this issue.

Certainly a bug, if it fails to unlock relays after locking them b/c of the sync mode.

Maybe something like this needs to happen instead (note to self; or, if you are able to build, to try out)

diff --git a/code/espurna/relay.cpp b/code/espurna/relay.cpp
index 48bc377e..0271d3f9 100644
--- a/code/espurna/relay.cpp
+++ b/code/espurna/relay.cpp
@@ -1681,10 +1681,10 @@ void _relaySyncUnlock() {
 #endif
         };

-        if (all_off) {
-            _relay_sync_timer.schedule(_relay_delay_interlock, action);
-        } else {
+        if (!all_off || !_relay_delay_interlock.count()) {
             action();
+        } else {
+            _relay_sync_timer.schedule(_relay_delay_interlock, action);
         }
     }
 }

Still prone to some timing issues, but at least locks would be disabled