Voici les modifications apportées au code du widget pour faire refonctionner ce dernier.
Je mettrais à jour le poste initiale d’ici ce soir, le temps de s’assurer que tout fonctionne bien.
Attention, je n’ai pas eu le temps de m’assurer du bon fonctionnement dans le temps (test en cours).
Il faut donc aller dans le menu Outils → Widgets et sélectionner Code.
A gauche, vous cliquer sur Dashboard et sur la fenêtre de droite vous devriez voir le widget météo cmd.info.string.Meteo.html.
Double cliquer sur ce fichier afin d’ouvrir l’éditeur, puis remplacer l’intégralité du code (copier le dans un bloc-note ou faite une copie du fichier avant la modification si vous préférez) par celui-ci :
<div class="cmd-widget" data-type="info" data-subtype="string" data-template="default" data-cmd_id="#id#" data-cmd_uid="#uid#" data-version="#version#" data-eqLogic_id="#eqLogic_id#">
<link rel="stylesheet" href="/desktop/theme/design/icons/weather-underground/wu-icons-style.css">
<link rel="stylesheet" href="/desktop/theme/design/icons/weather-icons/weather-icons.css">
<link rel="stylesheet" href="/desktop/theme/design/icons/weather-icons/weather-icons-wind.css">
<link rel="stylesheet" href="/desktop/theme/design/css/weather.css">
<div class="mia-meteo-cadre">
<!-- 1er cadre : météo actuelle -->
<div class="" id="mia-meteo-cadre-now">
<span class="" id="mia-meteo-now-icone"></span>
<span class="" id="mia-meteo-now-temperature"></span>
<span class="" id="mia-meteo-now-temps"></span>
</div>
<!-- 2nd cadre : détail météo actuelle -->
<div class="mia-meteo-cadre-detail">
<div class="mia-meteo-detail-grid">
<span class="mia-meteo-detail-texte" id="mia-meteo-lever-soleil"></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-coucher-soleil"></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-now-temperature-mini"><i class="wi wi-thermometer-exterior"></i></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-now-temperature-maxi"><i class="wi wi-thermometer"></i></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-now-vent-icone"></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-now-vent"></span>
<span class="mia-meteo-detail-texte"><i class="mia-meteo-detail-icone-pluie wi wi-raindrops"></i></span>
<span class="mia-meteo-detail-texte" id="mia-meteo-now-pluie"></span>
</div>
</div>
<!-- 3ème cadre : météo à venir -->
<div class="mia-meteo-cadre-prevision-grid">
<div>
<span class="mia-meteo-prevision-jour" id="mia-meteo-jour1-nom"></span>
<span class="" id="mia-meteo-jour1-icone"></span>
<span class="mia-meteo-prevision-temperature" id="mia-meteo-jour1-temperature"></span>
</div>
<div>
<span class="mia-meteo-prevision-jour" id="mia-meteo-jour2-nom"></span>
<span class="" id="mia-meteo-jour2-icone"></span>
<span class="mia-meteo-prevision-temperature" id="mia-meteo-jour2-temperature"></span>
</div>
<div>
<span class="mia-meteo-prevision-jour" id="mia-meteo-jour3-nom"></span>
<span class="" id="mia-meteo-jour3-icone"></span>
<span class="mia-meteo-prevision-temperature" id="mia-meteo-jour3-temperature"></span>
</div>
</div>
</div>
<script>
jeedom.cmd.addUpdateFunction('#id#',function(_options) {
// Initialisation des variables.
// Code de 1000 à 1282 = nouvelle version du plugin Weather (compatible V4.4)
var valeur = _options.display_value.split(',');
const cond_pluie = ["312", "500", "501", "531", "615", "616", "1063", "1180", "1183", "1186", "1189", "1240"];
const cond_averse = ["313", "314", "502", "503", "504", "520", "521", "522", "620", "1192", "1195", "1243", "1246", "1249"];
const cond_crachin = ["300", "301", "302", "310", "311", "321", "1150", "1153"];
const cond_neige = ["600", "601", "602", "621", "622", "1066", "1114", "1117", "1210", "1213", "1216", "1219", "1222", "1225", "1255", "1258"];
const cond_neige_fondue = ["611", "612", "613", "1204", "1237", "1252", "1261", "1264"];
const cond_pluie_vergla = ["511", "1147", "1069", "1072", "1168", "1171", "1198", "1201", "1207"];
const cond_orage = ["200", "201", "202", "210", "211", "212", "221", "230", "231", "232", "1087", "1273", "1276", "1279", "1282"];
const cond_brouillard = ["701", "721", "741", "1135", "1030", "1135"];
const cond_partiel_soleil = ["803", "1006"];
const cond_plutot_soleil = ["801", "802", "1003"];
const cond_soleil = ["800", "1000"];
const cond_nuageux = ["804", "1009"];
const jour = ['', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
const cadre_now = document.getElementById('mia-meteo-cadre-now');
const now_icone = document.getElementById('mia-meteo-now-icone');
const now_temperature = document.getElementById('mia-meteo-now-temperature');
const now_temps = document.getElementById('mia-meteo-now-temps');
const lever_soleil = document.getElementById('mia-meteo-lever-soleil');
const coucher_soleil = document.getElementById('mia-meteo-coucher-soleil');
const now_temperature_mini = document.getElementById('mia-meteo-now-temperature-mini');
const now_temperature_maxi = document.getElementById('mia-meteo-now-temperature-maxi');
const now_vent_icone = document.getElementById('mia-meteo-now-vent-icone');
const now_vent = document.getElementById('mia-meteo-now-vent');
const now_pluie = document.getElementById('mia-meteo-now-pluie');
const jour1_nom = document.getElementById('mia-meteo-jour1-nom');
const jour1_icone = document.getElementById('mia-meteo-jour1-icone');
const jour1_temperature = document.getElementById('mia-meteo-jour1-temperature');
const jour2_nom = document.getElementById('mia-meteo-jour2-nom');
const jour2_icone = document.getElementById('mia-meteo-jour2-icone');
const jour2_temperature = document.getElementById('mia-meteo-jour2-temperature');
const jour3_nom = document.getElementById('mia-meteo-jour3-nom');
const jour3_icone = document.getElementById('mia-meteo-jour3-icone');
const jour3_temperature = document.getElementById('mia-meteo-jour3-temperature');
var nuit = new Boolean(false);
var now = new Date();
var jour_numero = now.getDay();
var heure = now.getHours().toString() + now.getMinutes().toString().padStart(2, '0');
// Détermination si c'est le jour ou la nuit.
if (Number(heure) > Number(valeur[3]) && Number(heure) < Number(valeur[4])) {
nuit = false;
} else {
nuit = true;
}
// ******************** //
// Cadre météo now //
// ******************** //
// Icone et background.
if (cond_pluie.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-rain';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-rain';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_averse.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-chancerain';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-pluie';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-chancerain';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_crachin.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-flurries';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-flurries';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_neige_fondue.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-chancesleet';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-chancesleet';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_pluie_vergla.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-sleet';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-sleet';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_neige.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-snow';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-neige';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-black wu-day wu-snow';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-blue';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-blue';
} else if (cond_orage.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-chancetstorms';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-orage';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-chancetstorms';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_partiel_soleil.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-partlysunny';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-partlysunny';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_plutot_soleil.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-mostlysunny';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-soleil';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-mostlysunny';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (cond_brouillard.includes(valeur[0]) === true) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-fog';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-fog';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (valeur[0] == cond_soleil) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-sunny';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-soleil';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-sunny';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else if (valeur[0] == cond_nuageux) {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-cloudy';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-cloudy';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
} else {
if (nuit === true) {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuit';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-night wu-unknown';
} else {
cadre_now.className = 'mia-meteo-cadre-now mia-meteo-now-nuageux';
now_icone.className = 'mia-meteo-now-icone wu wu-128 wu-white wu-day wu-unknown';
}
now_temperature.className = 'mia-meteo-now-temperature mia-meteo-now-color-white';
now_temps.className = 'mia-meteo-now-temps mia-meteo-now-color-white';
}
// ******************** //
// Cadre météo détail //
// ******************** //
// Température et libellé condition.
now_temperature.innerHTML = Math.round(valeur[2]) + '°';
now_temps.innerHTML = valeur[1];
// Lever et coucher du soleil.
lever_soleil.innerHTML = '<i class="wi wi-sunrise"></i> ' + (valeur[3].length == 3 ? valeur[3].substring(0, 1) + ':' + valeur[3].substring(1) : valeur[3].substring(0, 2) + ':' + valeur[3].substring(2));
coucher_soleil.innerHTML = '<i class="wi wi-sunset"></i> ' + (valeur[4].length == 3 ? valeur[4].substring(0, 1) + ':' + valeur[4].substring(1) : valeur[4].substring(0, 2) + ':' + valeur[4].substring(2));
// Température mini et maxi.
now_temperature_mini.innerHTML = '<i class="wi wi-thermometer-exterior"></i> ' + valeur[5] + '°';
now_temperature_maxi.innerHTML = '<i class="wi wi-thermometer"></i> ' + valeur[6] + '°';
// Vent et rafale.
now_vent_icone.innerHTML = '<i class="mia-meteo-detail-icone-vent wi wi wi-wind from-' + valeur[7] + '-deg"></i>';
now_vent.innerHTML = ' <sup>' + valeur[8] + '</sup> / <sub>' + valeur[9];
// Pluie actuelle et comulée journée.
now_pluie.innerHTML = ' <sup>' + valeur[10] + '</sup> / <sub>' + valeur[11];
// ******************** //
// Cadre prévision //
// ******************** //
// Prévisions + 1.
((jour_numero + 1) > 7) ? jour1_nom.innerHTML = jour[jour_numero + 1 - 7] : jour1_nom.innerHTML = jour[jour_numero + 1];
jour1_icone.className = Prevision_Icone(valeur[12]);
jour1_temperature.innerHTML = Math.round(valeur[13]) + '°   ' + Math.round(valeur[14]) + '°';
// Prévision + 2.
((jour_numero + 2) > 7) ? jour2_nom.innerHTML = jour[jour_numero + 2 - 7] : jour2_nom.innerHTML = jour[jour_numero + 2];
jour2_icone.className = Prevision_Icone(valeur[15]);
jour2_temperature.innerHTML = Math.round(valeur[16]) + '°   ' + Math.round(valeur[17]) + '°';
// Prévision +3.
((jour_numero + 3) > 7) ? jour3_nom.innerHTML = jour[jour_numero + 3 - 7] : jour3_nom.innerHTML = jour[jour_numero + 3];
jour3_icone.className = Prevision_Icone(valeur[18]);
jour3_temperature.innerHTML = Math.round(valeur[19]) + '°   ' + Math.round(valeur[20]) + '°';
// Fonction permettant de retourner l'icône en fonction du n° de condition pour les prévisions.
function Prevision_Icone(meteo_condition) {
if (cond_pluie.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-rain';
} else if (cond_averse.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-chancerain';
} else if (cond_crachin.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-flurries';
} else if (cond_neige_fondue.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-chancesleet';
} else if (cond_pluie_vergla.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-sleet';
} else if (cond_neige.includes(meteo_condition) === true) {
return 'wu wu-64 wu-black wu-day wu-snow';
} else if (cond_orage.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-chancetstorms';
} else if (cond_partiel_soleil.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-partlysunny';
} else if (cond_plutot_soleil.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-mostlysunny';
} else if (cond_brouillard.includes(meteo_condition) === true) {
return 'wu wu-64 wu-white wu-day wu-fog';
} else if (meteo_condition == cond_soleil) {
return 'wu wu-64 wu-white wu-day wu-sunny';
} else if (meteo_condition == cond_nuageux) {
return 'wu wu-64 wu-white wu-day wu-cloudy';
} else {
return 'wu wu-64 wu-white wu-day wu-unknown';
}
}
});
jeedom.cmd.refreshValue([{cmd_id :'#id#',display_value: '#state#'}])
</script>
</div>
Avec cette version, le fichier weather.js se trouvant dans le dossier data → plan → js (d’après mon tuto, cet emplacement peut être différent suivant votre choix) n’est plus nécessaire.
N’hésitez pas à me faire part de vos retour.