Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff Basic R4 Magicswitch bounces when toggled by command #22535

Closed
3 tasks
crhass opened this issue Nov 23, 2024 · 7 comments · Fixed by #22539
Closed
3 tasks

Sonoff Basic R4 Magicswitch bounces when toggled by command #22535

crhass opened this issue Nov 23, 2024 · 7 comments · Fixed by #22539

Comments

@crhass
Copy link

crhass commented Nov 23, 2024

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.
I have noticed that when toggling the sonoff relay from the web interface or MQTT command, the relay will sometimes bounce back to its previous state. MAGICSWITCH_MASKING_WINDOW_LEN appears not to be active for switching by command but may solve the problem.

REQUESTED INFORMATION

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

  • [x ] Read the Contributing Guide and Policy and the Code of Conduct
  • [x ] Searched the problem in issues
  • [ x] Searched the problem in discussions
  • [ x] Searched the problem in the docs
  • Searched the problem in the chat
  • [ x] Device used (e.g., Sonoff Basic): R4
  • [ x] Tasmota binary firmware version number used: 14.3.0
    • Pre-compiled
    • [ x] Self-compiled
  • [ x] Flashing tools used: web interface
  • [ x] Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:
07:32:44.776 SRC: Backlog
07:32:44.777 CMD: Grp 0, Cmd 'GPIO', Idx 1, Len 4, Pld 255, Data '255:'
07:32:44.784 MQT: stat/DiningLight/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"224":"Relay1"},"GPIO5":{"10560":"MagicSwitch1"},"GPIO6":{"544":"LedLink"},"GPIO7":{"0":"None"},"GPIO8":{"0":"None"},"GPIO9":{"32":"Button1"},"GPIO10":{"0":"None"},"GPIO11":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO18":{"0":"None"},"GPIO19":{"0":"None"},"GPIO20":{"0":"None"},"GPIO21":{"0":"None"}}
  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:

  • [x ] Provide the output of this command: Status 0:
  STATUS 0 output here:
