Bonsoir,
Voici « une procédure » qui fonctionne pour moi, et qui bien entendu est à optimiser.
Je rajoute à la suite de ce post des éléments supplémentaires (dans un nouveau post)
Je met pour exemple des scripts PHP avec CURL.
1 - Récupération du TOKEN (Bearer Token) à partir de vos identifiants Aldes Connect :
URL: https://aldesiotsuite-aldeswebapi.azurewebsites.net/oauth2/token/
Méthode : POST
Réponse : token (Bearer Token)
Précisions :
- Je ne connais pas la durée de validité, je renouvelle tous les 24h
- Votre token est à conserver pour la suite et à passer en paramètre dans tous les appels API
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/oauth2/token/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'grant_type=password&username=VOTREEMAIL&password=VOTREMOTDEPASSE',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
2 - Récupération du USERID et du DEVICEID à partir du TOKEN
URL : https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/notification/preferences
Méthode : GET
Réponse :
{
> "userId": "XXXXX",
> "userProductPreferences": [
> {
> "deviceId": "YYYYYYYY",
> "receiveFilterAlert": false,
> "receiveDysfunctionAlert": false,
> "receiveFilterAlertSurvey": false
> }
> ],
> "needUpdate": {
> "message": "Your app is outdated please update it using the app store and try again",
> "storeAndroid": "https://play.google.com/store",
> "storeApple": "http://appstore.com/aldes"
> }
> }
Précision :
- Idem que pour le token, il faut récupérer USERSID et DEVICEID pour la suite
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/notification/preferences',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer VOTRETOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
3 - Obtenir toutes les infos des produits sur votre compte ALDES CONNECT
URL : https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products
Méthode : GET
Réponse :
[
> {
> "slaves": [],
> "masters": [],
> "indicators": [
> {
> "date": "2021-08-11T19:11:07.741Z",
> "type": "WATER_QUANTITY",
> "value": 75
> },
> {
> "date": "2021-08-11T19:11:07.741Z",
> "type": "TEMPERATURE",
> "value": 24.12
> },
> {
> "date": "2021-08-12T18:31:31.068Z",
> "type": "CLOUD_CONTROLLED",
> "value": null
> },
> {
> "date": "2021-08-12T18:31:31.253Z",
> "type": "SELF_CONTROLLED",
> "value": false
> }
> ],
> "indicator": {
> "fmist": 22.0,
> "fmast": 31.0,
> "cmast": 24.0,
> "cmist": 16.0,
> "date_debut_vac": null,
> "date_fin_vac": null,
> "hors_gel": false,
> "qte_eau_chaude": 75,
> "tmp_principal": 24.12,
> "current_air_mode": "F",
> "current_water_mode": "M",
> "thermostats": [
> {
> "ThermostatId": 622,
> "Name": null,
> "Type": null,
> "Order": 0,
> "IconId": 0,
> "Number": 0,
> "TemperatureSet": 24,
> "CurrentTemperature": 24.12
> },
> {
> "ThermostatId": 623,
> "Name": null,
> "Type": null,
> "Order": 0,
> "IconId": 0,
> "Number": 1,
> "TemperatureSet": 25,
> "CurrentTemperature": 24.62
> },
> {
> "ThermostatId": 624,
> "Name": null,
> "Type": null,
> "Order": 0,
> "IconId": 0,
> "Number": 2,
> "TemperatureSet": 24,
> "CurrentTemperature": 24.18
> },
> {
> "ThermostatId": 625,
> "Name": null,
> "Type": null,
> "Order": 0,
> "IconId": 0,
> "Number": 3,
> "TemperatureSet": 24,
> "CurrentTemperature": 24.6
> },
> {
> "ThermostatId": 626,
> "Name": null,
> "Type": null,
> "Order": 0,
> "IconId": 0,
> "Number": 4,
> "TemperatureSet": 26,
> "CurrentTemperature": 24.43
> }
> ],
> "settings": {
> "dateTime": null,
> "people": 3,
> "currency": 0,
> "antilegio": 0,
> "kwh_creuse": 0.15,
> "kwh_pleine": 0.15
> },
> "indicatorType": "TONE_Indicator"
> },
> "thermostats": null,
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer VOTRE TOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
4 - Mise à jour des thermostats dans le cas d’un T-ONE ALDES
URL : https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products/VOTREDEVICEID/updateThermostats
Méthode : PATH
Paramètres : [{« ThermostatId »: « 622 »,« TemperatureSet »: 25}]
Précisions :
- Il faut récupérer le ThermostatId du point 3
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products/VOTREDEVICEID/updateThermostats',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS =>' [{"ThermostatId": "VOTRE THERMOSTAT","TemperatureSet": VOTRE TEMPERATURE}]',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer VOTRETOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;