Skip to content
Merged
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
6 changes: 3 additions & 3 deletions defaultmodules/weather/current.njk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
<div class="wi dimmed wi-hot"></div>
{{ current.uv_index }}
{{ current.uvIndex }}
</td>
{% endif %}
</div>
Expand Down Expand Up @@ -78,11 +78,11 @@
</span>
<br />
{% endif %}
{% if config.showPrecipitationAmount and current.precipitationAmount %}
{% if config.showPrecipitationAmount and current.precipitationAmount is defined and current.precipitationAmount is not none %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_AMOUNT" | translate }}</span> {{ current.precipitationAmount | unit("precip", current.precipitationUnits) }} </span>
<br />
{% endif %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
{% if config.showPrecipitationProbability and current.precipitationProbability is defined and current.precipitationProbability is not none %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_POP" | translate }}</span> {{ current.precipitationProbability }}% </span>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/forecast.njk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{% endif %}
{% if config.showUVIndex %}
<td class="align-right dimmed uv-index">
{{ f.uv_index }}
{{ f.uvIndex }}
<span class="wi dimmed weathericon wi-hot"></span>
</td>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions defaultmodules/weather/hourly.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<td class="align-right bright">{{ hour.temperature | roundValue | unit("temperature") }}</td>
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
{% if hour.uv_index!=0 %}
{{ hour.uv_index }}
{% if hour.uvIndex!=0 %}
{{ hour.uvIndex }}
<span class="wi weathericon wi-hot"></span>
{% endif %}
</td>
Expand Down
4 changes: 2 additions & 2 deletions defaultmodules/weather/providers/weatherapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class WeatherAPIProvider {
weather.precipitationProbability = precipitationProbability;
}

weather.uv_index = this.#toNumber(forecastDay.day?.uv);
weather.uvIndex = this.#toNumber(forecastDay.day?.uv);

days.push(weather);

Expand Down Expand Up @@ -410,7 +410,7 @@ class WeatherAPIProvider {
const willSnow = this.#toNumber(hourData.will_it_snow) ?? 0;
weather.precipitationProbability = (willRain + willSnow) * 50;

weather.uv_index = this.#toNumber(hourData.uv);
weather.uvIndex = this.#toNumber(hourData.uv);

hours.push(weather);

Expand Down
33 changes: 18 additions & 15 deletions defaultmodules/weather/providers/weatherflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ class WeatherFlowProvider {

const weather = {
date: new Date(),
humidity: current.relative_humidity || null,
temperature: current.air_temperature || null,
feelsLikeTemp: current.feels_like || null,
humidity: current.relative_humidity ?? null,
temperature: current.air_temperature ?? null,
feelsLikeTemp: current.feels_like ?? null,
windSpeed: current.wind_avg != null ? convertKmhToMs(current.wind_avg) : null,
windFromDirection: current.wind_direction || null,
windFromDirection: current.wind_direction ?? null,
weatherType: this.#convertWeatherType(current.icon),
precipitationAmount: current.precip_accum_local_day ?? null,
precipitationUnits: "mm",
precipitationProbability: current.precip_probability ?? null,
uvIndex: current.uv || null,
sunrise: daily.sunrise ? new Date(daily.sunrise * 1000) : null,
sunset: daily.sunset ? new Date(daily.sunset * 1000) : null
Expand All @@ -175,9 +178,9 @@ class WeatherFlowProvider {
for (const forecast of data.forecast.daily) {
const weather = {
date: new Date(forecast.day_start_local * 1000),
minTemperature: forecast.air_temp_low || null,
maxTemperature: forecast.air_temp_high || null,
precipitationProbability: forecast.precip_probability || null,
minTemperature: forecast.air_temp_low ?? null,
maxTemperature: forecast.air_temp_high ?? null,
precipitationProbability: forecast.precip_probability ?? null,
weatherType: this.#convertWeatherType(forecast.icon),
precipitationAmount: 0.0,
precipitationUnits: "mm",
Expand All @@ -193,8 +196,8 @@ class WeatherFlowProvider {
if (hourDate.getFullYear() === forecastDate.getFullYear()
&& hourDate.getMonth() === forecastDate.getMonth()
&& hourDate.getDate() === forecastDate.getDate()) {
weather.uvIndex = Math.max(weather.uvIndex, hour.uv || 0);
weather.precipitationAmount += hour.precip || 0;
weather.uvIndex = Math.max(weather.uvIndex, hour.uv ?? 0);
weather.precipitationAmount += hour.precip ?? 0;
} else if (hourDate > forecastDate) {
// Check if we've moved to the next day
const diffMs = hourDate - forecastDate;
Expand Down Expand Up @@ -224,14 +227,14 @@ class WeatherFlowProvider {
for (const hour of data.forecast.hourly) {
const weather = {
date: new Date(hour.time * 1000),
temperature: hour.air_temperature || null,
feelsLikeTemp: hour.feels_like || null,
humidity: hour.relative_humidity || null,
temperature: hour.air_temperature ?? null,
feelsLikeTemp: hour.feels_like ?? null,
humidity: hour.relative_humidity ?? null,
windSpeed: hour.wind_avg != null ? convertKmhToMs(hour.wind_avg) : null,
windFromDirection: hour.wind_direction || null,
windFromDirection: hour.wind_direction ?? null,
weatherType: this.#convertWeatherType(hour.icon),
precipitationProbability: hour.precip_probability || null,
precipitationAmount: hour.precip || 0,
precipitationProbability: hour.precip_probability ?? null,
precipitationAmount: hour.precip ?? 0,
precipitationUnits: "mm",
uvIndex: hour.uv || null
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ describe("WeatherAPIProvider", () => {
expect(result[0].minTemperature).toBe(-8);
expect(result[0].maxTemperature).toBe(-1);
expect(result[0].weatherType).toBe("day-sprinkle");
expect(result[0].uvIndex).toBe(1);
expect(result[0].sunrise).toBeInstanceOf(Date);
expect(result[0].sunset).toBeInstanceOf(Date);
});
Expand Down Expand Up @@ -275,6 +276,7 @@ describe("WeatherAPIProvider", () => {
expect(result[0].humidity).toBe(85);
expect(result[0].windFromDirection).toBe(210);
expect(result[0].weatherType).toBe("night-sprinkle");
expect(result[0].uvIndex).toBe(0);
expect(result[0].precipitationProbability).toBe(50);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ describe("WeatherFlowProvider", () => {
expect(result).toBeDefined();
expect(result.temperature).toBe(16);
expect(result.humidity).toBe(28);
expect(result.precipitationAmount).toBe(0);
expect(result.precipitationUnits).toBe("mm");
expect(result.precipitationProbability).toBe(0);
expect(result.weatherType).not.toBeNull();
});

Expand Down
Loading