Note: As of July15th 2021 Viessmann will close down this soultion! A (temporary solution is available: https://community.openhab.org/t/vitoconnect-getting-values-sending-commands-via-the-new-api-by-using-rules/123900).
Solution for getting and setting readings from your Viessmann heating system via a connected VitoConnect 100 unit. The later connects to a Viessmann server only via your local Wifi, however the needed data can be requested from that server.
Note: YES, this is not the “normal” way for a openHAB solution, i.e. using only data from own sources. Look at the Vitotronic Binding with all its requirements if you are not comfortable with this cloudbased approach.
The solution is based on code written by the french Github-user “thetrueavatar”, who made it real easy to use the Viessmann API. A big MERCI BEAUCOUP goes to “thetrueavatar”.
The code can be found here.
Prerequisites:
- PHP7 and Curl installed on the System ( use “sudo apt-get instal php” AND “sudo apt-get install php-curl” for installation)
- User credential for ViCare App
- Exec Binding installed on openHAB
On the above posted Github-Link, navigate to the Code page page and select the Example folder. From the displayed files download the files “Viessmann-Api-x.y-SNAPSHOT.phar” (the x.y Version number might change and the "SNAPSHOT might be dropped in the future), “bootstrap.php”, and “credentials.properties” and paste them into the “scripts” folder of your openHAB system.
Edit the “credential.properties” and fill in your username and password, each in a seperate line. Save the file.
[Updated]
For getting values use a one single php file for all requests (that way the needed token is requested only once) and call the script via a rule.
Create a new .php file with following entries (for example to get the Outside Temperature and HotWater Temperature, the values are seperated by a “@” sign!):
<?php include __DIR__.'/bootstrap.php';
echo $viessmannApi->getOutsideTemperature();
echo "@";
echo $viessmannApi->getHotWaterStorageTemperature();
and save it, for example GetValues.php.
Make the file executable for owner and group.
You can test it from the commandline with.
php GetValues.php
For other readings refer to the Example folder.
Item Definitions:
String OutsideTemperature "OutsideTemperature [%s °C]"
String BoilerTemperature "BoilerTemperature [%s °C]`
Use a rule like:
rule "GetValues"
when
Time cron "10 0/5 * * * ?" //called every five minutes
then
var result=executeCommandLine("php@@/etc/openhab2/scripts/GetValues.php",5000)
OutsideTemperature.postUpdate( result.split("@").get(0))
BoilerTemperature.postUpdate( result.split("@").get(1))
end
For setting values create a new .php file with following entries (for example for setting the heating curve).
SetCurve.php
<?php
include __DIR__.'/bootstrap.php';
$slope=$viessmannApi->getSlope();
$shift=$viessmannApi->getShift();
if (count($argv)>1) {
if (count($argv)==2 ) {
//One argument given, has to be Shift!!
echo $viessmannApi->setCurve($argv[1], $slope);
echo "Shift set!"."\n";
}
if (count($argv)==3 ) {
//Two arguments given, has to be Shift followed by Slope!!
echo $viessmannApi->setCurve($argv[1], $argv[2]);
echo "Slope and Shift set!"."\n";
}
} else {
echo "Nothing set!"."\n";
}
This script takes shift and slope as commandline arguments.
Make the file executable for owner and group.
You can test it from the commandline with:
php SetCurve.php
It can run with one or two commands or with none!
In openHAB you can start it through a rule like:
rule "Test"
when
Item Test changed
then
var String slope="0.8"
var String shift="4"
logInfo("Test", "Start")
var result=executeCommandLine("php@@/etc/openhab2/scripts/MyScript.php@@" + slope + "@@" + shift,6000)
logInfo ("Test", "Result: {}", result)
end
The hardcoded values for slope and shift could easily be connected to setpoint items!
NOTE: The decimal point in the rule HAS TO BE set according the language setting of your system when started via the openHAB rule! In my case (german) I have to set it to “0,8”!