http request doesn't alter value

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
obod0002c
Normal user
Posts: 119
Joined: 10 Aug 2019, 20:31

http request doesn't alter value

#1 Post by obod0002c » 10 Aug 2019, 21:06

Dear ESPEasy professional,

being a newbie to this great software, I have a problem which I thought I had solved, but it's back:

when sending http requests I can easily activate the relais of my ESP using a browser, e.g.
http://<ip>/control?cmd=gpio,4,1

But when trying to alter a value it doesn't work (anymore):
http://<ip>/control?cmd=event,httpvalue=5
gives me a nice OK-reply but the cvalue hasn't change when I reload the devices tab

Thanks for help
header.jpg
header.jpg (12.57 KiB) Viewed 9400 times
devices.jpg
devices.jpg (12.39 KiB) Viewed 9400 times
I thought I had it working already, but now it's not. Could it be 'cause I altered the RulesSet?
rules1.zip
(482 Bytes) Downloaded 228 times
I'm using mega-20190630.

Thanks for help
Last edited by obod0002c on 10 Aug 2019, 23:38, edited 1 time in total.

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

Re: http request doesn't alter value

#2 Post by grovkillen » 10 Aug 2019, 21:29

Sorry but I can't set the rules you're using. Please attach them in a "code" syntax.
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:

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: http request doesn't alter value

#3 Post by Shardan » 10 Aug 2019, 21:46

Hm...
Honestly I can't see what you're doing with the "event,httpvalue=5" command in your rules...

"event" creates an event so you can for example test what happens if a temperature goes to a certain value.

For changing a dummy value I'd use TaskValueSet, in your example "TaskValueSet,3,1,5"
(Task 3, Value 1, set to 5)
Regards
Shardan

obod0002c
Normal user
Posts: 119
Joined: 10 Aug 2019, 20:31

Re: http request doesn't alter value

#4 Post by obod0002c » 10 Aug 2019, 23:38

grovkillen wrote: 10 Aug 2019, 21:29 Sorry but I can't set the rules you're using. Please attach them in a "code" syntax.
A bit lengthy hence I thought a zip could be better.
As requested:

Code: Select all

on System#Boot do
 gpio,4,0 // sicherheitshalber
 TaskValueSet 2,1,2
           // 2 = Task# in "Devices"
           //   1 = erste Variable=Anzahl
           //     2x Bewässern tgl. = default
endon

On Clock#Time=All,06:00 do
 if [Bewaesserung#Anzahl] >= 1
  gpio,4,1  // Relais ein
  gpio,13,1 // rote LED ein
  timerSet,1,75 // Timer auf 75 Sekunden setzen
 endif
endon

On Clock#Time=All,16:00 do
 if [Bewaesserung#Anzahl] >= 2
  gpio,4,1  // Relais ein
  gpio,13,1 // rote LED ein
  timerSet,1,75 // Timer auf 75 Sekunden setzen
 endif
endon

On Clock#Time=All,12:00 do
 if [Bewaesserung#Anzahl] >= 3
  gpio,4,1  // Relais ein
  gpio,13,1 // rote LED ein
  timerSet,1,75 // Timer auf 75 Sekunden setzen
 endif
endon

On Clock#Time=All,22:00 do
 if [Bewaesserung#Anzahl] = 4
  gpio,4,1  // Relais ein
  gpio,13,1 // rote LED ein
  timerSet,1,75 // Timer auf 75 Sekunden setzen
 endif
endon

On Rules#Timer=1 do  
 gpio,4,0  // Ende Bewässerung
 gpio,13,0 // rote LED aus
endOn

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

Re: http request doesn't alter value

#5 Post by grovkillen » 11 Aug 2019, 12:03

Yes, like Shardan is pointing out, you haven't crashed an event. Maybe talk value set and run would be better?
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:

obod0002c
Normal user
Posts: 119
Joined: 10 Aug 2019, 20:31

Re: http request doesn't alter value

#6 Post by obod0002c » 11 Aug 2019, 16:33

sorry guys, but I don't understand what you're talking of. I'll try and put it in other words so maybe you understand me:

I simply want to set/alter a variable using an http command like this one
http://<ip>/control?cmd=event,<eventName>=<eventValue>

Thought the way to get it done was:
1. create a 'Generic - Dummy Device' and name it <eventName> and enable the device
2. name first variable to e.g. v1
3. set/alter the variable using http://<ip>/control?cmd=event,<eventName>=<eventValue>
4. new variable's value should now be visible in the device's section in column 'Values'
5. usage of the previously set variable in one of the rules, e.g. if [eventName#v1] = 1

But even step 4. doesn't work, hence step 5. not, too.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: http request doesn't alter value

#7 Post by ThomasB » 11 Aug 2019, 18:34

I simply want to set/alter a variable using an http command like this one
http://<ip>/control?cmd=event,<eventName>=<eventValue>
Changing a dummy var's value does not use a event command. It uses the taskvalueset command.

Working example:
Your screenshot shows the dummy var (httpvalue) is task #3. The value name (value1) is var #1.
If you wanted to change the dummy var's value to 5 then it would use this syntax:

Code: Select all

taskvalueset,3,1,5
Sending this via http would be like this:

Code: Select all

http://<espeasyip>/control?cmd=taskvalueset,3,1,5
- Thomas

obod0002c
Normal user
Posts: 119
Joined: 10 Aug 2019, 20:31

Re: http request doesn't alter value

#8 Post by obod0002c » 12 Aug 2019, 12:28

ThomasB wrote: 11 Aug 2019, 18:34
Changing a dummy var's value does not use a event command. It uses the taskvalueset command.
Thank you very much, I was so focussed on the 'event' that I didn't see how straight forward the solution could be.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 17 guests