Generic HTTP Documentation
Moderators: grovkillen, Stuntteam, TD-er
Generic HTTP Documentation
I'm trying to learn more about how to format and use the Generic HTTP controller. I've searched both the old and new wiki sites but can't seem to get info on how to correctly format the URL. For testing I'm just using a RequestBin site to see the data being pushed out from this controller. I'm having a device trigger the controller every 5 seconds but I'm not even using any of that data. If you look at the attached image, I'm just trying to pass a hard coded value to the requestbin for testing. I also don't understand what the idx number is for when I tell a device to send info to this controller. There is the option to send all data to the controller rather then multiple calls. Since I want to pass all the data at once I think this is what I should have checked off.
- Attachments
-
- Screen Shot 2021-03-12 at 11.51.18 AM.png (62.01 KiB) Viewed 5887 times
-
- Screen Shot 2021-03-12 at 11.48.26 AM.png (76.18 KiB) Viewed 5887 times
Re: Generic HTTP Documentation
You have "https://" in the hostname.
That should not be there, just the hostname.
As a matter of fact, you cannot use https, so also make sure your site is reachable via http instead of https.
That should not be there, just the hostname.
As a matter of fact, you cannot use https, so also make sure your site is reachable via http instead of https.
Re: Generic HTTP Documentation
Thank you very much! I'll go do more testing.
Re: Generic HTTP Documentation
That 100% helped but I still don't understand the "Single event with all values" option under a device. I read that if a device has more than one task (like temp and humidity) that the device will pub to the controller twice. I thought that the "Single event with all values" option would send both reading to the controller so that I could send everything out together. I think I'm miss understanding this feature.
Re: Generic HTTP Documentation
OK, got it
?%val1%&%val2%
?%val1%&%val2%
Re: Generic HTTP Documentation
The "single event" is about the events handled in the rules.garnold wrote: ↑12 Mar 2021, 20:13 That 100% helped but I still don't understand the "Single event with all values" option under a device. I read that if a device has more than one task (like temp and humidity) that the device will pub to the controller twice. I thought that the "Single event with all values" option would send both reading to the controller so that I could send everything out together. I think I'm miss understanding this feature.
When it is unchecked (default behavior), ESPEasy will generate an event per task value.
For example for the task named "bme280" with task variables "T", "H" and "P" you will see 3 events being generated when there are new readings:
- bme280#T=21.3
- bme280#H=71.0
- bme280#P=1003.1
With the "single event" checked, you will get 1 event:
- bme280#all=21.3,71.0,1003.1
These event values can be referred to in the rules via %eventvalue1%, ... , %eventvalue3% (max. of 4, but the BME280 only outputs 3 values)
Re: Generic HTTP Documentation
Getting so much closer!
This is what I'm using to send the data out and it works perfect
sensorData?t=%val1%&h=%val2%&sId=sensor_001
But it is still making 2 calls to the controller, one for each measurement. I'm missing the meaning of that check box on the device about sending everything in one call. Does that mean it's going to send everything in one call but make a call for each measurement?
This is what I'm using to send the data out and it works perfect
sensorData?t=%val1%&h=%val2%&sId=sensor_001
But it is still making 2 calls to the controller, one for each measurement. I'm missing the meaning of that check box on the device about sending everything in one call. Does that mean it's going to send everything in one call but make a call for each measurement?
Re: Generic HTTP Documentation
That checkbox is for sending events to the rules.
It has nothing to do with the connected controllers.
But if you would like to use a more advanced approach, you could generate a HTTP call via the rules using the SendToHttp command and the %eventvalue1% reference I mentioned.
It has nothing to do with the connected controllers.
But if you would like to use a more advanced approach, you could generate a HTTP call via the rules using the SendToHttp command and the %eventvalue1% reference I mentioned.
Re: Generic HTTP Documentation
Understood. So the controller will always get called for each measurement, regardless of that checkbox. I'll have to move over to rules then. Thank you
Re: Generic HTTP Documentation
I have it working now thanks to the help I have received here! I still do have a question. I ended up doing this on a timer so that the data was posted every 5 seconds. Because of this I did not use the eventvalue option. I completely understand why I did what I had to do in this rule below. What I do not understand is, what would trigger my device to call my rule? So if I created a rule that fired off the change in my DTH22, what would have to change? The temp or humidity or does it fire when either change?
Here is my rule that works great.
On System#Boot do //When the ESP boots, do
timerSet,1,5 //Set Timer 1 for the next event in 5 seconds
endon
On Rules#Timer=1 do //When Timer1 expires, do
SendToHTTP enm6ldg2gcm5.x.pipedream.net,80,?t=[DHT22#Temperature]&h=[DHT22#Humidity]&sId=sensor_001
timerSet,1,5 //Resets the Timer 1 for another 5 seconds
endon
Here is my rule that works great.
On System#Boot do //When the ESP boots, do
timerSet,1,5 //Set Timer 1 for the next event in 5 seconds
endon
On Rules#Timer=1 do //When Timer1 expires, do
SendToHTTP enm6ldg2gcm5.x.pipedream.net,80,?t=[DHT22#Temperature]&h=[DHT22#Humidity]&sId=sensor_001
timerSet,1,5 //Resets the Timer 1 for another 5 seconds
endon
Re: Generic HTTP Documentation
You named your task and your variables of that task right?
A task with name "taskname" and a task variable called "taskvar" will generate an event "taskname#taskvar=..." with some value of that task variable.
For example task named "bme" and variable "temperature" may generate an event "bme#temperature=20.1"
That's what you may use in your rules:
A task with name "taskname" and a task variable called "taskvar" will generate an event "taskname#taskvar=..." with some value of that task variable.
For example task named "bme" and variable "temperature" may generate an event "bme#temperature=20.1"
That's what you may use in your rules:
Code: Select all
on bme#temperature do
....
endon
Who is online
Users browsing this forum: No registered users and 39 guests