HTTP request in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

HTTP request in rules

#1 Post by remko2000 » 22 Nov 2020, 14:23

I've an espeasy CO2 sensor and with this I want to send a window open. A can control my axa remote (= window opener) with this call from domoticz:

Code: Select all

http://10.0.1.102/open
So I thought I make a rule which send this command when my CO2 sensor reach a value of 2500 ppm. This is my rule:

Code: Select all

On CO2#PPM do
 if  [CO2#PPM]>2500
    SendToHTTP http://10.0.1.102/open
  endif
 endon
Problem is that this doesn't work. I read the wiki with tutorial rules but I don't find a proper example so this isn't help me. Someone any suggestions?

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

Re: HTTP request in rules

#2 Post by Ath » 22 Nov 2020, 14:54

You have the syntax for SendToHTTP wrong,
it should be something like this:

Code: Select all

On CO2#PPM do
 if  [CO2#PPM]>2500
    SendToHTTP,10.0.1.102,80,/open
  endif
 endon
- No protocol prefix (ESPEasy only supports http, and that is implied by the command)
- Separate arguments for ip/hostname, port and file/location

The command syntax can be found here: https://espeasy.readthedocs.io/en/lates ... mmand.html
/Ton (PayPal.me)

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: HTTP request in rules

#3 Post by remko2000 » 23 Nov 2020, 16:50

Indeed:

Code: Select all

On CO2#PPM do
 if  [CO2#PPM]>900
    SendToHTTP,10.0.1.125,80,/open
else
    SendToHTTP,10.0.1.125,80,/close
  endif
 endon
does the job.

The thing I don't like is the fact that my esp with CO2sensor constantly send 10.0.1.120,80,/open of 10.0.1.120,80,/close (dependig of the tresshold). It would be better when this wemos only send one command when it reaches the thresshold and one when it falls below the thresshold. Is this possible?

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

Re: HTTP request in rules

#4 Post by TD-er » 23 Nov 2020, 16:56

You can have a look at the "level" plugin to implement some kind of hysteresis like behavior.

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: HTTP request in rules

#5 Post by remko2000 » 25 Nov 2020, 17:34

I read the wiki of this levelplugin but I see it's combined a setpoint with an action on a GPIO (high of low). I don't want to have an action on a GPIO, I want to have a httprequest when the setpoint is reached. I don't read there is a possibility to do something like this?

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

Re: HTTP request in rules

#6 Post by Ath » 25 Nov 2020, 19:43

remko2000 wrote: 25 Nov 2020, 17:34 I read the wiki of this levelplugin but I see it's combined a setpoint with an action on a GPIO (high of low). I don't want to have an action on a GPIO, I want to have a httprequest when the setpoint is reached. I don't read there is a possibility to do something like this?
You can add an event in the rules to achieve what you want, leave the gpio set to none

Code: Select all

on level#output do
  If %eventvalue%=1
    Sendtohttp,.... // 'on' command
  else
    Sendtohttp,.... // 'off' command
  endif
endon
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 121 guests