Page 1 of 1
releay bounce at boot
Posted: 26 Dec 2020, 12:30
by s_p2003
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
Re: releay bounce at boot
Posted: 27 Dec 2020, 10:18
by s_p2003
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¶m=switchlight&idx=80&switchcmd=Off
SendToHTTP 192.168.0.140,8080,/json.htm?type=command¶m=switchlight&idx=81&switchcmd=Off
endon
Re: releay bounce at boot
Posted: 27 Dec 2020, 10:40
by TD-er
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
Re: releay bounce at boot
Posted: 27 Dec 2020, 11:19
by s_p2003
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.
Re: releay bounce at boot
Posted: 27 Dec 2020, 13:42
by TD-er
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.
Re: releay bounce at boot
Posted: 28 Dec 2020, 16:45
by s_p2003
hi TD-er
no intuition?
I also checked SendToHTTP wait for ack, but nothing has changed.
Re: releay bounce at boot
Posted: 28 Dec 2020, 17:17
by _Cyber_
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.
Re: releay bounce at boot
Posted: 28 Dec 2020, 19:22
by s_p2003
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.
Re: releay bounce at boot
Posted: 28 Dec 2020, 19:40
by Ath
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.
Re: releay bounce at boot
Posted: 28 Dec 2020, 19:58
by s_p2003
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
Re: releay bounce at boot
Posted: 29 Dec 2020, 10:03
by _Cyber_
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.
Re: releay bounce at boot
Posted: 29 Dec 2020, 19:07
by s_p2003
deleted the swith's rule and disabled the button on the case in devices (gpio-10).
the problem remains
Re: releay bounce at boot
Posted: 29 Dec 2020, 19:22
by Ath
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...
Re: releay bounce at boot
Posted: 30 Dec 2020, 20:46
by s_p2003
the problem does not arise if I exclude a controller
it doesn't matter which one it is.
Re: releay bounce at boot
Posted: 02 Jan 2021, 11:56
by s_p2003
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?
Re: releay bounce at boot
Posted: 13 Jan 2021, 15:13
by s_p2003
Hi guys
is it possible to delay starting a controller on startup with a rule? 20 or 30 seconds would be enough ...
Re: releay bounce at boot
Posted: 13 Jan 2021, 15:22
by TD-er
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.
Re: releay bounce at boot
Posted: 14 Jan 2021, 14:48
by s_p2003
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¶m=switchlight&idx=80&switchcmd=Off
SendToHTTP 192.168.0.140,8080,/json.htm?type=command¶m=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.
Re: releay bounce at boot
Posted: 14 Jan 2021, 14:58
by TD-er
Wifi#connected will happen before Mqtt#connected.
Maybe that's the difference here, Domoticz will be updated before Home Assistant?
Re: releay bounce at boot
Posted: 14 Jan 2021, 17:39
by s_p2003
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.
Re: releay bounce at boot
Posted: 14 Jan 2021, 18:29
by TD-er