Skip to content

Commit

Permalink
Update client to use new IOT API from Viessmann
Browse files Browse the repository at this point in the history
Removed session_start() from code so that session is managed by the user of the api.
credentials.properties is now defined as key=value file.
  • Loading branch information
lbscld committed Jul 16, 2021
1 parent dee4e00 commit 49c3771
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 168 deletions.
30 changes: 30 additions & 0 deletions Changelog-en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Version 1.4.0
--------------
Switch to version 2 of Oauth Viessmann servuce. Many other small improvements. See release note https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.4.0

Version 1.3.4
--------------
Suppress dep on php 7.1 and fix GetAvailableFeatures https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.4

Version 1.3.3
--------------

Added missing DateTime import.
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.3

Version 1.3.2
--------------
Warning. This version requires php and php-curl 7.1 to support "?".
Added caching to reduced load is available here : https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.2
It's also possible to define installationId(3rd line) and gatewayId(4th line) in the credentials.properties.
To get those value please use the getGatewayId and getInstallationid method.
This would reduce the total of request to 3. Moreover authentication(2 request) seems to not be taken into account so it will result in only 1 request counting in the quota.

As mentionned, Viessmann as set 2 limit to their API:
* 120 calls for a time window of 10 minutes
* 1450 calls for a time window of 24 hours



Version 1.1.0 available !
-------------------------
54 changes: 54 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Version 1.4.0
-------------
Basculement sur la version v2 du service Oauth Viessmann. Plusieurs autres modifications voir release note https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.4.0

Version 1.3.4
-------------
Suppression de la dépendance sur php 7.1 et fix de GetAvailableFeatures
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.4

Version 1.3.3
--------------

Ajout d'un import DateTime manquant créant une erreur lors du traitement du message de ban de Viessmann:
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.3

Version 1.3.2
--------------
Attention, cette version nécessite php et php-curl 7.1 pour supporter l'utilisation du "?".
Translated documentation can be found here:
- English: https://github.com/thetrueavatar/Viessmann-Api/blob/develop/README-en.md

Ajout d'une cache et refactoring pour réduire la charge sur le serveur Viessmann https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.2
Il est désormais possible de définir dans le credentials.properties son installationId(3ème ligne) et son gatewayid(4ème ligne) ce qui réduit le nombre de requêtes nécessaire.
Ces valeurs peuvent être obtenues en appelant les méthodes getGatewayId and getInstallationId avec juste le user/pwd dans credentials.properties.
Cela réduira le nombre de requête à 3 dont 2 pour l'authentification qui ne comptent pas dans le quota.
La cache est utilisée pour tout appelle sur l'objet ViessmannApi.
Le code suivant ne fait donc qu'un seul appel au total:

<?php
include __DIR__ . '/bootstrap.php';
$viessmannApi->getOutsideTemperature());
$viessmannApi->getBoilerTemperature());
$viessmannApi->getSlope());
$viessmannApi->getShift());

Comme déjà expliqué Viessmann limite désormais le nombre de requête sur son service:
* 120 calls for a time window of 10 minutes
* 1450 calls for a time window of 24 hours



News FR
----
Une nouvelle version utilisant une cache et évitant un nombre trop important d'appel est disponible en snapshot. Cette version a été développé à l'aveulge(mon compte est bloqué) mais fonctionne en test local. Faites-moi le plus de retour possible !
Attention, la cache fonctionne à condition que vous fassiez tout vos appels sur le même objet viessmannApi.
Exemple:

$viessmannApi->getOutsideTemperature());

$viessmannApi->getBoilerTemperature());

$viessmannApi->getSlope());

$viessmannApi->getShift());
34 changes: 14 additions & 20 deletions README-en.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
Version 1.3.3
--------------
Version 2.0.0-SNAPSHOT integrate with IOT services
--------------------------------------------------
Viessman has discontinued the access to the old api.

Added missing DateTime import.
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.3
I have started to work on the integration with the new IOT api on the branch features/iot https://github.com/thetrueavatar/Viessmann-Api/tree/features/iot
It's still in work in progress but reading data seems to work.
Some writing seems to works but still need some deep etst.
Please note, that somme ndpoint/feature may be missing on the new api. Viessmann is adding it on demand.
Be aware that with the iot api, you need to generate an api key on https://developer.viessmann.com/ and add it into the clintId field of credentials.properties.
You'll have to download the new [bootstrap.php](https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/bootstrap.php) and [credentias.properties](https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/credentials.properties).

