Actualités du plugin Météo France

Bonjour,

Afin de faciliter l’extraction de valeur dans les commandes Json jour, heure et moment du plugin, voici un bloc code de scénario avec la structure du json et le code pour extraire les valeurs:

/* JSON structure for a MeteoDayxJson command:
{ "dt":1687737600,
  "T":{"min":16.4,"max":27.4,"sea":null},
  "humidity":{"min":40,"max":70},
  "precipitation":{"24h":0},
  "uv":10,
  "weather12H":{"icon":"p2j","desc":"Eclaircies"},
  "sun":{"rise":1687750412,"set":1687808523},
  "dt12H":1687773600
}
*/
$cmdJSON = '#[Météo][Meteo France Jpty][Météo jour 0 - Json]#';
$temps = meteofrance::getJsonInfo($cmdJSON,'weather12H > desc');
$date = meteofrance::getJsonInfo($cmdJSON,'dt');
$pluie24h = meteofrance::getJsonInfo($cmdJSON,'precipitation > 24h');
$scenario->setLog('Jour Date: ' .date('d-m-Y H:i',$date) .' Pluie 24h: ' .$pluie24h .' Temps: ' .$temps);

/* JSON structure for a MeteoHourxJson command:
      { "dt":1685984400,
        "T":{"value":25.2,"windchill":24.1},
        "humidity":25,
        "sea_level":1015,
        "wind":{"speed":3,"gust":0,"direction":65,"icon":"ENE"},
        "rain":{"1h":0},
        "snow":{"1h":0},
        "iso0":2900,
        "rain snow limit":"Non pertinent",
        "clouds":10,
        "weather":{"icon":"p1j","desc":"Ensoleillé"}
      }
   */
$cmdJSON = '#[Météo][Meteo France Jpty][Météo heure - Json]#';
$temps = meteofrance::getJsonInfo($cmdJSON,'weather > desc');
$date = meteofrance::getJsonInfo($cmdJSON,'dt');
$pluie1h = meteofrance::getJsonInfo($cmdJSON,'rain > 1h');
$scenario->setLog('Heure Date: ' .date('d-m-Y H:i',$date) .' Pluie 1h: ' .$pluie1h .' Temps: ' .$temps);

/* JSON structure for a MeteoInstantxJson command:
      { "dt":1685991600,
        "T":{"value":22.7,"windchill":21.3},
        "humidity":30,
        "sea_level":1015.3,
        "wind":{"speed":4,"gust":0,"direction":55,"icon":"NE"},
        "rain":{"1h":0},
        "snow":{"1h":0},
        "iso0":3350,
        "rain snow limit":"Non pertinent",
        "clouds":10,
        "moment_day":"Soirée",
        "weather":{"icon":"p1j","desc":"Ensoleillé"}
      }
   */
$cmdJSON = '#[Météo][Meteo France Jpty][Moment de la journée - Json]#';
$temps = meteofrance::getJsonInfo($cmdJSON,'weather > desc');
$date = meteofrance::getJsonInfo($cmdJSON,'dt');
$humidity = meteofrance::getJsonInfo($cmdJSON,'humidity');
$pluie1h = meteofrance::getJsonInfo($cmdJSON,'rain > 1h');
$scenario->setLog('Moment Date: ' .date('d-m-Y H:i',$date) .' Pluie 1h: ' .$pluie1h .' Temps: ' .$temps  .' Humidité: ' .$humidity);

1 « J'aime »