il vous faut PHP5, sur Raspberry :
Code : Tout sélectionner
sudo apt-get update
sudo apt-get install php5Un capteur Température, Hydrométrie, Pression atmosphérique, IDX = 99 dans l'exemple ci-dessous
Un capteur Vent, IDX = 100 dans l'exemple ci-dessous
Il vous faut ensuite le code WOEID de votre lieu d'habitation, pour le trouver : http://woeid.rosselliot.co.nz/
Par exemple : 615702 pour Paris
créer un fichier meteo.php en modifiant les variables :
$WOEID, $IPPORT et les $IDX
Code : Tout sélectionner
<?php
// Code WOEID à récupérer sur woeid.rosselliot.co.nz
$WOEID="615702";
// Adresse et port de Domoticz
$IPPORT="192.168.1.2:8080";
// Index Domoticz du capteur de température Humidité et Pression atmosphérique
$IDX_THP=99;
// Index Domoticz du capteur de Vent
$IDX_VENT=100;
$result = file_get_contents("http://xml.weather.yahoo.com/forecastrss?w=$WOEID&u=c");
$xml = simplexml_load_string($result);
$xml->registerXPathNamespace('yweather', 'http://xml.weather.yahoo.com/ns/rss/1.0');
$location = $xml->channel->xpath('yweather:location');
$wind = $xml->channel->xpath('yweather:wind');
$atmosphere = $xml->channel->xpath('yweather:atmosphere');
$astronomy = $xml->channel->xpath('yweather:astronomy');
$units = $xml->channel->xpath('yweather:units');
$condition = $xml->channel->item->xpath('yweather:condition');
$location = $location[0];
$wind = $wind[0];
$atmosphere = $atmosphere[0];
$astronomy = $astronomy[0];
$units = $units[0];
$condition = $condition[0];
// Capteur de Température Humidité et Pression atmosphérique dans Domoticz
$rTemp=$condition['temp'];
$rPres=$atmosphere['pressure'];
$rHumi=$atmosphere['humidity'];
$majdomoticz="http://$IPPORT/json.htm?type=command¶m=udevice&idx=$IDX_THP&nvalue=0&svalue=$rTemp;$rHumi;0;$rPres;0";
echo file_get_contents($majdomoticz);
// Capteur de vent
$rVent=$wind['speed'];
$rDirec=$wind['direction'];
$rTempRessentie=$wind['chill']; ; // Temperature Windchill
$majdomoticz="http://$IPPORT/json.htm?type=command¶m=udevice&idx=$IDX_VENT&nvalue=0&svalue=$rDirec;N;$rVent;0;$rTemp;$rTempRessentie";
echo file_get_contents($majdomoticz);
?>
Code : Tout sélectionner
php5 -n meteo.php