-
Notifications
You must be signed in to change notification settings - Fork 37
English
Code as been developed in php7. Git is folowing basic Gitflow principle:
- Master branch contains release(0.1,0.2,0.3,...)
- Develop branch contains developpment(feature) finalized. Version will be SNAPHOST suffixed
- Feature/xxx branch will contains not yet finished development.
Dependency managment is done through composer. Oauth client is implemented with PHPAuthLib library: https://github.com/Lusitanian/PHPoAuthLib Siren Json parsing is done with siren-php https://github.com/tomphp/siren-php
The API is release as on signle phar file which can be directly included in a php file
The api requires php 7 and php-curl component to be installed. On raspberry you only need to type in commande line and enter your current user password:
sudo apt-get install php-curl
The main point on how to use the api si to include the phar through include 'phar://../bin/Viessmann-Api-0.1-SNAPSHOT.phar/index.php' . This include the whole api and auto-load every class.
To use the api, you only have to instanciate the ViessmannApi class with an array of parameter and then call method on it:
- user: username viessmann
- pwd: password viessmann
- uri: callback url after Oauth2. Not sure it's usefull and might be removed in the furter release.
All together
<?php
include 'phar://'.__DIR__.'/Viessmann-Api-0.3-SNAPSHOT.phar/index.php';
use Viessmann\API\ViessmannAPI;
$params = [
"user" => "username",
"pwd" => "password",
"uri" => "vicare://oauth-callback/everest"
];
$viessmannApi = new ViessmannAPI($params);
With that you can now use the $viessmannApi to call method on it.
Basically, to run the code, you'll have to copy the phar, example/credentials.properties(filled in with your credentials), example/bootstrap.php writeyour own php file such as this:
<?php
include __DIR__.'/bootstrap.php';
echo $viessmannApi->getRoomTemperature();
You'll find some more example in the example directory.
Since 0.3 version you can provide upon instanciation of the ViessmannApi which default deviceId and circuitId should be use for method call. However, this can be overwritten by passing the circuitId as parameter to the method:
$viessmannApi->getRoomTemperature(4);// will use circuitId 4.
You will find a file example/Main.php showing some common function. Full list of function can be found here: Viessmann API:
Right now exposed function are auto-generated here: Viessmann API: Some special features:
- getFeatures() get a huge json file containing all the feature provide by the service.
- getAvailableFeatures(): return a lisf of feature having either a value or and action that can be used. This is the quickest way to find what cand be done with your own heating system and the API.
- getRawJsonData return json/siren corresponding to the given feature
- setRawJsonData allow you to change data of a feature. You have to pass 3 argument: feature,action,json containing the data to update.
A shell script is avaiable on script/createPhar.sh
it run this command in the root of the git
php -d phar.readonly=0 phar-builder.phar package composer.json
.
phar-builder.phar parameters are configure in the composer.json:
"extra": {
"phar-builder": {
"compression": "GZip",
"name": "Viessmann-Api-0.2.phar",
"output-dir": "./example",
"entry-point": "./index.php",
"include": "php",
"include-dev": false,
"skip-shebang":false
}
}
Once the script is launched, it will create a new version of the phar in the example directory.