1

Ajout de données météo

This commit is contained in:
2025-11-27 01:38:50 +01:00
parent bf500c183a
commit 88fd44c0fb
450 changed files with 6182 additions and 205 deletions

View File

@@ -0,0 +1,60 @@
const fs = require("fs");
const path = require("path");
const DEFAULT_WEATHER_CONFIG = {
timezone: "Europe/Paris",
defaultHour: 12,
defaultMinute: 0,
windowMinutes: 60,
precipitationThreshold: 0.1,
providers: {
influxdb: {
windowMinutes: 60,
},
openMeteo: {
timezone: null,
pressureOffset: 0,
},
},
};
function loadWeatherConfig(configPath = path.resolve(__dirname, "..", "..", "config.json")) {
let raw = {};
if (fs.existsSync(configPath)) {
try {
raw = JSON.parse(fs.readFileSync(configPath, "utf8"));
} catch (error) {
console.error(`Unable to read weather config at ${configPath}: ${error.message}`);
}
}
const weather = raw.weather || {};
const providers = {
...DEFAULT_WEATHER_CONFIG.providers,
...(weather.providers || {}),
};
providers.influxdb = {
...DEFAULT_WEATHER_CONFIG.providers.influxdb,
...(weather.providers?.influxdb || {}),
};
providers.openMeteo = {
...DEFAULT_WEATHER_CONFIG.providers.openMeteo,
timezone: weather.providers?.openMeteo?.timezone || weather.timezone || DEFAULT_WEATHER_CONFIG.timezone,
...(weather.providers?.openMeteo || {}),
};
return {
...DEFAULT_WEATHER_CONFIG,
...weather,
providers,
};
}
module.exports = {
DEFAULT_WEATHER_CONFIG,
loadWeatherConfig,
};