Ruls do not show the state of GPIOs under divices

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

Ruls do not show the state of GPIOs under divices

#1 Post by leachimtrebron » 23 Dec 2019, 17:07

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?

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

Re: Ruls do not show the state of GPIOs under divices

#2 Post by grovkillen » 23 Dec 2019, 19:07

You shouldn't use GPIO directly, send an event instead
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:

leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

Re: Ruls do not show the state of GPIOs under divices

#3 Post by leachimtrebron » 23 Dec 2019, 23:59

Thank you
could you please show me an example of how I can create an event in rules

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

Re: Ruls do not show the state of GPIOs under divices

#4 Post by grovkillen » 24 Dec 2019, 02:43

You already have, use this instead of the GPIO cmd in the URL

http://192.168.178.161/control?cmd=event,start-gpio14
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:

leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

Re: Ruls do not show the state of GPIOs under divices

#5 Post by leachimtrebron » 24 Dec 2019, 13:11

@ 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:
on BMx280 # Humidity> 55 do
     http://192.168.178.161/control?cmd=GPIO,14,1
endon

does anyone else have a suggestion?

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

Re: Ruls do not show the state of GPIOs under divices

#6 Post by grovkillen » 24 Dec 2019, 18:24

I might be a bit slow but please explain a bit more.
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: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Ruls do not show the state of GPIOs under divices

#7 Post by ThomasB » 24 Dec 2019, 19:23

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.
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.
I cannot send http://192.168.178.161/control?cmd=event,start-gpio14 from Rules.

Code: Select all

on BMx280 # Humidity> 55 do
     http://192.168.178.161/control?cmd=GPIO,14,1
endon 
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

leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

Re: Ruls do not show the state of GPIOs under divices

#8 Post by leachimtrebron » 25 Dec 2019, 14:39

@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.

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

Re: Ruls do not show the state of GPIOs under divices

#9 Post by grovkillen » 25 Dec 2019, 15:09

TaskRun is needed. Have you tried that? And have you studied the https://espeasy.readthedocs.io/en/lates ... mmand.html
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:

leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

Re: Ruls do not show the state of GPIOs under divices

#10 Post by leachimtrebron » 25 Dec 2019, 18:12

@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?

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

Re: Ruls do not show the state of GPIOs under divices

#11 Post by grovkillen » 25 Dec 2019, 18:40

Change TaskValueSet,4,1,0 to TaskValueSetAndRun,4,1,0. That way you don't need the first run command.
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests