sendtohttp acknowledgement for rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

sendtohttp acknowledgement for rules

#1 Post by chromo23 » 20 Apr 2021, 09:59

Hi,

does anyone know if there is some kind of acknowledgement to sendtohttp i could use for rules?

eg:

on succesfull sendtohttp do

It´s for my battery powered sensor project. i would like to send the esp to sleep immediately after a succesfull sendtohttp

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sendtohttp acknowledgement for rules

#2 Post by Ath » 20 Apr 2021, 10:08

I do like your idea, but currently that's not supported.

It inspires me to create a PR for that ;)
Will be applicable to some other commands as well, just thinking if there should be a success / fail event, or just pass the HTTP status code returned.
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: sendtohttp acknowledgement for rules

#3 Post by chromo23 » 20 Apr 2021, 10:18

after many trial and error i ended up with this code and the last part would be a perfect fit for it :)

Code: Select all

On System#Boot do
 TaskRun,1
 TimerSet_ms,1,10	
Endon
	
On System#Wake do
 TaskRun,1
Endon

On WiFi#Connected do
 Let,1,1
Endon

On sensor_extern#Temperature do
 Let,2,1
Endon 

On Rules#Timer=1 do
 If [var#1]=1 and [var#2]=1
  SendToHTTP whatever you want
  Let,1,0
 Endif
 TimerSet_ms,1,10
Endon

///----would be a nice extra------
On successfull sendtohttp do
 If [Switch#State]=0
  deepsleep,600
 Endif
Endon
i could minimize the on-time without fiddling with the timings
depending on the router i have 1-2 seconds on-time. but still sometimes missing data (its seldom but annoying)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sendtohttp acknowledgement for rules

#4 Post by TD-er » 20 Apr 2021, 10:39

There is a checkbox for it on the Tools->Advanced page.
Top of that page: SendToHTTP wait for ack

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sendtohttp acknowledgement for rules

#5 Post by Ath » 20 Apr 2021, 10:43

In addition to the 'wait for ack' setting, I would want to suggest something like this:

Code: Select all

///----would be a nice extra------
On sendtohttp#status do // eventvalue1 = http status code, optional: eventvalue2 1 = success, 0 = fail
  If %eventvalue1% >= 200 and %eventvalue1% < 400
    If [Switch#State]=0
      deepsleep,600
    Endif
  Else
    // Fail catastrophically ?
  Endif
Endon
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: sendtohttp acknowledgement for rules

#6 Post by chromo23 » 20 Apr 2021, 10:48

TD-er wrote: 20 Apr 2021, 10:39 There is a checkbox for it on the Tools->Advanced page.
Top of that page: SendToHTTP wait for ack
Thats right but not the issue.
Timing is.
I want the on-time as short a possible and if the wifi connection takes longer on wake up, the esp goes to sleep before it can issue the sendtohttp command.
To circumvent that i would like to send the esp to sleep manually and directly after a successful sendtohttp as you can see in the end of the code i send in the last post...
Last edited by chromo23 on 20 Apr 2021, 13:10, edited 1 time in total.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: sendtohttp acknowledgement for rules

#7 Post by chromo23 » 20 Apr 2021, 10:53

@Ath looks good!

Code: Select all

///----would be a nice extra------
On sendtohttp#status do // eventvalue1 = http status code, optional: eventvalue2 1 = success, 0 = fail
  If %eventvalue1% >= 200 and %eventvalue1% < 400
    If [Switch#State]=0
      deepsleep,600
    Endif
  Else
    //try to send it 2 or 3 more times and then go to sleep   
  Endif
Endon
that the esp doesn’t stay awake forever i would send it back to sleep after some further attempts

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: sendtohttp acknowledgement for rules

#8 Post by TD-er » 20 Apr 2021, 11:09

Just realize this is a feature proposal from Ton, not yet working code.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests