Bonjour,
J’ai réussi à créer un fichier php pour récupérer les infos de mon thermostat Netatmo. le fichier est héberger sur mon NAS et me renvoie bien les infos.
Malheureusement je n’arrive pas à les afficher sur l’IPX800.
Pouvez vous m’aider ?
Cordialement
Yann
Le code
<?php
$password= ";;;;;;;;;;";
$username= ";;;;;;;;;;;;;;;";
$app_id = ";;;;;;;;;;;;;;;;;;;;;";
$app_secret = ";;;;;;;;;;;;;;;;;;;;;";
$token_url = "https://api.netatmo.net/oauth2/token";
$postdata = http_build_query(
array(
'grant_type' => "password",
'client_id' => $app_id,
'client_secret' => $app_secret,
'username' => $username,
'password' => $password,
'scope' => 'read_station read_thermostat write_thermostat'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$response = file_get_contents($token_url, false, $context);
$params = null;
$params = json_decode($response, true);
$api_url = "https://api.netatmo.net/api/getuser?access_token=" . $params['access_token']."&app_type=app_thermostat";
$requete = @file_get_contents($api_url);
$url_devices = "https://api.netatmo.net/api/devicelist?access_token=" . $params['access_token']."&app_type=app_thermostat";
$resulat_device = @file_get_contents($url_devices);
$json_devices = json_decode($resulat_device,true);
$device1 = $json_devices["body"]["devices"][0]["_id"];
$module1 = $json_devices["body"]["modules"][0]["_id"];
$url_thermostat1="http://api.netatmo.net/api/getthermstate?access_token=" . $params['access_token']."&device_id=".$device1."&module_id=".$module1;
$value_thermostat1= file_get_contents($url_thermostat1);
$json_mesures_thermostat1 = json_decode($value_thermostat1, true);
$temperature_thermostat1 = $json_mesures_thermostat1["body"]["measured"]["temperature"];
$run_thermostat1 = $json_mesures_thermostat1["body"]["therm_relay_cmd"];
$setpoint_thermostat1=$json_mesures_thermostat1["body"]["measured"]["setpoint_temp"];
echo '<?xml version="1.0" encoding="utf8" ?>';
echo "<netatmo>";
echo "Temperature " . $temperature_thermostat1 . "<br />\n" ;
echo "Chaudière " . $run_thermostat1 . "<br />\n" ; // Etat du thermostat, 0 chaudiere a l'arret, 100 chaudiere en marche
echo "Consigne " . $setpoint_thermostat1 . "<br />\n"; // Consigne thermostat
echo "</netatmo>";
?>