Page 1 of 1
GPIO pin status at rules engine
Posted: 09 Sep 2017, 20:52
by hiihoo
Hello all.
Very first post..

Exciting..
https://www.letscontrolit.com/wiki/inde ... _Reference
Says:
Command Class Purpose Syntax
Status Plugin Show status on previously controlled pins Status <device>,<pin>
and stated:
Plugins - Can be run from serial, rules engine, HTTP, MQTT
Very well. But how?-) Meaning using it at rules engine.
Many examples deploy "extra" switch for getting gpio state, but if I'm not misunderstood, it should work directly also?
via
http://192.168.1.xx/control?cmd=status,gpio,12 i can get gpio status directly without extra switches.
I have sonoff basic, and want its relay to be ON at boot, so gpio 12 is default ACTIVE.
But if i have input switch task connected to gpio 12 to read relay state, it apparently puts relay off after couple of seconds after boot.
After that it works like it should, but initially it just ruins idea about light been "manually" operated..
One could write some system#boot gpio,12,1 rule, but even then relay goes off for moment and on again, not "professional"..
So.. It this a bug or a fly, or just a way it should work?
Firmware is espEasy.2.0.0-dev11_normal_8285.bin.
Re: GPIO pin status at rules engine
Posted: 10 Sep 2017, 20:54
by toffel969
You can probably get the gpio state(use in if condition) , but this way you are not able to start an event, trigger something, you can just check from existing event
If you want more professional advice on Rules +gpio + boot state post your rules, devices and config tab.
Re: GPIO pin status at rules engine
Posted: 11 Sep 2017, 14:17
by hiihoo
Thanks for reply, just happened to read my original post also..
Sorry, I was not making my question clear.
I was looking for
syntax / format, to use with "status,gpio,12" in rules engine.
Like:
Code: Select all
On Button#Switch do
If [status,gpio,12]=1
gpio,12,0
gpio,13,1
else
gpio,12,1
gpio,13,0
endif
endon
Won't work.

Re: GPIO pin status at rules engine
Posted: 11 Sep 2017, 15:30
by grovkillen
This is the correct syntax for that. Since you already have a switch device you use that variable an not the state of the gpio.
Code: Select all
On Button#Switch do
If [Button#Switch]=1
gpio,12,0
gpio,13,1
else
gpio,12,1
gpio,13,0
endif
endon
Or as this:
Code: Select all
On Button#Switch=1 do
gpio,12,0
gpio,13,1
endon
On Button#Switch=0 do
gpio,12,1
gpio,13,0
endon
Re: GPIO pin status at rules engine
Posted: 11 Sep 2017, 20:17
by hiihoo
Yes, it can be done that way, and there are million zillion ways.
My point, to be exact, is that how / or anyway, is it possible to us "status,gpio,12" in rules engine.
Documentation implies that it could be possible, looking for syntax for that.
Thanks for example, appreciate help, but someday, when you least except it, it might be usefull to get gpio status straight away...

Re: GPIO pin status at rules engine
Posted: 11 Sep 2017, 23:02
by toffel969
I get your point, though can't help you with that
Re: GPIO pin status at rules engine
Posted: 21 Sep 2017, 21:05
by ut1545
Hello,
I'd like to do the same as hiihoo. My ESP Easy node is controlling 16 relays so, it is not desirable to have to define 16 switches devices only to know gpio state in a rule.
Those relays are activated/deactivated by an openHab controller and in specific situations, I need to know gpio states.
Any idea?
Thanks in advance for any help.
Re: GPIO pin status at rules engine
Posted: 21 Sep 2017, 21:41
by toffel969
ut1545 wrote: ↑21 Sep 2017, 21:05
Hello,
I'd like to do the same as hiihoo. My ESP Easy node is controlling 16 relays so, it is not desirable to have to define 16 switches devices only to know gpio state in a rule.
Those relays are activated/deactivated by an openHab controller and in specific situations, I need to know gpio states.
Any idea?
Thanks in advance for any help.
You could use 4 dummy devices with 4var each, that's what I did on my 8 relay (i2c expander) multisensor node. Still not exactly what you ask for, but 12 less devices for 16 relay states. Just set the dummies whenever you set the gpios
Re: GPIO pin status at rules engine
Posted: 25 Sep 2017, 13:48
by ut1545
Hi,
Thank you for your response. Your suggestion, setting dummy variables, is a good solution. BTW, I'm looking for a new approach. I will explain the idea if it can be useful for other people.
I'm controlling a irrigation system through openHab controller so, when it is time to start a irrigation zone, it sends a MQTT message to ESP Easy node in order to turn on a gpio and sends another message when irrigation timer has finished to turn off the gpio. The problem occurs when openHab, for any reason, doesn't send the turn off message or when it doesn't arrive into EspEasy so, the irrigation zone will be turned on for all eternity.....
There are several approaches to solve this but, my favorite is the following: Using a dummy device and some ESPEasyrules, the openHab server sends a timer value and the gpio number to ESPEasy in order to start a irrigation zone for a time. Once the timer value expires, ESPEasy turns the gpio off. In this way, if the controller fails after the zone has started, the ESPEasy will turn it off anyway.
Thanks,
Re: GPIO pin status at rules engine
Posted: 25 Sep 2017, 16:03
by maluko
i have a irrigation system too with espeasy and domoticz to controll 8 relay, you for 16 can use the rules to controll it like this
Code: Select all
on relay1 do
gpio,1,1
timerset 1,1800 //max timer to esp turn gpio off
endoff
on Rules#Timer=1 do
gpio,1,0
SendToHTTP domoticzip,8080,/json.htm?type=param=switchlight&command&idx=101&switchcmd=Off
endoff
on relay2 do
gpio,2,1
timerset 2,1800 //max timer to esp turn gpio off
endoff
on Rules#Timer=2 do
gpio,2,0
SendToHTTP domoticzip,8080,/json.htm?type=param=switchlight&command&idx=102&switchcmd=Off
endoff
etc....
to begin the relay1 you have to put this on your controller
http://<espeasyip>/control?cmd=event,relay1