Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sendtohttp] thingspeak only reply event #4856

Merged
merged 31 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4060dad
Update Networking.cpp
chromoxdor Oct 23, 2023
bb5ac3e
Update Networking.cpp
chromoxdor Oct 25, 2023
425aec4
Update Networking.cpp
chromoxdor Oct 25, 2023
db1d7d9
make thinkspeak event optional
chromoxdor Oct 25, 2023
6b5e249
compare also the last part of the uri to generate an event
chromoxdor Oct 25, 2023
fb0f8ed
add check if we got an answer otherwise we get -1 as a value
chromoxdor Oct 25, 2023
197dc10
Update Networking.cpp
chromoxdor Oct 25, 2023
4c934d4
Update Networking.cpp
chromoxdor Oct 25, 2023
4ad08ac
Update define_plugin_sets.h
chromoxdor Oct 25, 2023
ad5e2ea
Update define_plugin_sets.h
chromoxdor Oct 25, 2023
1ef66a4
Update Networking.cpp
chromoxdor Oct 25, 2023
5a689b2
Add ThingspeakReply to wordlist
chromoxdor Oct 25, 2023
89bf66c
Update Networking.cpp
chromoxdor Oct 25, 2023
600367b
Update Networking.cpp
chromoxdor Oct 25, 2023
99b8156
added documentation
chromoxdor Oct 26, 2023
7d37637
Update Rules.rst
chromoxdor Oct 26, 2023
c9ef151
single + multifield reply combined
chromoxdor Oct 26, 2023
c6b96c5
Update Rules.rst
chromoxdor Oct 26, 2023
065efcd
Update Rules.rst
chromoxdor Oct 26, 2023
8c2f5a2
Merge branch 'mega' into reply_event
chromoxdor Oct 29, 2023
ae3cbb9
a little formatting
chromoxdor Oct 29, 2023
61a8a28
Merge branch 'mega' into reply_event
chromoxdor Nov 15, 2023
9756b8a
Merge branch 'reply_event' of https://github.com/chromoxdor/ESPEasy i…
chromoxdor Nov 30, 2023
967f940
Update espeasy.min.js
chromoxdor Nov 30, 2023
7f2a4ed
Update Rules.rst
chromoxdor Nov 30, 2023
33006a7
Merge branch 'letscontrolit:mega' into reply_event
chromoxdor Dec 27, 2023
7c85873
Merge branch 'mega' into reply_event
chromoxdor Jan 14, 2024
bcae422
Merge branch 'mega' into reply_event
chromoxdor Jan 18, 2024
8967740
Merge branch 'mega' into reply_event
chromoxdor Jan 21, 2024
1667923
Merge branch 'letscontrolit:mega' into reply_event
chromoxdor Jan 24, 2024
c215acf
Merge branch 'mega' into reply_event
chromoxdor Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Custom-sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define FEATURE_RULES_EASY_COLOR_CODE 1 // Use code highlighting, autocompletion and command suggestions in Rules
#define FEATURE_ESPEASY_P2P 1 // (1/0) enables the ESP Easy P2P protocol
#define FEATURE_ARDUINO_OTA 1 //enables the Arduino OTA capabilities
#define FEATURE_THINGSPEAK_EVENT 1 // generate an event when requesting last value of a field in thingspeak via SendToHTTP(e.g. sendToHTTP,api.thingspeak.com,80,/channels/1667332/fields/5/last)
// #define FEATURE_SD 1 // Enable SD card support
// #define FEATURE_DOWNLOAD 1 // Enable downloading a file from an url

Expand Down
24 changes: 24 additions & 0 deletions src/src/Helpers/Networking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,31 @@ int http_authenticate(const String& logIdentifier,
event += '=';
event += httpCode;
eventQueue.addMove(std::move(event));
#if FEATURE_THINGSPEAK_EVENT
chromoxdor marked this conversation as resolved.
Show resolved Hide resolved
// Generate event with the response of a
// "last-value-of-field" tingspeak request (https://de.mathworks.com/help/thingspeak/readlastfieldentry.html)
chromoxdor marked this conversation as resolved.
Show resolved Hide resolved
// e.g. (sendToHTTP,api.thingspeak.com,80,/channels/143789/fields/5/last)
// where first eventvalue is the channel number, the second the field number
// and the third is the value received by the request
// Example of received reply: "HTTP : SendToHTTP api.thingspeak.com GETHTTP code: 200 Received reply: 24.2"
// Example of the event: "EVENT: reply#thingspeak=1637928,5,24.2"
// ^ ^ ^
// channel number ┘ | └ received value
// field number
// In rules you can grep the reply by "On ThingspeakReply# Do ..."
if (httpCode == 200 && equals(host, F("api.thingspeak.com")) && uri.endsWith(F("/last"))) {
String revent = F("ThingspeakReply#");
chromoxdor marked this conversation as resolved.
Show resolved Hide resolved
revent += '=';
revent += parseString(uri.c_str(), 2, '/');; //get the channel number
chromoxdor marked this conversation as resolved.
Show resolved Hide resolved
revent += ',';
revent += parseString(uri.c_str(), 4, '/');; //get the field number
revent += ',';
revent += http.getString().substring(0, 21);
eventQueue.addMove(std::move(revent));
}
#endif
}

#ifndef BUILD_NO_DEBUG
log_http_result(http, logIdentifier, host + ':' + port, HttpMethod, httpCode, EMPTY_STRING);
#endif
Expand Down
Loading