IF statement on %eventvalue%

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

IF statement on %eventvalue%

#1 Post by rayE » 23 Oct 2017, 12:50

Hi,
V2.0

I set up a rule as follows.

on configFlowSensor do
if [%eventvalue%] = 1
// Do something like set a GPIO output
endif
endon

I send the following HTTP request.
http://<your esp ip>/control?cmd=event,configFlowSenor=1

With the IF statement i get no response, without the IF statement it will set the digital output. The IF statement seems to ignore the value in %eventvalue% although it does trigger the rule.

Any pointers?

TIA
Ray

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

Re: IF statement on %eventvalue%

#2 Post by grovkillen » 23 Oct 2017, 14:39

As seen in the wiki here: https://www.letscontrolit.com/wiki/inde ... _Reference you cannot pass values with the event command.

To do so I suggest you try the TaskValueSet together with a dummy device (if you insist on using HTTP). If you use MQTT you could resolve the matter by using the MQTT import or use the TaskValueSet via cmd.
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
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: IF statement on %eventvalue%

#3 Post by vader » 23 Oct 2017, 15:15

What about the rule

on configFlowSensor do
if [configFlowSensor#ValueOfDevice] = 1
// Do something like set a GPIO output
endif
endon

@grovkillen: You wrote "use the TaskValueSet via cmd". TaskValueSet is declared in the Wiki as rule command only, not for external usage!

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

Re: IF statement on %eventvalue%

#4 Post by grovkillen » 23 Oct 2017, 16:16

vader wrote: 23 Oct 2017, 15:15 @grovkillen: You wrote "use the TaskValueSet via cmd". TaskValueSet is declared in the Wiki as rule command only, not for external usage!
Aaah!! You're right. Sorry, wrote it on my phone and didn't think straight :oops:
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
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: IF statement on %eventvalue%

#5 Post by toffel969 » 23 Oct 2017, 18:23

grovkillen wrote: 23 Oct 2017, 16:16
vader wrote: 23 Oct 2017, 15:15 @grovkillen: You wrote "use the TaskValueSet via cmd". TaskValueSet is declared in the Wiki as rule command only, not for external usage!
Aaah!! You're right. Sorry, wrote it on my phone and didn't think straight :oops:
It is possible with TaskValueSet

You sent event value and write it into a dummy using taskvalueset within the event. Then you can check the dummys value within rules.
Last edited by toffel969 on 23 Oct 2017, 18:31, edited 1 time in total.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: IF statement on %eventvalue%

#6 Post by toffel969 » 23 Oct 2017, 18:30

You still start by sending http command with event value:
http://<your esp ip>/control?cmd=event,configFlowSenor=1

On the receiving ESP you create a Dummy device, lets say as device 1 in the device Tab. You name the value , for example memory

Code: Select all

On configFlowSensor do 
TaskValueSet 1,%eventvalue%
if [Dummy#memory]=1 
// Do something 
endif 
endon

That should work!
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: IF statement on %eventvalue%

#7 Post by vader » 23 Oct 2017, 19:20

Not working. Messed the rules! BTW: TaskValueSet need 3 parameter...

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: IF statement on %eventvalue%

#8 Post by toffel969 » 23 Oct 2017, 19:28

vader wrote: 23 Oct 2017, 19:20 Not working. Messed the rules! BTW: TaskValueSet need 3 parameter...
You are right about the TaskValueSet needing 3 parameters. But then there is no reason y th shouldn't work
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: IF statement on %eventvalue%

#9 Post by vader » 23 Oct 2017, 19:44

I've tested it and does not work for me. I mean, you can not transmit values to an event. The parser seems to ignore more than 1 value after "event". It is only interested in the event name.... :D

The messed rules seem to be an issue of core 2.4.0.... :?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: IF statement on %eventvalue%

#10 Post by toffel969 » 23 Oct 2017, 19:58

I just tested this on one of my nodes running R142

it definitly works the way I described
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: IF statement on %eventvalue%

#11 Post by toffel969 » 23 Oct 2017, 19:59

vader wrote: 23 Oct 2017, 19:44 I've tested it and does not work for me. I mean, you can not transmit values to an event. The parser seems to ignore more than 1 value after "event". It is only interested in the event name.... :D

The messed rules seem to be an issue of core 2.4.0.... :?
You can send values, check the wiki
https://www.letscontrolit.com/wiki/inde ... _Variables
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: IF statement on %eventvalue%

#12 Post by vader » 23 Oct 2017, 20:10

Ok, now I got it. The "=" after event name was wrong (I had ",")... :oops:

danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: IF statement on %eventvalue%

#13 Post by danmero » 23 Oct 2017, 23:16

Code: Select all

on testevent do
  TaskValueSet 5,4,%eventvalue%
endon

Code: Select all

http://x.x.x.x/control?cmd=event,testevent=3
This works on 2.0.0.x

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: IF statement on %eventvalue%

#14 Post by rayE » 24 Oct 2017, 02:53

Thanks guy's, this works a treat :-)

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

Re: IF statement on %eventvalue%

#15 Post by grovkillen » 24 Oct 2017, 07:54

toffel969 wrote: 23 Oct 2017, 19:59
vader wrote: 23 Oct 2017, 19:44 I've tested it and does not work for me. I mean, you can not transmit values to an event. The parser seems to ignore more than 1 value after "event". It is only interested in the event name.... :D

The messed rules seem to be an issue of core 2.4.0.... :?
You can send values, check the wiki
https://www.letscontrolit.com/wiki/inde ... _Variables
I have now moved this section to its correct section 8-)

https://www.letscontrolit.com/wiki/inde ... alue.25.29

I hope more people will use this awesome technique (I sure hadn't seen it before you pointed it out).
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:

danmero
Normal user
Posts: 64
Joined: 11 May 2017, 01:19

Re: IF statement on %eventvalue%

#16 Post by danmero » 20 Nov 2017, 15:20

I use this rule set to pass GPIO # as event argument.

Code: Select all

on sniff#a do
  event event1=%eventvalue%
endon

on event1 do
  pcfpulse %eventvalue%,0,200
endon
Regards,

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

Re: IF statement on %eventvalue%

#17 Post by grovkillen » 20 Nov 2017, 16:32

danmero wrote: 20 Nov 2017, 15:20 I use this rule set to pass GPIO # as event argument.

Code: Select all

on sniff#a do
  event event1=%eventvalue%
endon

on event1 do
  pcfpulse %eventvalue%,0,200
endon
Regards,
Clever, will try to add this to the wiki as well.
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 22 guests