07:23:59.284 CMD: Status 0
07:23:59.286 SRC: WebConsole from 192.168.1.25
07:23:59.288 CMD: Grp 0, Cmd 'STATUS', Idx 1, Len 1, Pld 0, Data '0'
07:23:59.293 MQT: stat/DiningLight/STATUS = {"Status":{"Module":0,"DeviceName":"Dining Light","FriendlyName":["Dining Light"],"Topic":"DiningLight","ButtonTopic":"0","Power":"0","PowerLock":"0","PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}}
07:23:59.299 MQT: stat/DiningLight/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota32/release/tasmota32c3.bin","RestartReason":"Software reset CPU","Uptime":"0T05:51:31","StartupUTC":"2024-11-23T00:32:28","Sleep":50,"CfgHolder":4617,"BootCount":19,"BCResetTime":"2024-11-22T19:15:07","SaveCount":320}}
07:23:59.305 MQT: stat/DiningLight/STATUS2 = {"StatusFWR":{"Version":"14.3.0(tasmota32)","BuildDateTime":"2024-11-23T00:10:01","Core":"3_1_0","SDK":"5.3.1.240924","CpuFrequency":160,"Hardware":"ESP32-C3 v0.4","CR":"423/699"}}
07:23:59.309 MQT: stat/DiningLight/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":3,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["eclipse",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C80001000600003C5A0A192800000000","00000080","00006000","00004000","00000000"]}}
07:23:59.322 MQT: stat/DiningLight/STATUS4 = {"StatusMEM":{"ProgramSize":1997,"Free":882,"Heap":170,"StackLowMark":4,"PsrMax":0,"PsrFree":0,"ProgramFlashSize":4096,"FlashSize":4096,"FlashChipId":"164020","FlashFrequency":80,"FlashMode":"DIO","Features":["0809","9F9AD7DF","0015A001","B7F7BFCF","05DA9BC4","E0360DC7","480840D2","20200000","D4BC482D","810A80B1","00000015"],"Drivers":"1,2,!3,!4,!5,7,!8,9,10,11,12,!14,!16,!17,!20,!21,!24,26,!27,29,!34,!35,38,50,52,!59,!60,62,!63,!66,!67,!68,71,!73,82,!86,!87,!88,121","Sensors":"1,2,3,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,26,31,34,37,39,40,42,43,45,51,52,55,56,58,59,64,66,67,74,85,92,95,98,103,105,109,127","I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,58,62,65,69,76,77,82,89"}}
07:23:59.331 MQT: stat/DiningLight/STATUS5 = {"StatusNET":{"Hostname":"DiningLight-4308","IPAddress":"192.168.1.136","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.1.1","DNSServer2":"0.0.0.0","Mac":"C0:4E:30:80:70:D4","IP6Global":"","IP6Local":"fe80::c24e:30ff:fe80:70d4%st3","Ethernet":{"Hostname":"","IPAddress":"0.0.0.0","Gateway":"0.0.0.0","Subnetmask":"0.0.0.0","DNSServer1":"192.168.1.1","DNSServer2":"0.0.0.0","Mac":"00:00:00:00:00:00","IP6Global":"","IP6Local":""},"Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":19.0}}
07:23:59.336 MQT: stat/DiningLight/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.133","MqttPort":1883,"MqttClientMask":"Dining Light","MqttClient":"Dining Light","MqttUser":"testuser","MqttCount":2,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
07:23:59.341 MQT: stat/DiningLight/STATUS7 = {"StatusTIM":{"UTC":"2024-11-23T06:23:59Z","Local":"2024-11-23T07:23:59","StartDST":"2024-03-31T02:00:00","EndDST":"2024-10-27T03:00:00","Timezone":"+01:00","Sunrise":"08:12","Sunset":"17:00"}}
07:23:59.348 MQT: stat/DiningLight/STATUS10 = {"StatusSNS":{"Time":"2024-11-23T07:23:59","Switch1":"ON"}}
07:23:59.355 MQT: stat/DiningLight/STATUS11 = {"StatusSTS":{"Time":"2024-11-23T07:23:59","Uptime":"0T05:51:31","UptimeSec":21091,"Heap":168,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":2,"Berry":{"HeapUsed":4,"Objects":45},"POWER":"OFF","Wifi":{"AP":1,"SSId":"testwifi","BSSId":"60:A4:B7:49:24:56","Channel":11,"Mode":"HT40","RSSI":80,"Signal":-60,"LinkCount":2,"Downtime":"0T00:00:07"}}}
07:24:28.378 WIF: Network (re)scan started...
  • [x ] Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:
07:18:52.008 SRC: MQTT
07:18:52.010 CMD: Grp 0, Cmd 'POWER', Idx 1, Len 3, Pld 0, Data 'OFF'
07:18:52.016 MQT: stat/DiningLight/RESULT = {"POWER":"OFF"}
07:18:52.019 MQT: stat/DiningLight/POWER = OFF
07:18:52.293 CFG: Saved, Count 318, Bytes 4096
07:18:52.300 MSW: length:4566, window:20
07:18:52.351 SRC: Switch
07:18:52.358 MQT: stat/DiningLight/RESULT = {"POWER":"ON"}
07:18:52.362 MQT: stat/DiningLight/POWER = ON
07:18:53.384 CFG: Saved, Count 319, Bytes 4096
07:18:55.551 SRC: MQTT
07:18:55.552 CMD: Grp 0, Cmd 'POWER', Idx 1, Len 3, Pld 0, Data 'OFF'
07:18:55.559 MQT: stat/DiningLight/RESULT = {"POWER":"OFF"}
07:18:55.561 MQT: stat/DiningLight/POWER = OFF
07:18:56.284 CFG: Saved, Count 320, Bytes 4096

The log above shows the MQTT turn off command
Then a 4566 pulse is detected and it turns on again
The second MQTT turn off command is successful

TO REPRODUCE

Steps to reproduce the behavior:
Apply the standard magicswitch template
Set MAGICSWITCH_MASKING_WINDOW_LEN to 20
The relay does not bounce when using the magicswitch but does bounce when switched from the web interface or MQTT.

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.
Expect the relay to change state once and not trigger the magicswitch feature.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.
I had to increase the MAGICSWITCH_MASKING_WINDOW_LEN from the default 5 (250ms) to 20 (1 sec) to prevent the bouncing when using the physical switch but I still get the issue when switching by software. Should the masking be applied to all switching?

(Please, remember to close the issue when the problem has been addressed)

@barbudor
Copy link
Contributor

I will try to reproduce but I believe your problem is hardware related as the magic switch features detects a power loss while you are not actuating the switch.

What is your load? Passive or inductive? What power?
I fear that the load switch creates a disturbance on the mains that the Basic sees as a small power loss.

@crhass
Copy link
Author

crhass commented Nov 23, 2024

Load is 4x 6watt GU10 LED lamps.

I am seeing the magic switch detect pulses of around 5000 to 50000 when switching the relay with MQTT.

It is not every time, probably about 10% erroneous detection.

I suspecting it could be the load characteristics too but would be nice to be able to filter it.

It is not general power noise as I have no phantom switching other than the described issue.

I tried switchdebounce 1000 which I suspect may have reduced the frequency of this issue.

Do you know if Switchdebounce 69 works with the basic R4

I am going to try a rule to create a longer delay, maybe 2 sec

I would like to find a software solution as I am sure others could have similar loads.

Thanks for responding

@barbudor
Copy link
Contributor

Switchdebounce will have no impact on the MagicSwitch which use a logic totally indépendant from Switches

I don't see how you could workaround that with rules.

I think the only solution is indeed to apply the masking window for any power switch whatever is the source
I'll try to find time for that during the week end

I understand you know how to compile your own so I'll provide you patches or a branch to test

@crhass
Copy link
Author

crhass commented Nov 23, 2024

Thank you for your help, I will be sure to test this on my setup and feedback to you if it is successful.

@crhass
Copy link
Author

crhass commented Nov 23, 2024

I can confirm I am also seeing this with different GU10 lamps, with a single lamp and also with no load so I am ruling out the load now.

@barbudor
Copy link
Contributor

I'm fighting with my build env
I can't test but this should be ok
Can you please try to apply the changes listed there and report ?
https://github.com/arendst/Tasmota/pull/22539/files

@crhass
Copy link
Author

crhass commented Nov 23, 2024

Just compiled and flashed and pleased to confirm it works and the issue is resolved. Really appreciate you working on this so quickly. Many Thanks again.

Off to turn my lighting automations back on in home assistant now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants