IF statement on %eventvalue%
Moderators: grovkillen, Stuntteam, TD-er
IF statement on %eventvalue%
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
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
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: IF statement on %eventvalue%
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.
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: IF statement on %eventvalue%
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!
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!
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: IF statement on %eventvalue%
Aaah!! You're right. Sorry, wrote it on my phone and didn't think straight

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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: IF statement on %eventvalue%
It is possible with TaskValueSetgrovkillen wrote: ↑23 Oct 2017, 16:16Aaah!! You're right. Sorry, wrote it on my phone and didn't think straight![]()
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
Re: IF statement on %eventvalue%
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
That should work!
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
Re: IF statement on %eventvalue%
Not working. Messed the rules! BTW: TaskValueSet need 3 parameter...
Re: IF statement on %eventvalue%
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
Re: IF statement on %eventvalue%
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.... 
The messed rules seem to be an issue of core 2.4.0....

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

Re: IF statement on %eventvalue%
I just tested this on one of my nodes running R142
it definitly works the way I described
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
Re: IF statement on %eventvalue%
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: IF statement on %eventvalue%
Ok, now I got it. The "=" after event name was wrong (I had ",")... 

Re: IF statement on %eventvalue%
Code: Select all
on testevent do
TaskValueSet 5,4,%eventvalue%
endon
Code: Select all
http://x.x.x.x/control?cmd=event,testevent=3
Re: IF statement on %eventvalue%
Thanks guy's, this works a treat 

- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: IF statement on %eventvalue%
I have now moved this section to its correct sectiontoffel969 wrote: ↑23 Oct 2017, 19:59You can send values, check the wiki
https://www.letscontrolit.com/wiki/inde ... _Variables

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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: IF statement on %eventvalue%
I use this rule set to pass GPIO # as event argument.
Regards,
Code: Select all
on sniff#a do
event event1=%eventvalue%
endon
on event1 do
pcfpulse %eventvalue%,0,200
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: IF statement on %eventvalue%
Clever, will try to add this to the wiki as well.danmero wrote: ↑20 Nov 2017, 15:20 I use this rule set to pass GPIO # as event argument.Regards,Code: Select all
on sniff#a do event event1=%eventvalue% endon on event1 do pcfpulse %eventvalue%,0,200 endon
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Who is online
Users browsing this forum: No registered users and 18 guests