Adding Weather driver for WeatherFlow#2258
Merged
Merged
Conversation
knro
reviewed
Jul 17, 2025
knro
reviewed
Jul 17, 2025
… for improved clarity and consistency
knro
reviewed
Jul 22, 2025
Comment on lines
+131
to
+134
| char api_key[256] = {0}; | ||
| IUGetConfigText(getDeviceName(), "WF_API_KEY", "API_KEY", api_key, 256); | ||
| wfAPIKeyTP[0].fill("API_KEY", "API Key", api_key); | ||
| wfAPIKeyTP.fill(getDeviceName(), "WF_API_KEY", "WeatherFlow", OPTIONS_TAB, IP_RW, 60, IPS_IDLE); |
Contributor
There was a problem hiding this comment.
You can remove the first two line and simply add after the wfAPIKeyTP.fill, this line:
wfAPIKeyTP.load();
This should load the config automatically.
knro
reviewed
Jul 22, 2025
Comment on lines
+137
to
+140
| char station_id[256] = {0}; | ||
| IUGetConfigText(getDeviceName(), "WF_STATION_ID", "STATION_ID", station_id, 256); | ||
| wfStationIDTP[0].fill("STATION_ID", "Station ID", station_id); | ||
| wfStationIDTP.fill(getDeviceName(), "WF_STATION_ID", "WeatherFlow", OPTIONS_TAB, IP_RW, 60, IPS_IDLE); |
knro
reviewed
Jul 22, 2025
Comment on lines
+428
to
+443
| CURL *curl = curl_easy_init(); | ||
| if (!curl) | ||
| { | ||
| LOG_ERROR("Failed to initialize CURL."); | ||
| return false; | ||
| } | ||
|
|
||
| std::string url = API_BASE_URL + endpoint; | ||
| char errorBuffer[CURL_ERROR_SIZE] = {0}; | ||
|
|
||
| curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); | ||
| curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); | ||
| curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); | ||
| curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer); | ||
| curl_easy_setopt(curl, CURLOPT_TIMEOUT, static_cast<long>(wfSettingsNP[WF_CONNECTION_TIMEOUT].getValue())); | ||
| curl_easy_setopt(curl, CURLOPT_USERAGENT, "INDI-WeatherFlow/1.0"); |
Contributor
There was a problem hiding this comment.
Is there any reason for using CURL? In INDI, we typically used httplib::Client to handle API requests. You can checkout DragonLight driver for an example implementation. It's much cleaner than using CURL directly.
Contributor
Author
There was a problem hiding this comment.
I didn't look at the codebase enough so I did what I knew, my mistake.
Contributor
|
@beettlle I tried to fix a couple of errors on my own, but there are more now. Please try to fix the rest. |
Contributor
Author
|
Sorted my setup and it's not compiling without any errors: Also found a small omission in the Docker README |
knro
added a commit
to knro/indi
that referenced
this pull request
Aug 25, 2025
* Adding Weather driver for WeatherFlow * Fixing per @knro comments * Refactor authorization header construction in WeatherFlow API request for improved clarity and consistency * Removed CURL and fixed some functions * Update weatherflow.cpp * Update weatherflow.h * Update Docker README for clarity and fix authorization header construction in WeatherFlow API request --------- Co-authored-by: Jasem Mutlaq <mutlaqja@ikarustech.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WeatherFlow makes some great weather devices. This adds WeatherFlow as a weather driver.