Rules help needed

Moderators: grovkillen, TD-er, Stuntteam

Post Reply
Message
Author
StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Rules help needed

#1 Post by StRess691 » 12 Mar 2020, 15:13

Hello Everyone!

I need a little bit of your knowledge, because of my lack of it.
Tried to search the forum but couldn't find an answer for my question.

I'm using Wemos D1 mini with newest ESPEasy software.
Wemos is controlled by Domoticz.
To this Wemos I connected 3 relays, to GPIO 12, 13 and 14 and created 3 "normal switches".

I would like to control a device with this Wemos, for which I need those 3 relays. The thing is, that only one relay should be in "on" state at once, so when I send with the Domoticz command to ESP to turn on GPIO 12 I would like pins 13 and 14 to be off.

I can program this with Domoticz, but anyhow I would like to be "double-safe" and make it also by the rules in ESP.

Can you please help me how can I achieve this? I tried in many different ways, but without success.

Thank you in advance.

Micha_he
Normal user
Posts: 140
Joined: 07 Feb 2018, 19:14

Re: Rules help needed

#2 Post by Micha_he » 12 Mar 2020, 15:52

You should use events to switch your relays.

Code: Select all

on eventname1 do
  GPIO,12,1
  GPIO,13,0
  GPIO,14,0
endon
Now you just have to see how you trigger the event from Domoticz. Via http it looks like this:

Code: Select all

http://<espeasyip>/control?cmd=event,eventname1

StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Re: Rules help needed

#3 Post by StRess691 » 12 Mar 2020, 17:33

I'm sending from Domoticz command:
http://192.168.1.210/control?cmd=GPIO,13,1

and made in Rules:
on GPIO,12,1 do
GPIO,16,0
GPIO,13,0
GPIO,14,0
GPIO,12,1
endon

on GPIO,13,1 do
GPIO,12,0
GPIO,16,0
GPIO,14,0
GPIO,13,1
endon

on GPIO,14,1 do
GPIO,12,0
GPIO,13,0
GPIO,16,0
GPIO,14,1
endon

on GPIO,16,1 do
GPIO,12,0
GPIO,13,0
GPIO,14,0
GPIO,16,1
endon

Doesn't work unfortunately.

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

Re: Rules help needed

#4 Post by grovkillen » 12 Mar 2020, 17:43

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:

StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Re: Rules help needed

#5 Post by StRess691 » 12 Mar 2020, 17:44

Yes, half last night. Even now I've been on this website, but can not find a sollution. Programming isn't my thing...

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

Re: Rules help needed

#6 Post by grovkillen » 12 Mar 2020, 18:01

Your syntax on GPIO,16,1 do isn't correct. This example in the rules might be a start?

Code: Select all

on ToggleGPIO do
  GPIO,%eventvalue1%,%eventvalue2%
endon
Triggered like this:

http://<espeasyip>/control?cmd=event,ToggleGPIO=12,1
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:

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

Re: Rules help needed

#7 Post by grovkillen » 12 Mar 2020, 18:05

This might be working?

Code: Select all

on GPIOtoggle do
GPIO,12,0
GPIO,13,0
GPIO,14,0
GPIO,16,0
GPIO,%eventvalue%,1
endon
http://<espeasyip>/control?cmd=event,GPIOtoggle=12
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:

User avatar
ThomasB
Normal user
Posts: 690
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules help needed

#8 Post by ThomasB » 12 Mar 2020, 18:12

Another method: See the on GPIO#N section in the readthedocs.
https://espeasy.readthedocs.io/en/lates ... Rules.html

- Thomas

StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Re: Rules help needed

#9 Post by StRess691 » 12 Mar 2020, 18:18

Works like a charm with one exception - after hitting "off", relay connected to "off" is switching for a couple of milliseconds and previous value is coming back. So if I had switched the selector switch to 3, then I hit OFF, it will change to OFF for a while and get back to 3.
grovkillen wrote:
12 Mar 2020, 18:05
This might be working?

Code: Select all

on GPIOtoggle do
GPIO,12,0
GPIO,13,0
GPIO,14,0
GPIO,16,0
GPIO,%eventvalue%,1
endon
http://<espeasyip>/control?cmd=event,GPIOtoggle=12

Edit:
After removing all the devices from ESP and left this tab empty, everything works fine.
Thank you!

StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Re: Rules help needed

#10 Post by StRess691 » 12 Mar 2020, 18:30

One more thing. After resetting ESP value doesn't come back to previous state - it doesn't read the value from Domoticz, as there is no code for that.
Is it possible to make it work?

If not, I will make just simple:

Code: Select all

On System#Boot do
  GPIO,16,1
endon
for default value to be working.

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

Re: Rules help needed

#11 Post by grovkillen » 12 Mar 2020, 18:42

No currently you'd need to use that type of fix. We have some ideas that we might be able to implement.
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:

StRess691
Normal user
Posts: 6
Joined: 12 Mar 2020, 15:03

Re: Rules help needed

#12 Post by StRess691 » 12 Mar 2020, 18:56

Anyhow, thank you for the ready-to-go solution!

RobertBurton45
Normal user
Posts: 10
Joined: 28 Feb 2020, 02:46

Re: Rules help needed

#13 Post by RobertBurton45 » 15 Mar 2020, 23:28

Thank you !!

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests