stefanbode / Sonoff-Tasmota

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE, enhanced with I2C options
GNU General Public License v3.0
128 stars 41 forks source link

Shutter with LC-TECH X2 in mode 1 allows changing direction without power removal #216

Closed taste66 closed 4 years ago

taste66 commented 4 years ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is. I am using a LC-Tech X2 relay to control my shutter. This relay needs rules to change the relay status over the serial link to the extra processor. (see https://github.com/arendst/Tasmota/wiki/LC-Technology-WiFi-Relay) If you change the shutter direction while moving the commands to stop and start the motor ar to close so do not propagate to the actual relais. This breaks the direction relay if this action is performed while moving.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:

Rules output here: 20:26:23 MQT: stat/Shutter/01/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":253,"Rules":"on System#Boot do Backlog Baudrate 115200; SerialSend5 0 endon on Power1#State=1 do SerialSend5 A00101A2 endon on Power1#State=0 do SerialSend5 A00100A1 endon on Power2#State=1 do SerialSend5 A00201A3 endon on Power2#State=0 do SerialSend5 A00200A2 endon"}

- [ ] Provide the output of this command: `Status 0`:

STATUS 0 output here: 20:27:47 MQT: stat/Shutter/01/STATUS = {"Status":{"Module":18,"FriendlyName":["Shutter_01","Shutter_01a"],"Topic":"Shutter/01","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":1}}

- [ ] Provide the output of the Console log output when you experience your issue; if applicable:
  _(Please use_ `weblog 4` _for more debug information)_

Console output here: 20:33:02 SHT: Shutter1 Real 29605, Start 40000, Stop 0, Dir -1, Delay 0, Rtc 4.95 [s], Freq 1052 20:33:02 MQT: stat/Shutter/01/RESULT = {"Shutter1":{"Position":74,"Direction":-1}} 20:33:03 SHT: Shutter1 Real 27505, Start 40000, Stop 0, Dir -1, Delay 0, Rtc 5.95 [s], Freq 1052 20:33:03 MQT: stat/Shutter/01/RESULT = {"Shutter1":{"Position":69,"Direction":-1}} 20:33:03 SHT: Wait for Motorstop.. 20:33:03 MQT: tele/Shutter/01/STATE = {"Time":"2020-02-13T20:33:03","Uptime":"0T00:37:06","UptimeSec":2226,"Vcc":3.432,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"ON","Wifi":{"AP":1,"SSId":"taste2","BSSId":"08:62:66:3D:BD:90","Channel":6,"RSSI":100,"Signal":-45,"LinkCount":1,"Downtime":"0T00:00:09"}} 20:33:03 MQT: stat/Shutter/01/RESULT = {"POWER1":"OFF"} 20:33:03 MQT: stat/Shutter/01/POWER1 = OFF (retained) 20:33:04 MQT: tele/Shutter/01/STATE = {"Time":"2020-02-13T20:33:04","Uptime":"0T00:37:07","UptimeSec":2227,"Vcc":3.434,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"ON","Wifi":{"AP":1,"SSId":"taste2","BSSId":"08:62:66:3D:BD:90","Channel":6,"RSSI":100,"Signal":-44,"LinkCount":1,"Downtime":"0T00:00:09"}} 20:33:04 MQT: stat/Shutter/01/RESULT = {"POWER1":"OFF"} 20:33:04 MQT: stat/Shutter/01/POWER1 = OFF (retained) 20:33:04 MQT: tele/Shutter/01/STATE = {"Time":"2020-02-13T20:33:04","Uptime":"0T00:37:07","UptimeSec":2227,"Vcc":3.432,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"taste2","BSSId":"08:62:66:3D:BD:90","Channel":6,"RSSI":100,"Signal":-44,"LinkCount":1,"Downtime":"0T00:00:09"}} 20:33:04 MQT: stat/Shutter/01/RESULT = {"POWER2":"OFF"} 20:33:04 MQT: stat/Shutter/01/POWER2 = OFF (retained) 20:33:04 MQT: tele/Shutter/01/STATE = {"Time":"2020-02-13T20:33:04","Uptime":"0T00:37:07","UptimeSec":2227,"Vcc":3.434,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"ON","POWER2":"OFF","Wifi":{"AP":1,"SSId":"taste2","BSSId":"08:62:66:3D:BD:90","Channel":6,"RSSI":100,"Signal":-44,"LinkCount":1,"Downtime":"0T00:00:09"}} 20:33:04 MQT: stat/Shutter/01/RESULT = {"POWER1":"ON"} 20:33:04 MQT: stat/Shutter/01/POWER1 = ON (retained) 20:33:04 MQT: stat/Shutter/01/RESULT = {"ShutterOpen1":100} 20:33:04 RUL: POWER2#STATE=0 performs "SerialSend5 A00200A2" 20:33:04 MQT: stat/Shutter/01/RESULT = {"SerialSend":"Done"} 20:33:04 SHT: Shutter1 Real 27395, Start 27295, Stop 40000, Dir 1, Delay 0, Rtc 0.05 [s], Freq 1000 20:33:04 MQT: stat/Shutter/01/RESULT = {"Shutter1":{"Position":68,"Direction":1}} 20:33:05 SHT: Shutter1 Real 29895, Start 27295, Stop 40000, Dir 1, Delay 0, Rtc 1.30 [s], Freq 1000 20:33:05 MQT: stat/Shutter/01/RESULT = {"Shutter1":{"Position":75,"Direction":1}} 20:33:06 SHT: Shutter1 Real 31895, Start 27295, Stop 40000, Dir 1, Delay 0, Rtc 2.30 [s], Freq 1000

As you can see the rule to switch off POWER1 is never send



### TO REPRODUCE
_Steps to reproduce the behavior:_
ShutterOpen1
wait 2s
ShutterClose1

### EXPECTED BEHAVIOUR
_A clear and concise description of what you expected to happen._
POWER1 is disabled for atleast 1s when the direction changes

### SCREENSHOTS
_If applicable, add screenshots to help explain your problem._

### ADDITIONAL CONTEXT
_Add any other context about the problem here._

**(Please, remember to close the issue when the problem has been addressed)**
taste66 commented 4 years ago

I will try the solution indicated in this post: https://github.com/arendst/Tasmota/issues/7133#issuecomment-586680162 Will close the issue if it works!

taste66 commented 4 years ago

Sorry was too fast, need to check again

btw the reason I use an LC-TECH is it fits into a European style wall box if you cut the corners a bit.

taste66 commented 4 years ago

Looks like the rule is not trigger while
delay(MOTOR_STOP_TIME); is executed. As I am nog SW engineer I would not know how to fix this

stefanbode commented 4 years ago

Yes, this might be correct, because it is a delay(500); that for sure freezes the program execution for 0.5 sec. There is no simple way to overcome this. You can set the delay in the INO file to "0". In this case, the motor immediately changes direction. If I give back control at this time I will have definitely side effects during the main execution of the functions.

taste66 commented 4 years ago

Hi Stefan, Thanks I will see if I can simply avoid you change the direction without a stop in between. Currently this means te LC-TECH is not usable this way since it does break the direction relay (confirmed)