Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
tony_wk
New user
Posts: 8
Joined: 26 Jun 2017, 05:03

Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#1 Post by tony_wk » 18 Jul 2017, 07:58

I flashed both Sonoff RF and Sonoff S22(same Sonoff basic but with a thermo/humidity detector jack), flashed ESPeasy 2.0.0 dev10, dev 1024 version. Whenever power on the unit, if I press the button, the relay click on and off endlessly. If I press the button for long time, the on/off stops and everything return to normal, further button press or RF remote press all functions well. Below is my unit setup, can you help identify the problem?
Thanks!
无标题.jpg
无标题.jpg (74.38 KiB) Viewed 8952 times
新建位图图像.jpg
新建位图图像.jpg (71.86 KiB) Viewed 8952 times
无标题2.jpg
无标题2.jpg (35.47 KiB) Viewed 8952 times

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#2 Post by toffel969 » 18 Jul 2017, 10:45

tony_wk wrote: 18 Jul 2017, 07:58 I flashed both Sonoff RF and Sonoff S22(same Sonoff basic but with a thermo/humidity detector jack), flashed ESPeasy 2.0.0 dev10, dev 1024 version. Whenever power on the unit, if I press the button, the relay click on and off endlessly. If I press the button for long time, the on/off stops and everything return to normal, further button press or RF remote press all functions well. Below is my unit setup, can you help identify the problem?
Thanks!

无标题.jpg
新建位图图像.jpg
无标题2.jpg
You need to change a few things. In button device (switch1), change to normal switch, enable pull-up.

in rules change

Code: Select all