Version 1.3.2
--------------
Warning. This version requires php and php-curl 7.1 to support "?".
Added caching to reduced load is available here : https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.2
It's also possible to define installationId(3rd line) and gatewayId(4th line) in the credentials.properties.
To get those value please use the getGatewayId and getInstallationid method.
This would reduce the total of request to 3. Moreover authentication(2 request) seems to not be taken into account so it will result in only 1 request counting in the quota.
The current snapshot phar can be found here https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/Viessmann-Api-2.0.0-SNAPSHOT.phar

As mentionned, Viessmann as set 2 limit to their API:
* 120 calls for a time window of 10 minutes
* 1450 calls for a time window of 24 hours
Changelog is now available here: https://github.com/thetrueavatar/Viessmann-Api/blob/develop/Changelog-en.md


If you wish to contribute or thanks me /Si souhaitez me soutenir ou me remercier:[![paypal](https://www.paypalobjects.com/fr_FR/BE/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LPAMB5QUEPV48)

If you wish to contribute or thanks me [![paypal](https://www.paypalobjects.com/fr_FR/BE/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3DAXXVZV7PCR6)

Version 1.1.0 available !
-------------------------

Implementation of an API to get data that are expose through the viessmann service.
This service is available through oauth2 autorization and use HATEOAS approach.
Viessmann is using the specification siren such as defined here:
https://github.com/kevinswiber/siren

The goal of this api is to hide technical aspect to expose only raw data so that users doesn't have to know anything about OAuth2 and Siren.

Expand Down
55 changes: 11 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,20 @@
Version 1.3.4
-------------
Suppression de la dépendance sur php 7.1 et fix de GetAvailableFeatures
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.4
Version 2.0.0-SNAPSHOT intégrée avec IOT
-------------------------
Depuis le 16 juillet, l'ancienne API de Viessmann ne semble plus utilisable.
J'ai donc planché sur une première version en urgence s'intégrant avec l'api IOT.
J’ai fait en sorte qu’elle est fonctionnelle pour la lecture des données.
Il se peut que certaines données ne soient pas tout de suite dispo et que je doives adapté certaines routes.

Version 1.3.3
--------------

Ajout d'un import DateTime manquant créant une erreur lors du traitement du message de ban de Viessmann:
https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.3
Attention que pour l’api, il faut générer un api key sur le portail https://developer.viessmann.com/ et l'ajouter dans le champ clientId de credentials.properties.

Version 1.3.2
--------------
Attention, cette version nécessite php et php-curl 7.1 pour supporter l'utilisation du "?".
Translated documentation can be found here:
- English: https://github.com/thetrueavatar/Viessmann-Api/blob/develop/README-en.md

Ajout d'une cache et refactoring pour réduire la charge sur le serveur Viessmann https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.3.2
Il est désormais possible de définir dans le credentials.properties son installationId(3ème ligne) et son gatewayid(4ème ligne) ce qui réduit le nombre de requêtes nécessaire.
Ces valeurs peuvent être obtenues en appelant les méthodes getGatewayId and getInstallationId avec juste le user/pwd dans credentials.properties.
Cela réduira le nombre de requête à 3 dont 2 pour l'authentification qui ne comptent pas dans le quota.
La cache est utilisée pour tout appelle sur l'objet ViessmannApi.
Le code suivant ne fait donc qu'un seul appel au total:

<?php
include __DIR__ . '/bootstrap.php';
$viessmannApi->getOutsideTemperature());
$viessmannApi->getBoilerTemperature());
$viessmannApi->getSlope());
$viessmannApi->getShift());
Il faut donc reprendre le fichier [bootstrap.php](https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/bootstrap.php) et [credentias.properties](https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/credentials.properties).

Comme déjà expliqué Viessmann limite désormais le nombre de requête sur son service:
* 120 calls for a time window of 10 minutes
* 1450 calls for a time window of 24 hours
Le phar se trouve sur https://github.com/thetrueavatar/Viessmann-Api/raw/features/iot/example/Viessmann-Api-2.0.0-SNAPSHOT.phar

