RULES: press button switcher for 2 or 3 relays (no longpress!)

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Velly
New user
Posts: 3
Joined: 17 Nov 2018, 21:52

RULES: press button switcher for 2 or 3 relays (no longpress!)

#1 Post by Velly » 17 Nov 2018, 22:02

Hi

Ask for pro asiistance in making quite banal rule:
I have one press Button and 2 relays (=2 GPIO used)

Need to make the rule for several single consequtive presses like:
[first short press] : relay1=ON and relay2=ON
[second press]: relay1=ON and relay2=OFF
[third press]: relay1=OFF and relay2=ON
[forth press]: both relays are OFF

I tried.... many possible ways but failed..
seemed to me quite easy with condition:
if RELAY1=1 and RELAY2=0
do
RELAY1=0
RELAY2=1

I failed... Of course I used correct syntax in rule , upper is just example of idea (bad idea)..

Thank you!

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

Re: RULES: press button switcher for 2 or 3 relays (no longpress!)

#2 Post by grovkillen » 17 Nov 2018, 22:13

Please provide the version you're running and the rules you're using.
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:

Velly
New user
Posts: 3
Joined: 17 Nov 2018, 21:52

Re: RULES: press button switcher for 2 or 3 relays (no longpress!)

#3 Post by Velly » 17 Nov 2018, 22:36

mega-20181112 dev for ESP8266 (nodeMCU)

my rules are not working...
LED_switcher#Switcher: pushbutton
LED_warm#Switch: relay1
LED_cold#Switch: relay2

On LED_switcher#Switcher do
if [LED_warm#Switch]=0 and if [LED_cold#Switch]=0
gpio,14,1
gpio,13,1
else
gpio,14,0
gpio,13,0
endif
endon

I tried to mention various IF conditions like:

On LED_switcher#Switcher do
if [LED_warm#Switch]=0 and if [LED_cold#Switch]=0 // FIRST press - relay1=ON and relay2=ON
do
gpio,14,1
gpio,13,1


if [LED_warm#Switch]=1 and if [LED_cold#Switch]=1 // SECOND pRESS - relay 1=OFF relay2=ON
do
gpio,14,0
gpio,13,1

if [LED_warm#Switch]=0 and if [LED_cold#Switch]=1 // THIRD PRESS relay1=ON relay2=OFF
do
gpio,14,1
gpio,13,0
if [LED_warm#Switch]=1 and if [LED_cold#Switch]=0 // another press relay1=OFF relay2=OFF
do
gpio,14,0
gpio,13,0


etc .. - but it is not working.

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

Re: RULES: press button switcher for 2 or 3 relays (no longpress!)

#4 Post by grovkillen » 17 Nov 2018, 23:31

AND/OR is not using ifs, just the first if should be there.
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:

Velly
New user
Posts: 3
Joined: 17 Nov 2018, 21:52

Re: RULES: press button switcher for 2 or 3 relays (no longpress!)

#5 Post by Velly » 18 Nov 2018, 00:24

Thank you! Stupid mistake...

now the code is like and working ppefectly

on System#Boot do
GPIO,14,0
GPIO,13,0
endon

On LED_switcher#Switcher do
if [LED_warm#Switch]=0 and [LED_cold#Switch]=0
gpio,14,1
gpio,13,1
endif
endon

On LED_switcher#Switcher do
if [LED_warm#Switch]=1 and [LED_cold#Switch]=1
gpio,14,1
gpio,13,0
endif
endon

On LED_switcher#Switcher do
if [LED_warm#Switch]=1 and [LED_cold#Switch]=0
gpio,14,0
gpio,13,1
endif
endon

On LED_switcher#Switcher do
if [LED_warm#Switch]=0 and [LED_cold#Switch]=1
gpio,14,0
gpio,13,0
endif
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 102 guests