-
Notifications
You must be signed in to change notification settings - Fork 37
Home
Le code a été développé en php 7. Les dépendances sont gérées via composer. Le client Oauth est implémenté à l'aide la librairie PHPoAuthLib https://github.com/Lusitanian/PHPoAuthLib Le parsing Siren Json est fait avec siren-php https://github.com/tomphp/siren-php
Désormais, l'API est livrée sous la forme d'un seul fichier .phar(php archive) qu'on peut inclure directement dans un fichier php.
Le fichier php example/Main.php montre un simple exemple d'appel.
Il suffit d'ajouter son user à la 1ère ligne de credentials.properties et son password à la 2ème ligne. Tout le reste de la partie Oauth se fait de façon transparente à l'instanciation de l'api. La méthode getFeatures() permet de récupérer le tableau des features en json. La méthode getRawData renvoye le json/siren directement. Il suffit de lui passer le nom de la feature. J'ai ajouté des constantes pour les features courrantes(voir après code) Les autres méthodes renvoie les valeurs directement.
<?php
include 'phar://../bin/Viessmann-Api-0.1-SNAPSHOT.phar/index.php';
use Viessmann\API\ViessmannAPI;
$credentials = file("../resources/credentials.properties");
$params=[
"user"=>trim("$credentials[0]","\n"),
"pwd"=>trim("$credentials[1]","\n"),
"uri"=>"vicare://oauth-callback/everest"
];
$viessmanApi=new ViessmannAPI($params);
echo $viessmanApi->getFeatures();
echo "Température extérieure ".$viessmanApi->getOutsideTemperature()."\n";
echo "Température boiler ".$viessmanApi->getBoilerTemperature()."\n";
echo "Pente ".$viessmanApi->getSlope()."\n";
echo "Parallèle ".$viessmanApi->getShift()."\n";
echo "Mode chaudière ".$viessmanApi->getActiveMode()."\n";
echo "Programme actif ".$viessmanApi->getActiveProgram()."\n";
echo "Is Heating Burner active ? ".$viessmanApi->isHeatingBurnerActive()."\n";//in php false bool is converted into empty string
echo "Is Dhw mode active ? ".$viessmanApi->isDhwModeActive()."\n";
echo "Température de confort ".$viessmanApi->getComfortProgramTemperature()."\n";
echo "Température écho ".$viessmanApi->getEchoProgramTemperature()."\n";
echo "Température externe ".$viessmanApi->getExternalProgramTemperature()."\n";
echo "Température réduit ".$viessmanApi->getReducedProgramTemperature()."\n";
echo "Température supply ".$viessmanApi->getSupplyProgramTemperature()."\n";
echo "Est en veille ? ".$viessmanApi->isInStandbyMode()."\n";
echo "Appelle resources ".$viessmanApi->getRawData(ViessmannAPI::HEATING_PROGRAM_ACTIVE);
Liste des constantes passable à getRawData:
const BOILER_TEMP="heating.boiler.sensors.temperature.main";
const HEATING_BURNER="heating.burner";
const HEATING_CIRCUITS="heating.circuits";
const HEATING_CIRCUITS_0="heating.circuits.0";
const HEATING_CURVE="heating.circuits.0.heating.curve";
const HEATING_OPERATING_MODES="heating.circuits.0.operating.modes.active";
const HEATING_DWH_MODE="heating.circuits.0.operating.modes.dhw";
const HEATING_DWH_AND_HEATING_MODE="heating.circuits.0.operating.modes.dhwAndHeating";
const HEATING_FORCED_NORMAL_MODE="heating.circuits.0.operating.modes.forcedNormal";
const HEATING_FORCED_REDUCTED_MODE="heating.circuits.0.operating.modes.forcedReduced";
const HEATING_STANDY_MODE="heating.circuits.0.operating.modes.standby";
const HEATING_PROGRAM_ACTIVE="heating.circuits.0.operating.programs.active";
const HEATING_PROGRAM_COMFORT="heating.circuits.0.operating.programs.comfort";
const HEATING_PROGRAM_ECHO="heating.circuits.0.operating.programs.eco";
const HEATING_PROGRAM_EXTERNAL="heating.circuits.0.operating.programs.external";
const HEATING_PROGRAM_NORMAL="heating.circuits.0.operating.programs.normal";
const HEATING_PROGRAM_REDUCED="heating.circuits.0.operating.programs.reduced";
const HEATING_PROGRAM_STANDBY="heating.circuits.0.operating.programs.standby";
const HEATING_PROGRAM_SUPLY="heating.circuits.0.sensors.temperature.supply";
const HEATING_TIME_OFFSET="heating.device.time.offset";
const HEATING_DWH="heating.dhw";
const HEATING_CIRCUITS_1_DHW="heating.circuits.1.dhw";
const HEATING_DWH_TEMPERATURE="heating.dhw.temperature";
const HEATING_DWH_SENSORS="heating.dhw.sensors";
const HEATING_DWH_SENSORS_TEMPERATURE="heating.dhw.sensors.temperature";
const HEATING_DWH_SCHEDULE="heating.dhw.schedule";
const HEATING_DWH_TEMPERATURE_HOTWATER_STORAGE="heating.dhw.sensors.temperature.hotWaterStorage";
const HEATING_DWH_TEMPERATURE_OUTLET="heating.dhw.sensors.temperature.outlet";
const HEATING_GAS_CONSUMPTION_DHW="heating.gas.consumption.dhw";
const HEATING_TEMP_OUTSIDE="heating.sensors.temperature.outside";
const HEATING_SENSORS_TEMPERATURE="heating.sensors.temperature";
const HEATING_TIMEBASE="heating.service.timeBased";
const HEATING_SENSORS="heating.sensors";
const GATEWAY_DEVICES="gateway.devices";