Rules for sonoff dual R2
Moderators: grovkillen, Stuntteam, TD-er
Rules for sonoff dual R2
hi to all
i need help.
I would like to create a rule for the activation of the relays (on gpio 12 and gpio 5) when I press the button on the case (gpio 10).
The button on the case is set to "normal switch" so each press it switches 0-1-0.
How can it be done?
tnks
i need help.
I would like to create a rule for the activation of the relays (on gpio 12 and gpio 5) when I press the button on the case (gpio 10).
The button on the case is set to "normal switch" so each press it switches 0-1-0.
How can it be done?
tnks
Re: Rules for sonoff dual R2
You can set the switch task to be "Push button active low"
Let's assume the task is named "Button1" with the taskvalue "switch" and relay is on GPIO 12.
Then add this to the rules:
Let's assume the task is named "Button1" with the taskvalue "switch" and relay is on GPIO 12.
Then add this to the rules:
Code: Select all
on Button1#switch do
if [Button1#switch]=1
gpio,12,1
else
gpio,12,0
endif
endon
Re: Rules for sonoff dual R2
this is my rule but it does not work
i tried with Active High, Active Low and normal switch
i tried with Active High, Active Low and normal switch
Code: Select all
on pulsante#stato do
if [pulsante#stato]=1
gpio,12,1
gpio,5,0
elseif
gpio,12,0
gpio,5,1
elseif
gpio,12,1
gpio,5,1
elseif
gpio,12,0
gpio,5,0
endif
endon
Re: Rules for sonoff dual R2
What do you think this code will do?
I think the rules parser also doesn't know what to do with it.
Strip it to something like this:
Code: Select all
on pulsante#stato do
if [pulsante#stato]=1
gpio,12,1
gpio,5,0
elseif
gpio,12,0
gpio,5,1
elseif
gpio,12,1
gpio,5,1
elseif
gpio,12,0
gpio,5,0
endif
endon
Strip it to something like this:
Code: Select all
on pulsante#stato do
if [pulsante#stato]=1
gpio,12,1
gpio,5,0
elseif
gpio,12,0
gpio,5,1
endif
endon
Re: Rules for sonoff dual R2
First, thank you.
I would like to replicate the behavior of a monostable relay.
first press relay 1 closed and relay 2 open
second press relay 2 open and relay 2 closed
third press relay 1 and 2 closed
fourth press relay 1 and 2 open.
on system boot all open
and maybe also set the gpio led
I would like to replicate the behavior of a monostable relay.
first press relay 1 closed and relay 2 open
second press relay 2 open and relay 2 closed
third press relay 1 and 2 closed
fourth press relay 1 and 2 open.
on system boot all open
and maybe also set the gpio led
Re: Rules for sonoff dual R2
You should use a counter and set the counter and pin states at boot.
Not tested, but it should be something like this.
See: https://espeasy.readthedocs.io/en/lates ... Rules.html
Code: Select all
on System#Boot do
GPIO,12,0 // Relay 1 open
GPIO,5,1 // Relay 2 closed
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,0
gpio,5,0
elseif [int#1]=4
let,1,0
gpio,12,1
gpio,5,1
endif
endif
endon
See: https://espeasy.readthedocs.io/en/lates ... Rules.html
Re: Rules for sonoff dual R2
it works, but need to press button 2 times for status change
the gpio of button is set to active high
the gpio of button is set to active high
Re: Rules for sonoff dual R2
I think the switch setting should be changed from push button to normal switch.
You might also want to set the debounce value to 50 or 100 msec, to avoid 'nervous' like switching when lightly touching the button.
You might also want to set the debounce value to 50 or 100 msec, to avoid 'nervous' like switching when lightly touching the button.
/Ton (PayPal.me)
Re: Rules for sonoff dual R2
Perfect!!
thank you
thank you
Re: Rules for sonoff dual R2
Yep, mistake from my side.
I first suggested it based on the idea of mimicking the switch state to the relay state, but now we have a state machine of > 2 states, you must use it as a normal switch again as Ath suggested.
Glad it is working.
I first suggested it based on the idea of mimicking the switch state to the relay state, but now we have a state machine of > 2 states, you must use it as a normal switch again as Ath suggested.
Glad it is working.
Who is online
Users browsing this forum: Bing [Bot] and 49 guests