If you wish to contribute or thanks me /Si souhaitez me soutenir ou me remercier:[![paypal](https://www.paypalobjects.com/fr_FR/BE/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3DAXXVZV7PCR6)
Désormais les informations sur les versions précédentes sont dispo dans le changelog: https://github.com/thetrueavatar/Viessmann-Api/blob/develop/Changelog.md

News FR
----
Une nouvelle version utilisant une cache et évitant un nombre trop important d'appel est disponible en snapshot. Cette version a été développé à l'aveulge(mon compte est bloqué) mais fonctionne en test local. Faites-moi le plus de retour possible !
Attention, la cache fonctionne à condition que vous fassiez tout vos appels sur le même objet viessmannApi.
Exemple:

$viessmannApi->getOutsideTemperature());

$viessmannApi->getBoilerTemperature());

$viessmannApi->getSlope());

$viessmannApi->getShift());
If you wish to contribute or thanks me /Si souhaitez me soutenir ou me remercier:[![paypal](https://www.paypalobjects.com/fr_FR/BE/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LPAMB5QUEPV48)


General info
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"require": {
"php": "^7.0",
"psr/link": "^1.0",
"phpunit/phpunit": "^7.3.2",
"phpunit/phpunit": "7.5.17",
"lusitanian/oauth": "v0.8.11",
"tomphp/siren": "v0.1.0",
"ext-json": "*",
Expand All @@ -23,7 +23,7 @@
"extra": {
"phar-builder": {
"compression": "GZip",
"name": "Viessmann-Api-1.4.0.phar",
"name": "Viessmann-Api-2.0.0.phar",
"output-dir": "./example",
"entry-point": "./index.php",
"include": "php",
Expand Down
6 changes: 3 additions & 3 deletions example/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
include __DIR__ . '/bootstrap.php';

use Viessmann\API\ViessmannFeature;

echo "All datas". $viessmannApi->getRawJsonData(""). "\n";
echo "Température extérieure " . $viessmannApi->getOutsideTemperature() . "\n";
echo "Température boiler " . $viessmannApi->getBoilerTemperature() . "\n";
echo "Pente " . $viessmannApi->getSlope() . "\n";
echo "Parallèle " . $viessmannApi->getShift() . "\n";
//echo "Pente " . $viessmannApi->getSlope() . "\n";
//echo "Parallèle " . $viessmannApi->getShift() . "\n";
echo "Mode chaudière " . $viessmannApi->getActiveMode() . "\n";
echo "Programme actif " . $viessmannApi->getActiveProgram() . "\n";
echo "Is Heating Burner active ? " . (int) $viessmannApi->isHeatingBurnerActive() . "\n";//in php false bool is converted into empty string
Expand Down
Binary file not shown.
9 changes: 2 additions & 7 deletions example/bootstrap-dev.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php
include __DIR__.'/../index.php';
use Viessmann\API\ViessmannAPI;
$credentials = file(__DIR__ . "/credentials.properties");
$params = [
"user" => trim("$credentials[0]"),
"pwd" => trim("$credentials[1]"),
"deviceId" => "0",
"circuitId" => "0"
];

$params = parse_ini_file(__DIR__ . "/credentials.properties");
function print_exception($e){
echo "Message: " . $e->getMessage() . "\n";
echo "Code: " . $e->getCode() . "\n";
Expand Down
14 changes: 3 additions & 11 deletions example/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

use Viessmann\API\ViessmannAPI;
use Viessmann\API\ViessmannApiException;
session_start();
include 'phar://' . __DIR__ . '/Viessmann-Api-2.0.0.phar/index.php';

include 'phar://' . __DIR__ . '/Viessmann-Api-1.4.0.phar/index.php';


$credentials = file(__DIR__ . "/credentials.properties");
$params = [
"user" => trim("$credentials[0]"),
"pwd" => trim("$credentials[1]"),
"installationId" =>trim("$credentials[2]"),
"gatewayId" =>trim("$credentials[3]"),
"deviceId" => "0",
"circuitId" => "0"
];
$params = parse_ini_file(__DIR__ . "/credentials.properties");
function print_exception($e){
echo "Message: " . $e->getMessage() . "\n";
echo "Code: " . $e->getCode() . "\n";
Expand Down
Loading

0 comments on commit 49c3771

Please sign in to comment.