Page 1 of 1
Ruls do not show the state of GPIOs under divices
Posted: 23 Dec 2019, 17:07
by leachimtrebron
Hello everybody,
I encountered a problem with the Ruls and I hope you can help me further
Task:
If the air humidity is over 55%, a relay on the GPIO12 should be switched on for 5 seconds
If the air humidity is below 50%, an LED on the GPIO14 should be switched on for 5 seconds
Both state (GPIO12 and 14)
reported via MQTT and LCD-Display.
Built ruls:
On start-gpio12 do
LongPulse,12,1,5
Endon
On start-gpio14 do
LongPulse,14,1,5
endon
on BMx280#Humidity<50 do
Event start-gpio14
endon
on BMx280#Humidity>55 do
Event start-gpio13
endon
Is installed:
ESP_Easy_mega-20191208_normal_ESP8266_4M1M.bin
my problem:
I switch the GPIOs over:
http://192.168.178.161/control?cmd=GPIO,14,1
The
state are correctly reported on the MQTT and displayed on LCD display.
If the information for switching comes from the Ruls, the state
is not reported via MQTT displayed on LCD display.
Does somebody has any idea?
Re: Ruls do not show the state of GPIOs under divices
Posted: 23 Dec 2019, 19:07
by grovkillen
You shouldn't use GPIO directly, send an event instead
Re: Ruls do not show the state of GPIOs under divices
Posted: 23 Dec 2019, 23:59
by leachimtrebron
Thank you
could you please show me an example of how I can create an event in rules
Re: Ruls do not show the state of GPIOs under divices
Posted: 24 Dec 2019, 02:43
by grovkillen
You already have, use this instead of the GPIO cmd in the URL
http://192.168.178.161/control?cmd=event,start-gpio14
Re: Ruls do not show the state of GPIOs under divices
Posted: 24 Dec 2019, 13:11
by leachimtrebron
@ grovkillen:
Your suggestion doesn't seem right
State is displayed:
http://192.168.178.161/control?cmd=GPIO,14,1
State is
not displayed:
http://192.168.178.161/control?cmd=event,start-gpio14
I would like if BMx280 # Humidity> 55, the GPIO14 goes to 1 and this status is also sent via MQTT.
I cannot send
http://192.168.178.161/control?cmd=event,start-gpio14 from Rules
that's
not how it works:
does anyone else have a suggestion?
Re: Ruls do not show the state of GPIOs under divices
Posted: 24 Dec 2019, 18:24
by grovkillen
I might be a bit slow but please explain a bit more.
Re: Ruls do not show the state of GPIOs under divices
Posted: 24 Dec 2019, 19:23
by ThomasB
Setting GPIO14 to logic high is not the same thing as briefly pulsing it (per your event rule). This may explain the difference you see.
That URL is not a valid rule statement (it's only valid from a web browser).
BTW, your event naming syntax might confuse the rules parser. For example, instead of "start-gpio14" I suggest removing the hyphen (subtraction sign) and change it to "StartGpio14."
Also, officially the
Event command would be followed by a comma. A space may be supported (?), but until things are working I suggest you use a comma. Like seen in this updated rule set (untested):
Code: Select all
On StartGpio12 do
LongPulse,12,1,5
Endon
On StartGpio14 do
LongPulse,14,1,5
endon
on BMx280#Humidity<50 do
Event,StartGpio14
endon
on BMx280#Humidity>55 do
Event,StartGpio12
endon
This new example also corrects the name typo found in the bottom rule. That is to say, you incorrectly typed "start-gpio13" which was an undefined event name.
- Thomas
Re: Ruls do not show the state of GPIOs under divices
Posted: 25 Dec 2019, 14:39
by leachimtrebron
@Thomas:
Thanks for your quick reply.
unfortunately that still doesn't solve my problem.
Signaling via MQTT does not work
the current stage from the GPIO is not transmitted, it always remains at 0 even though it is 1
Via the URL in the browser
http://192.168.178.161/control?cmd=GPIO,14,1, GPIO is also set to 1 and does not signal in MQTT if the 5 seconds have passed
On StartGpio14 do
Long Pulse, 14,1,5
endon
there should be a way to change the status within Ruls.
this does not currently appear to be implementedhe browser
http://192.168.178.161/control?cmd=GPIO,14,1 the state is correctly transmitted to the MQTT broker.
Re: Ruls do not show the state of GPIOs under divices
Posted: 25 Dec 2019, 15:09
by grovkillen
TaskRun is needed. Have you tried that? And have you studied the
https://espeasy.readthedocs.io/en/lates ... mmand.html
Re: Ruls do not show the state of GPIOs under divices
Posted: 25 Dec 2019, 18:12
by leachimtrebron
@grovkillen
I have now found a pragmatic solution. it is not elegant but seems to work
Code: Select all
On StartGpio12 do
LongPulse,12,1,5 //gpio12 ==> 5 Sec =on
Endon
On startgpio13 do
LongPulse,13,1,5 //gpio13 ==> 5 Sec = on
endon
On StartGpio14 do
taskRun,4 // The GPIO is defined in task-ID: #4
LongPulse,14,1,5 //gpio14 ==> 5 Sec = on
TaskValueSet,4,1,0 // State from gpio14 ==> off
endon
on BMx280#Humidity<50 do
TaskValueSet,4,1,1 // State from gpio14 ==> on
Event,StartGpio14
endon
on BMx280#Humidity>55 do
Event,StartGpio12
endon
ist TaskRun so richtig angewendet?
what could be done better?
Re: Ruls do not show the state of GPIOs under divices
Posted: 25 Dec 2019, 18:40
by grovkillen
Change TaskValueSet,4,1,0 to TaskValueSetAndRun,4,1,0. That way you don't need the first run command.