Page 1 of 1

Rules help needed

Posted: 12 Mar 2020, 15:13
by StRess691
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.

Re: Rules help needed

Posted: 12 Mar 2020, 15:52
by Micha_he
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

Re: Rules help needed

Posted: 12 Mar 2020, 17:33
by StRess691
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.

Re: Rules help needed

Posted: 12 Mar 2020, 17:43
by grovkillen

Re: Rules help needed

Posted: 12 Mar 2020, 17:44
by StRess691
Yes, half last night. Even now I've been on this website, but can not find a sollution. Programming isn't my thing...

Re: Rules help needed

Posted: 12 Mar 2020, 18:01
by grovkillen
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

Re: Rules help needed

Posted: 12 Mar 2020, 18:05
by grovkillen
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

Re: Rules help needed

Posted: 12 Mar 2020, 18:12
by ThomasB
Another method: See the on GPIO#N section in the readthedocs.
https://espeasy.readthedocs.io/en/lates ... Rules.html

- Thomas

Re: Rules help needed

Posted: 12 Mar 2020, 18:18
by StRess691
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!

Re: Rules help needed

Posted: 12 Mar 2020, 18:30
by StRess691
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.

Re: Rules help needed

Posted: 12 Mar 2020, 18:42
by grovkillen
No currently you'd need to use that type of fix. We have some ideas that we might be able to implement.

Re: Rules help needed

Posted: 12 Mar 2020, 18:56
by StRess691
Anyhow, thank you for the ready-to-go solution!