releay bounce at boot

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

releay bounce at boot

#1 Post by s_p2003 » 26 Dec 2020, 12:30

Hi to all

I can't understand what happens. when the device, is a Sonoff Dual R2, restarts, relays bounce from on to off repeatedly. Sometimes indefinitely for both relays, other times relay 1 stops in the wrong position, other times relay 2.
The reboot is normal if both controllers are disabled.

https://youtu.be/io2Kx7g-xco

this is my rule

Code: Select all

on System#Boot do
   GPIO,12,0   // Relay 1 OFF
   GPIO,5,0    // Relay 2 OFF
   let,1,0     // Set variable 1 to 0
endon

on pulsante#stato do
  if [pulsante#stato]=1
    let,1,[int#1]+1
    if [int#1]=1
      gpio,12,1
      gpio,5,0
    elseif [int#1]=2
      gpio,12,0
      gpio,5,1
    elseif [int#1]=3
      gpio,12,1
      gpio,5,1
    elseif [int#1]=4
      let,1,0
      gpio,12,0
      gpio,5,0
    endif
  endif
endon
Attachments
devices.png
devices.png (50.49 KiB) Viewed 9610 times
device_4.png
device_4.png (63.69 KiB) Viewed 9610 times
device_3.png
device_3.png (63.4 KiB) Viewed 9610 times
device_2.png
device_2.png (63.54 KiB) Viewed 9610 times
device_1.png
device_1.png (81.8 KiB) Viewed 9610 times
controller_2.png
controller_2.png (46.1 KiB) Viewed 9610 times
controller_1.png
controller_1.png (73.87 KiB) Viewed 9610 times

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#2 Post by s_p2003 » 27 Dec 2020, 10:18

good morning

situation update

I have disabled from send to controller the Domoticz HTTP controller onto relay devices and the reboot is normal.
is it possible to have two active controllers on the same device?

i added this to rules

Code: Select all

on WiFi#Connected do
   SendToHTTP 192.168.0.140,8080,/json.htm?type=command&param=switchlight&idx=80&switchcmd=Off
   SendToHTTP 192.168.0.140,8080,/json.htm?type=command&param=switchlight&idx=81&switchcmd=Off
endon

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: releay bounce at boot

#3 Post by TD-er » 27 Dec 2020, 10:40

s_p2003 wrote: 27 Dec 2020, 10:18 [...]
is it possible to have two active controllers on the same device?
[...]
Not sure what you mean by that?

Also when using Domoticz to interact with ESPEasy in 2 directions, it is preferred to use MQTT and the Domoticz MQTT helper plugin.
See: https://espeasy.readthedocs.io/en/lates ... z%20helper

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#4 Post by s_p2003 » 27 Dec 2020, 11:19

sorry. you are right, but it is difficult to explain the problem.
I have two controllers running on my sonoff, #1 is Home Assistant and #2 is Domoticz HTTP.
It happens that when the Sonoff Dual R2 is restarted, the two relays start bouncing from open to closed quickly for several seconds, and at stop of bouncing they are in a random position and not as I would like (open).
Sorry for my English, and I hope I have explained well.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: releay bounce at boot

#5 Post by TD-er » 27 Dec 2020, 13:42

OK, so you're hitting the limit of only 1 enabled MQTT controller right now.

This means the fix may be a bit more complex and I have to think about it a bit more.

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#6 Post by s_p2003 » 28 Dec 2020, 16:45

hi TD-er

no intuition?
I also checked SendToHTTP wait for ack, but nothing has changed.

_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Re: releay bounce at boot

#7 Post by _Cyber_ » 28 Dec 2020, 17:17

maybe this: https://github.com/letscontrolit/ESPEas ... -729524772

Try to deactivate your "Switch input" devices bound to the GPIOs which you are using in rules.

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#8 Post by s_p2003 » 28 Dec 2020, 19:22

after disabling the switches relating to the relays (gpio 12 and 5), there is no bounce at start-up, but there is no control with Home Assistant.
Moreover when restarting the relays are always closed and I want them open.

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: releay bounce at boot

#9 Post by Ath » 28 Dec 2020, 19:40

s_p2003 wrote: 28 Dec 2020, 19:22 Moreover when restarting the relays are always closed and I want them open.
Then check out the Hardware tab, where you can configure the initial state after boot of each GPIO. Only configure the ones you actually need to control (GPIO-5 and GPIO-12).

As TD-er already suggested, currently ESPEasy doesn't support having 2 active MQTT controllers, and that's what you seem to have set up. Disable at least one of the controllers (suggestion: Domoticz) to get your unit stable. After that you can probably enable the Relay devices again to be able to control them remotely.
/Ton (PayPal.me)

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#10 Post by s_p2003 » 28 Dec 2020, 19:58

Ath wrote: 28 Dec 2020, 19:40 Then check out the Hardware tab, where you can configure the initial state after boot of each GPIO. Only configure the ones you actually need to control (GPIO-5 and GPIO-12).
solution already tested, but not working. obviously I also changed the rules by removing the status at System#boot

Ath wrote: 28 Dec 2020, 19:40 As TD-er already suggested, currently ESPEasy doesn't support having 2 active MQTT controllers, and that's what you seem to have set up. Disable at least one of the controllers (suggestion: Domoticz) to get your unit stable. After that you can probably enable the Relay devices again to be able to control them remotely.

there is only 1 controller active over MQTT and it is Home Assistant.
The second one is Domoticz HTTP

_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Re: releay bounce at boot

#11 Post by _Cyber_ » 29 Dec 2020, 10:03

s_p2003 wrote: 28 Dec 2020, 19:22 after disabling the switches relating to the relays (gpio 12 and 5), there is no bounce at start-up, but there is no control with Home Assistant.
Moreover when restarting the relays are always closed and I want them open.
I would try to control the relays with gpio only, not with the switch device from devices page.
if you need a device generate a dummy device, set the state according to the relays. then reflect the behvior in the rule, so if you switch your dummydevice create in your rule a "on ... endon" block to switch the gpio accordingly.

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#12 Post by s_p2003 » 29 Dec 2020, 19:07

deleted the swith's rule and disabled the button on the case in devices (gpio-10).
the problem remains

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: releay bounce at boot

#13 Post by Ath » 29 Dec 2020, 19:22

The problem is most likely caused by Domoticz, receiving a state change and reflecting that with the on/off state back to the device, have you by accident, swapped the on and off state commands? However, the previous sentence could also be said for HA... :roll:
/Ton (PayPal.me)

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#14 Post by s_p2003 » 30 Dec 2020, 20:46

the problem does not arise if I exclude a controller
it doesn't matter which one it is.

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#15 Post by s_p2003 » 02 Jan 2021, 11:56

hi

no suggestion? my doubt is that you cannot have 2 controllers active at boot, so a rule would be needed to activate domoticz HTTP after 20 or 30 seconds. it can be done?

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#16 Post by s_p2003 » 13 Jan 2021, 15:13

Hi guys

is it possible to delay starting a controller on startup with a rule? 20 or 30 seconds would be enough ...

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: releay bounce at boot

#17 Post by TD-er » 13 Jan 2021, 15:22

You could use the rules to act on the System#boot event and then use the commands ControllerDisable and ControllerEnable.
See: https://espeasy.readthedocs.io/en/lates ... mmand.html

For example, set a timer at boot and disable the controller.
Then, when the timer expires, you can enable the controller.

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#18 Post by s_p2003 » 14 Jan 2021, 14:48

Hi guys,

after many days of testing, I found an almost perfect solution.

Code: Select all

on System#Boot do
  ControllerDisable,2
  GPIO,12,0         // Rele 1 aperto
  GPIO,5,0          // Rele 2 aperto
  let,1,0           // imposta variabile 1 a 0
  timerSet,1,5     // imposta un timer di 5 secondi
endon

on WiFi#Connected do
  SendToHTTP 192.168.0.140,8080,/json.htm?type=command&param=switchlight&idx=80&switchcmd=Off
  SendToHTTP 192.168.0.140,8080,/json.htm?type=command&param=switchlight&idx=81&switchcmd=Off
endon

on MQTT#Connected do
  Publish %sysname%/gpio/12,0
  Publish %sysname%/gpio/5,0
endon

On Rules#Timer=1 do  // quando Timer1 finisce
  ControllerEnable,2 // abilita Domoticz HTTP
endon

on pulsante#stato do
  if [pulsante#stato]=1
    let,1,[int#1]+1
    if [int#1]=1
      gpio,12,1
      gpio,5,0
    elseif [int#1]=2
      gpio,12,0
      gpio,5,1
    elseif [int#1]=3
      gpio,12,0
      gpio,5,0
    elseif [int#1]=4
      let,1,0
      gpio,12,1
      gpio,5,1
    endif
  endif
endon
there is only one small problem:
if the last command to the relays was from domoticz, on restart the sonoff behaves as I wish, i.e. GPIO 12 and 5 always open, if instead the last command to the relays comes from Home Assistant, on restart the GPIOs close for a few instant and then they reopen.

As I said, almost perfect solution.
If anyone has an intuition, please write me !!
Thank you all.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: releay bounce at boot

#19 Post by TD-er » 14 Jan 2021, 14:58

Wifi#connected will happen before Mqtt#connected.
Maybe that's the difference here, Domoticz will be updated before Home Assistant?

s_p2003
Normal user
Posts: 17
Joined: 02 Jan 2018, 11:34

Re: releay bounce at boot

#20 Post by s_p2003 » 14 Jan 2021, 17:39

I don't think this is it.
What happens is strange, because it is not related to the rules, but to what happened to the relays BEFORE the reboot.
it is as if the MQTT broker updates the GPIO status before the sonoff rules intervene. I instead want the sonoff boot to update the broker, and not vice versa.
in fact there are some controller voices that I don't understand and couldn't find info.
Attachments
controller_1.png
controller_1.png (67.69 KiB) Viewed 8206 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: releay bounce at boot

#21 Post by TD-er » 14 Jan 2021, 18:29

See here for more info on the controller parameters: https://espeasy.readthedocs.io/en/lates ... parameters

Post Reply

Who is online

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