on switch1#Switch do
if [relay#switch]=1...
Then n
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

bryan
Normal user
Posts: 21
Joined: 05 Feb 2017, 18:15

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#3 Post by bryan » 18 Jul 2017, 10:55

For me it worked by turning off the send to controller option on both devices and use rules instead.

The rules I've used:

Code: Select all

On System#Boot do
  timerSet,1,5
endon
 
On Rules#Timer=1 do
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
endon

on switch1#Switch do
    if [relay#switch]=0
      GPIO,12,1
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=1
    else 
      GPIO,12,0
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
    endif
endon
Change the ip address, port and IDX.

Regards,

Bryan

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#4 Post by grovkillen » 18 Jul 2017, 11:17

bryan wrote: 18 Jul 2017, 10:55 For me it worked by turning off the send to controller option on both devices and use rules instead.

The rules I've used:

Code: Select all

On System#Boot do
  timerSet,1,5
endon
 
On Rules#Timer=1 do
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
endon

on switch1#Switch do
    if [relay#switch]=0
      GPIO,12,1
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=1
    else 
      GPIO,12,0
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
    endif
endon
Change the ip address, port and IDX.

Regards,

Bryan
The second part can be written as:

Code: Select all

on switch1#Switch do
      GPIO,12,[relay#switch]
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=[relay#switch]
endon
If the switch is inverted (done in the settings page of the device).
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#5 Post by LisaM » 18 Jul 2017, 13:47

bryan wrote: 18 Jul 2017, 10:55 For me it worked by turning off the send to controller option on both devices and use rules instead.

The rules I've used:

Code: Select all

On System#Boot do
  timerSet,1,5
endon
 
On Rules#Timer=1 do
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
endon

on switch1#Switch do
    if [relay#switch]=0
      GPIO,12,1
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=1
    else 
      GPIO,12,0
      SendToHTTP 192.168.0.xx,8080,/json.htm?type=command&parm=udevice&idx=xxx&nvalue=0
    endif
endon
Change the ip address, port and IDX.

Regards,

Bryan
This is a feedback loop caused by a time delay in the feedback... Set a response delay time in your switch so it won't react to the controller for a fixed amount of time...

bryan
Normal user
Posts: 21
Joined: 05 Feb 2017, 18:15

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#6 Post by bryan » 18 Jul 2017, 15:22

In order to prevend a feedback loop, it would be better to send the update to domoticz using rules.
You never know what value to use to set the delay.

But if you still want to use the send to controller option with a delay, you might want to turn off the send to controller for the button. You only need to send the state of the relay once.

tony_wk
New user
Posts: 8
Joined: 26 Jun 2017, 05:03

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#7 Post by tony_wk » 18 Jul 2017, 15:58

toffel969 wrote: 18 Jul 2017, 10:45
tony_wk wrote: 18 Jul 2017, 07:58 I flashed both Sonoff RF and Sonoff S22(same Sonoff basic but with a thermo/humidity detector jack), flashed ESPeasy 2.0.0 dev10, dev 1024 version. Whenever power on the unit, if I press the button, the relay click on and off endlessly. If I press the button for long time, the on/off stops and everything return to normal, further button press or RF remote press all functions well. Below is my unit setup, can you help identify the problem?
Thanks!

无标题.jpg
新建位图图像.jpg
无标题2.jpg
You need to change a few things. In button device (switch1), change to normal switch, enable pull-up.

in rules change

Code: Select all

on switch1#Switch do
if [relay#switch]=1...
Then n
I can't change the switch1 type from push button active low to normal switch, as it represents the physical push button. once I change to normal switch, every time I push it, the relay on off on off 4 times.
For my final hybrid solution, I keep 2 switch' hardware setting unchanged,
this is my rule

On System#Boot do
timerSet,1,3
endon

On Rules#Timer=1 do
SendToHTTP 192.168.1.208,8080,/json.htm?type=param=switchlight&command&idx=93&switchcmd=On

On switch1#Switch do
if [relay#switch]=0
GPIO,12,1
else
GPIO,12,0
endif
endon

that finally works.

Bryan's solution doesn't work for me. the physical button is not functioning.

still don't know the root cause....

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#8 Post by toffel969 » 18 Jul 2017, 19:59

Well, glad to hear that you got it working!
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

bryan
Normal user
Posts: 21
Joined: 05 Feb 2017, 18:15

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#9 Post by bryan » 18 Jul 2017, 22:18

Good to hear that it is working.

Maybe it will also be solved for you when you turn on send boot state for the relay?

The rules I've posted came from a sonoff touch, but I thought it should be the same, also (touch) button and relay.

Other thoughts: when you send to controller on both devices, you will switch the relay 2 times (See domoticz log). That should not be needed.

Also when using the rule: SendToHTTP 192.168.1.208,8080,/json.htm?type=param=switchlight&command&idx=93&switchcmd=On ,
it will trigger the relay switch and send the command back to the sonoff.

When using: SendToHTTP 192.168.1.208,8080,/json.htm?type=param=udevice&command&idx=93&nvlaue=1 ,
it will only update the switch state in domoticz and domoticz will not send anything back to the sonoff.

tony_wk
New user
Posts: 8
Joined: 26 Jun 2017, 05:03

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#10 Post by tony_wk » 20 Jul 2017, 15:32

bryan wrote: 18 Jul 2017, 22:18 Good to hear that it is working.

Maybe it will also be solved for you when you turn on send boot state for the relay?

The rules I've posted came from a sonoff touch, but I thought it should be the same, also (touch) button and relay.

Other thoughts: when you send to controller on both devices, you will switch the relay 2 times (See domoticz log). That should not be needed.

Also when using the rule: SendToHTTP 192.168.1.208,8080,/json.htm?type=param=switchlight&command&idx=93&switchcmd=On ,
it will trigger the relay switch and send the command back to the sonoff.

When using: SendToHTTP 192.168.1.208,8080,/json.htm?type=param=udevice&command&idx=93&nvlaue=1 ,
it will only update the switch state in domoticz and domoticz will not send anything back to the sonoff.
My further revision to the device setup is only setup GPIO0 switch send to controller and send boot state. For relay switch, none are selected. This solves some 1st press the button, relay turns on then off problem, but domoticz status is still not updated. To solve that, I need to use your boot timer.

For me, the 2 types of SendToHTTP rule you mentioned has no difference, they all physically turn on the relay. It may be related to the different device setup you have?

bryan
Normal user
Posts: 21
Joined: 05 Feb 2017, 18:15

Re: Power on Sonoff ESPeasy and 1st button push, go into endless relay on/off cycle

#11 Post by bryan » 20 Jul 2017, 21:45

You can see the difference in behaviour best when you send the commands directly from a webbrowser to domoticz:

http://192.168.1.208:8080/json.htm?type ... itchcmd=On
updates domoticz and turns on switch

http://192.168.1.208:8080/json.htm?type ... 3&nvalue=1
updates domoticz

Regards,

Bryan

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 102 guests