Setting a dummy device value in rule
Moderators: grovkillen, Stuntteam, TD-er
Setting a dummy device value in rule
I'm sure this one is an easy one and I'm just not searching the forum and docs correctly. I need to store a value that can be queried later on from a REST call (like sensorupdate). My idea is to simply store what I need in a dummy device. I cannot find the proper call to set the value of this device in a rule. The dummy device is looking to store a 0 or 1. So basically, when one event fires store a 0 in dummy device and when another event fires store a 1 in dummy device. I'm sure this is easy but I just can't seem to find the call. Thank you
Re: Setting a dummy device value in rule
You can give the event command via HTTP and include a number of eventvalues.
For example the command:
If you enter it from the command field on the Tools page, you'll see the encoded URL:
The "eventname" is a name you can pick yourself and act on it in the rules:
Just be aware that %eventvalue3% for example will not be replaced by its value if less than 3 eventvalues are given. (same for %eventvalue2% etc)
See also https://espeasy.readthedocs.io/en/lates ... skvalueset
For example the command:
Code: Select all
Event,eventname=1,2,3,4
Code: Select all
http://192.168.10.151/tools?cmd=Event%2Ceventname%3D1%2C2%2C3%2C4
Code: Select all
on eventname do
taskvalueset,1,1,%eventvalue1%
taskvalueset,1,2,%eventvalue2%
taskvalueset,1,3,%eventvalue3%
taskvalueset,1,4,%eventvalue4%
endon
See also https://espeasy.readthedocs.io/en/lates ... skvalueset
Re: Setting a dummy device value in rule
Excellent, I'll give this a try. So when setting the value of the device I don't call it like this....
[DummyDevice#value] = someValue
I need to reference the device via the task number and the number of the specific item I want to set within that task. Is this correct? I'm pretty sure that is what you meant by the below but wanted to confirm.
taskvalueset,1,1,%eventvalue1%
Thank you again!
[DummyDevice#value] = someValue
I need to reference the device via the task number and the number of the specific item I want to set within that task. Is this correct? I'm pretty sure that is what you meant by the below but wanted to confirm.
taskvalueset,1,1,%eventvalue1%
Thank you again!
Re: Setting a dummy device value in rule
Yep, dummy task values must be set using taskvalueset command.
You can "read" them via [taskvaluename#variablename] syntax.
You can "read" them via [taskvaluename#variablename] syntax.
Re: Setting a dummy device value in rule
Perfect! Thank you very much!
Re: Setting a dummy device value in rule
I just wanted to post my final results just incase someone reads this thread and has the same reqs.
So now I can pass in the blow url to open the vent
http://192.168.86.52/control?cmd=event,controlVent=1
and to close the vent
http://192.168.86.52/control?cmd=event,controlVent=0
and I can get the status of the vent with
http://192.168.86.52/json?view=sensorupdate
I check the value being sent in from the URL. Based on that value I open or close the vent as well as set a dummy device which I can query later. This dummy device acts as a method of allowing me to run a REST call into the ESPEasy and get the vent's status.
Thank you again TD-er for all the help!
So now I can pass in the blow url to open the vent
http://192.168.86.52/control?cmd=event,controlVent=1
and to close the vent
http://192.168.86.52/control?cmd=event,controlVent=0
and I can get the status of the vent with
http://192.168.86.52/json?view=sensorupdate
I check the value being sent in from the URL. Based on that value I open or close the vent as well as set a dummy device which I can query later. This dummy device acts as a method of allowing me to run a REST call into the ESPEasy and get the vent's status.
Code: Select all
on controlVent do
if %eventvalue1%=1
LogEntry, 'Vent Open'
servo,1,14,90
taskvalueset,2,1,%eventvalue1%
else
LogEntry, 'Vent Closed'
servo,1,14,0
taskvalueset,2,1,%eventvalue1%
endif
endon
Who is online
Users browsing this forum: No registered users and 100 guests