Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/BaseWeatherChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ void BaseWeatherChannel::setValueCompare(uint goNumber, const KNXValue& value, c

void BaseWeatherChannel::fetchData()
{
CurrentWheatherData current = CurrentWheatherData();
ForecastHourWheatherData hour1 = ForecastHourWheatherData();
ForecastHourWheatherData hour2 = ForecastHourWheatherData();
CurrentWeatherData current = CurrentWeatherData();
ForecastHourWeatherData hour1 = ForecastHourWeatherData();
ForecastHourWeatherData hour2 = ForecastHourWeatherData();

int16_t httpStatus = fillWeather(current, _today, _tomorrow, hour1, hour2);
KoIW_CHHTTPStatus.value(httpStatus, DPT_Value_2_Count);
Expand Down Expand Up @@ -307,7 +307,7 @@ void BaseWeatherChannel::fetchData()
}
}

void BaseWeatherChannel::updateDayForecastKo(ForecastDayWheatherDataWithDescription& fd, int koOffset)
void BaseWeatherChannel::updateDayForecastKo(ForecastDayWeatherDataWithDescription& fd, int koOffset)
{
logIndentUp();
logDebugP("Description: %s", fd.description);
Expand Down
16 changes: 8 additions & 8 deletions src/BaseWeatherChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define IW_KoOffset_Forecast (IW_KoCHForecastDescription - IW_KoCHTodayDescription)


struct CurrentWheatherData
struct CurrentWeatherData
{
float temperature_C = 0;
float temperatureFeelsLike_C = 0;
Expand All @@ -36,7 +36,7 @@ struct CurrentWheatherData
uint8_t cloudsCover_percent = 0;
};

struct ForecastHourWheatherData
struct ForecastHourWeatherData
{
float temperature_C = 0;
float temperatureFeelsLike_C = 0;
Expand All @@ -53,7 +53,7 @@ struct ForecastHourWheatherData
};


struct ForecastDayWheatherData
struct ForecastDayWeatherData
{
float temperatureMin_C = 0;
float temperatureMax_C = 0;
Expand All @@ -79,7 +79,7 @@ struct ForecastDayWheatherData
uint8_t cloudsCover_percent = 0;
};

struct ForecastDayWheatherDataWithDescription : ForecastDayWheatherData
struct ForecastDayWeatherDataWithDescription : ForecastDayWeatherData
{
char description[15] = {0};
};
Expand All @@ -91,15 +91,15 @@ class BaseWeatherChannel : public OpenKNX::Channel
unsigned long _lastApiCall = 0;
unsigned long _updateIntervalInMs = 0;
bool _available = false;
ForecastDayWheatherDataWithDescription _today = ForecastDayWheatherDataWithDescription();
ForecastDayWheatherDataWithDescription _tomorrow = ForecastDayWheatherDataWithDescription();
ForecastDayWeatherDataWithDescription _today = ForecastDayWeatherDataWithDescription();
ForecastDayWeatherDataWithDescription _tomorrow = ForecastDayWeatherDataWithDescription();
void buildDescription(char* description, float rain, float snow, uint8_t clouds, const char* prefix);
void updateDayForecastKo(ForecastDayWheatherDataWithDescription& day, int koOffset);
void updateDayForecastKo(ForecastDayWeatherDataWithDescription& day, int koOffset);
void fetchData();

protected:
BaseWeatherChannel(uint8_t index);
virtual int16_t fillWeather(CurrentWheatherData& currentWeather, ForecastDayWheatherData& todayWeather, ForecastDayWheatherData& tomorrowWeather, ForecastHourWheatherData& hour1Weather, ForecastHourWheatherData& hour2Weather) = 0;
virtual int16_t fillWeather(CurrentWeatherData& currentWeather, ForecastDayWeatherData& todayWeather, ForecastDayWeatherData& tomorrowWeather, ForecastHourWeatherData& hour1Weather, ForecastHourWeatherData& hour2Weather) = 0;
void setValueCompare(GroupObject& groupObject, const KNXValue& value, const Dpt& type);
void setValueCompare(uint goNumber, const KNXValue& value, const Dpt& type);

Expand Down
6 changes: 3 additions & 3 deletions src/OpenMeteoChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int16_t OpenMeteoChannel::fillWeather(CurrentWheatherData& currentWeather, Forec
return httpStatus;
}

void OpenMeteoChannel::fillForecast(JsonObject& json, CurrentWheatherData& wheater)
void OpenMeteoChannel::fillForecast(JsonObject& json, CurrentWeatherData& wheater)
{
wheater.temperature_C = json["temperature_2m"];
wheater.temperatureFeelsLike_C = json["apparent_temperature"];
Expand All @@ -193,7 +193,7 @@ void OpenMeteoChannel::fillForecast(JsonObject& json, CurrentWheatherData& wheat
// * Weather Code [0..100] - see end of https://open-meteo.com/en/docs
}

void OpenMeteoChannel::fillForecast(JsonObject& json, int vi, ForecastHourWheatherData& wheater)
void OpenMeteoChannel::fillForecast(JsonObject& json, int vi, ForecastHourWeatherData& wheater)
{
// same as for current, but value-arrays instead of values
wheater.temperature_C = json["temperature_2m"][vi];
Expand Down Expand Up @@ -221,7 +221,7 @@ float OpenMeteoChannel::avg(JsonArray& arr, int begin, int n)
return sum / n;
}

void OpenMeteoChannel::fillForecast(JsonObject& json, JsonObject& jsonHourly, int vi, ForecastDayWheatherData& wheater)
void OpenMeteoChannel::fillForecast(JsonObject& json, JsonObject& jsonHourly, int vi, ForecastDayWeatherData& wheater)
{
const int vih = 24 * vi;
const int vihNight = vih + 0;
Expand Down
8 changes: 4 additions & 4 deletions src/OpenMeteoChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ class OpenMeteoChannel : public BaseWeatherChannel
{
private:
float avg(JsonArray& arr, int begin, int n);
void fillForecast(JsonObject& json, JsonObject& jsonHourly, int vi, ForecastDayWheatherData& wheater);
void fillForecast(JsonObject& json, CurrentWheatherData& wheater);
void fillForecast(JsonObject& json, int vi, ForecastHourWheatherData& wheater);
void fillForecast(JsonObject& json, JsonObject& jsonHourly, int vi, ForecastDayWeatherData& wheater);
void fillForecast(JsonObject& json, CurrentWeatherData& wheater);
void fillForecast(JsonObject& json, int vi, ForecastHourWeatherData& wheater);

protected:
int16_t fillWeather(CurrentWheatherData& currentWeather, ForecastDayWheatherData& todayWeather, ForecastDayWheatherData& tomorrowWeather, ForecastHourWheatherData& hour1Weather, ForecastHourWheatherData& hour2Weather) override;
int16_t fillWeather(CurrentWeatherData& currentWeather, ForecastDayWeatherData& todayWeather, ForecastDayWeatherData& tomorrowWeather, ForecastHourWeatherData& hour1Weather, ForecastHourWeatherData& hour2Weather) override;

public:
OpenMeteoChannel(uint8_t index);
Expand Down
10 changes: 5 additions & 5 deletions src/OpenWeatherMapChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const std::string OpenWeatherMapChannel::name()
return "OpenWeatherMap";
}

int16_t OpenWeatherMapChannel::fillWeather(CurrentWheatherData& currentWeather, ForecastDayWheatherData& todayWeather, ForecastDayWheatherData& tomorrowWeather, ForecastHourWheatherData& hour1Weather, ForecastHourWheatherData& hour2Weather)
int16_t OpenWeatherMapChannel::fillWeather(CurrentWeatherData& currentWeather, ForecastDayWeatherData& todayWeather, ForecastDayWeatherData& tomorrowWeather, ForecastHourWeatherData& hour1Weather, ForecastHourWeatherData& hour2Weather)
{
String url = OpenWeatherMapUrl;
url += "&appid=";
Expand Down Expand Up @@ -61,7 +61,7 @@ int16_t OpenWeatherMapChannel::fillWeather(CurrentWheatherData& currentWeather,
return httpStatus;
}

void OpenWeatherMapChannel::fillForecast(JsonObject& json, CurrentWheatherData& wheater)
void OpenWeatherMapChannel::fillForecast(JsonObject& json, CurrentWeatherData& wheater)
{
wheater.temperature_C = json["temp"]; // 22.34
wheater.temperatureFeelsLike_C = json["feels_like"]; // 21.95
Expand All @@ -78,13 +78,13 @@ void OpenWeatherMapChannel::fillForecast(JsonObject& json, CurrentWheatherData&
wheater.cloudsCover_percent = json["clouds"]; // 40
}

void OpenWeatherMapChannel::fillForecast(JsonObject& json, ForecastHourWheatherData& wheater)
void OpenWeatherMapChannel::fillForecast(JsonObject& json, ForecastHourWeatherData& wheater)
{
fillForecast(json, (CurrentWheatherData&) wheater);
fillForecast(json, (CurrentWeatherData&) wheater);
wheater.probabilityOfPrecipitation_percent = round(100. * (float) json["pop"]); // 0.70
}

void OpenWeatherMapChannel::fillForecast(JsonObject& json, ForecastDayWheatherData& wheater)
void OpenWeatherMapChannel::fillForecast(JsonObject& json, ForecastDayWeatherData& wheater)
{
JsonObject tempObject = json["temp"];
wheater.temperatureDay_C = tempObject["day"]; // 21.95
Expand Down
10 changes: 5 additions & 5 deletions src/OpenWeatherMapChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
class OpenWeatherMapChannel : public BaseWeatherChannel
{
private:
void fillForecast(JsonObject& json, ForecastDayWheatherData& wheater);
void fillForecast(JsonObject& json, CurrentWheatherData& wheater);
void fillForecast(JsonObject& json, ForecastHourWheatherData& wheater);
void fillForecast(JsonObject& json, ForecastDayWeatherData& wheater);
void fillForecast(JsonObject& json, CurrentWeatherData& wheater);
void fillForecast(JsonObject& json, ForecastHourWeatherData& wheater);
protected:
int16_t fillWeather(CurrentWheatherData& currentWeather, ForecastDayWheatherData& todayWeather, ForecastDayWheatherData& tomorrowWeather, ForecastHourWheatherData& hour1Weather, ForecastHourWheatherData& hour2Weather) override;
int16_t fillWeather(CurrentWeatherData& currentWeather, ForecastDayWeatherData& todayWeather, ForecastDayWeatherData& tomorrowWeather, ForecastHourWeatherData& hour1Weather, ForecastHourWeatherData& hour2Weather) override;

public:
OpenWeatherMapChannel(uint8_t index);
const std::string name() override;
Expand Down