ayant plus d’info « plus de colonne » que le script original
[2021-05-25 23:51:35][SCENARIO] Start : Scenario lance manuellement.
[2021-05-25 23:51:35][SCENARIO] Exécution du sous-élément de type [action] : code
[2021-05-25 23:51:35][SCENARIO] Exécution d’un bloc code
[2021-05-25 23:51:35][SCENARIO] Colonne ‹ Temps › ? : Température
[2021-05-25 23:51:35][SCENARIO] Valeur de j1 : 0
[2021-05-25 23:51:35][SCENARIO] Valeur de j2 : 0
[2021-05-25 23:51:35][SCENARIO] le-puy-loudes vs 23h00
[2021-05-25 23:51:35][SCENARIO] le-puy-loudes - Température : 7 °C
[2021-05-25 23:51:35][SCENARIO] => Mise à jour le-puy-loudes
[2021-05-25 23:51:35][SCENARIO] Pluie : 0 mm/1h
[2021-05-25 23:51:35][SCENARIO] Vent : 7 km/h
[2021-05-25 23:51:35][SCENARIO] rafale : 16.2
[2021-05-25 23:51:35][SCENARIO] Humidité : 77 %
[2021-05-25 23:51:35][SCENARIO] Match trouvé précipitation
[2021-05-25 23:51:35][SCENARIO] Précipitations Cumul du jour : 0 mm
[2021-05-25 23:51:35][SCENARIO] Match trouvé Degrés Jour Unifiés (DJU
[2021-05-25 23:51:35][SCENARIO]
9.6 chauffe (DJC)0 froid (DJF)
[2021-05-25 23:51:35][SCENARIO] Fin correcte du scénario
regarde en bas le cumul du jour (c’est la valeur que je récupéres)
tu crées un scenario avec un cron
j’ai crée une variable
ligne2
se met à jour ligne 113
voici mon script « adaptation de l’original »
// On récupère les tags du scénario
$Variable_Cumul_Precipitation = "CumulDuJourPrecipitation";
$tags = $scenario->getTags();
// On extrait l'éventuel tag maj
$maj = $tags['#maj#'];
// le-puy-loudes
$url = "https://www.infoclimat.fr/observations-meteo/temps-reel/le-puy-loudes/07471.html";
// $url = "https://www.infoclimat.fr/observations-meteo/temps-reel/carpentras/07586.html";
$data = file_get_contents($url);
@$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($data);
libxml_use_internal_errors(false);
$xpath = new DomXPath($dom);
$j1 = 0;$j2 = 0;
$s = 1; // 1 si colonne avec liens vers stations météo
//$node = $xpath->query("//*[@id=\"tableau-releves\"]/thead/tr/th[2]/a");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/thead/tr/th[3]/a");
$val = $node[0]->nodeValue;
$scenario->setLog("Colonne 'Temps' ? : ".$val);
if ($val === "Temps") {
$j1 = 1;//Ajout d'une colonne dans le tableau
}
$scenario->setLog("Valeur de j1 : ".$j1);
//$node = $xpath->query("//*[@id=\"tableau-releves\"]/thead/tr/th[".(3+$j)."]/a");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/thead/tr/th[".(6+$s+$j1)."]/a");
$val = $node[0]->nodeValue;
if ($val === "Bio-météo") {
$j2 = 1;//Ajout d'une colonne dans le tableau
}
$scenario->setLog("Valeur de j2 : ".$j2);
//Heure
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/span");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/th/span");
$nouvelle_heure = preg_replace ('#h$#','h00',$node[0]->nodeValue);
// $cmd=cmd::byString("#[météo][InfoClimat][Heure]#");
// $ancienne_heure = $cmd->execCmd();
$scenario->setLog("le-puy-loudes ".$ancienne_heure. " vs ".$nouvelle_heure);
//Température
$i = 1 + $s;
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/span[1]");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/td[".$i."]/span[1]");
$nouvelle_temp = $node[0]->nodeValue;
$scenario->setLog("le-puy-loudes - Température : ".$nouvelle_temp." °C");
if ( ($nouvelle_heure != $ancienne_heure || $maj) && ($nouvelle_heure != "") && ($nouvelle_temp != "") ) {
//Mise à jour heure et température
$scenario->setLog("=> Mise à jour le-puy-loudes");
// $cmd->event($nouvelle_heure);
// cmd::byString("#[Météo][Carpentras][Température]#")->event($nouvelle_temp);
//Pluie
$i = 3 + $s + $j1;
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/span/text()");
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/td[".$i."]");
// cmd::byString("#[météo][InfoClimat][Pluie]#")->event($node[0]->nodeValue);
$scenario->setLog("Pluie : ".$node[0]->nodeValue);
//Vent
$i = 4 + $s + $j1;
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/span[1]");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/td[".$i."]/span[1]");
// table#resptable-releves>tbody>tr:nth-child(1)>td:nth-child(6)>span:nth-child(1)
// cmd::byString("#[météo][InfoClimat][Vent]#")->event($node[0]->nodeValue);
$scenario->setLog("Vent : ".$node[0]->nodeValue." km/h");
//rafale
$i = 4 + $s + $j1;
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/text()");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/td[".$i."]/span[3]/span[2]");
// cmd::byString("#[météo][InfoClimat][Pression]#")->event($node[0]->nodeValue);
$scenario->setLog("rafale : ".$node[0]->nodeValue);
//Humidité
$i = 5 + $s + $j1;
//$node = $xpath->query("//*[@id=\"cdata0\"]/td[".$i."]/span");
$node = $xpath->query("//*[@id=\"resptable-releves\"]/tbody/tr[1]/td[".$i."]/span[1]");
// cmd::byString("#[météo][InfoClimat][Humidité]#")->event($node[0]->nodeValue);
$scenario->setLog("Humidité : ".$node[0]->nodeValue." %");
//Précipitations Cumul du jour
$precipitations = 0;
for ($k = 3; $k <= 12; $k++) {
$node = $xpath->query("//*[contains(@class, \"recap-clim-resp\")]/tr[".$k."]/td[1]");
$texte = $node[0]->nodeValue;
// $scenario->setLog("Libellé : $texte");
if (stripos($texte, 'Cumul du jour') !== FALSE) {
$scenario->setLog("Match trouvé précipitation");
$node = $xpath->query("//*[contains(@class, \"recap-clim-resp\")]/tr[".$k."]/td[2]/div/b");
$precipitations = $node[0]->nodeValue;
$scenario->setLog("Précipitations Cumul du jour : ".$precipitations." mm");
}
if (stripos($texte, 'Degrés Jour Unifiés (DJU)') !== FALSE) {
$scenario->setLog("Match trouvé Degrés Jour Unifiés (DJU");
$node = $xpath->query("//*[contains(@class, \"recap-clim-resp\")]/tr[".$k."]/td[2]/div");
$DJU = $node[0]->nodeValue;
$scenario->setLog($DJU);
}
}
// cmd::byString("#[résumé][InfoClimat][Précipitations 24h]#")->event($precipitations);
// cmd::byString("#[météo][InfoClimat][Degrés Jour Unifiés]#")->event($DJU);
$scenario->setData($Variable_Cumul_Precipitation, $precipitations);
}
pour les précipitations futur j’utilise le site
il y a un xml de dispo
https://www.yr.no/place/France/Île-de-France/Paris/forecast_hour_by_hour.xml
avec un script qui cumul
https://forum.jeedom.com/viewtopic.php?f=139&t=45783&p=737885&hilit=météo#p737956