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
13 changes: 5 additions & 8 deletions defaultmodules/weather/providers/openmeteo.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class OpenMeteoProvider {
pastDays: 0,
type: "current",
maxNumberOfDays: 5,
maxEntries: 5,
updateInterval: 10 * 60 * 1000,
...config
};
Expand Down Expand Up @@ -241,16 +240,14 @@ class OpenMeteoProvider {
}

#getQueryParameters () {
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
let maxEntries = this.config.maxEntries;
let maxNumberOfDays = this.config.maxNumberOfDays;

if (this.config.maxNumberOfDays !== undefined && !isNaN(parseFloat(this.config.maxNumberOfDays))) {
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
const daysFactor = ["daily", "forecast"].includes(this.config.type) ? 1 : this.config.type === "hourly" ? 24 : 0;
maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
const maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
maxNumberOfDays = Math.ceil(maxEntries / Math.max(1, daysFactor));
}
maxEntries = Math.max(1, Math.min(maxEntries, maxEntriesLimit));

const params = {
latitude: this.config.lat,
Expand Down Expand Up @@ -429,7 +426,7 @@ class OpenMeteoProvider {

// Add hourly data if available
if (parsedData.hourly) {
let h = 0;
let h;
const currentTime = parsedData.current_weather.time;

// Handle both data shapes: object with arrays or array of objects (after transpose)
Expand Down Expand Up @@ -522,8 +519,8 @@ class OpenMeteoProvider {
const now = new Date();

parsedData.hourly.forEach((weather, i) => {
// Skip past entries, collect only future hours up to maxEntries
if (weather.time <= now || hours.length >= this.config.maxEntries) {
// Skip past entries
if (weather.time <= now) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/providers/openweathermap.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class OpenWeatherMapProvider {
}

#generateWeatherObjectsFromOnecall (data) {
let precip = false;
let precip;

// Get current weather
const current = {};
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/providers/pirateweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PirateweatherProvider {
return;
}

let weatherData = null;
let weatherData;

switch (this.config.type) {
case "current":
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/providers/ukmetofficedatahub.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class UkMetOfficeDataHubProvider {
return;
}

let weatherData = null;
let weatherData;

switch (this.config.type) {
case "current":
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/weatherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const WeatherUtils = {
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;

let convertedValue = value;
let conversionUnit = valueUnit;
let conversionUnit;
if (outputUnit === "imperial") {
convertedValue = this.convertPrecipitationToInch(value, valueUnit);
conversionUnit = "in";
Expand Down
2 changes: 1 addition & 1 deletion js/http_fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class HTTPFetcher extends EventEmitter {
#getDelayForResponse (response) {
const { status } = response;
let delay = this.reloadInterval;
let message = "";
let message;
let errorType = "UNKNOWN_ERROR";

if (status === 401 || status === 403) {
Expand Down
2 changes: 1 addition & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Loader, defaults, Translator, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */
/* global Loader, defaults, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */

const MM = (function () {
let modules = [];
Expand Down
2 changes: 1 addition & 1 deletion js/module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Class, cloneObject, Loader, MMSocket, nunjucks, Translator */
/* global Class, cloneObject, Loader, MMSocket, nunjucks */

/*
* Module Blueprint.
Expand Down
Loading