[VitoConnect] Getting readings from Viessmann Heating system via VitoConnect

Hello,

This is my first post here, I wanted to thanks @opus and @thetrueavatar for sharing this viessmann / vitoconnect solution.
I own a Viessmann fuel boiler (vitoladens 300c) with a vitoconnect attach to it since 1 year, used initially for remote control / supervision.

I want to optimize my heating and I’ve just installed and configured an OpenHab solution with the Viessmann-API : after a few gotchas it’s working nicely. I’m also configuring some MAX! radiators TRV but that’s another story…

Just want to share an alternative to your config : as I want to persist in influxdb the temperatures data fetch from the vitoconnect, I needed the items to be cast as Number and not String, so here are my openhab config ;

Items definition, the ‘gTemperatures’ is used ad a funcitonal group to persist all ‘temperatures related’ items to be persisted in influxdb

Number Viessmann_OutsideTemperature "T° Extérieur [%.1f °C]"        (gTemperatures)  
Number Viessmann_BoilerTemperature  "T° Chaudière [%.1f °C]"        (gTemperatures)  
Number Viessmann_EcoTemperature     "T° consigne Eco [%.1f °C]"                      
Number Viessmann_NormalTemperature  "T° consigne Normal [%.1f °C]"                   
Number Viessmann_ComfortTemperature "T° consigne Comfort [%.1f °C]"                 

php script that will output JSON formatted data (for me /etc/openh2/scripts/viessmann-api/get-vitoconnect-data.php)

<?php include __DIR__.'/bootstrap.php'; ?>
{
    "Mode" :          <?php echo $viessmannApi->getActiveMode() ?>,
    "Program" :       <?php echo $viessmannApi->getActiveProgram() ?>,
    "IsBurnerAcive" : <?php echo $viessmannApi->isHeatingBurnerActive() ?>,
    
    "ExtTemp" :      <?php echo $viessmannApi->getOutsideTemperature() ?>,
    "BoilerTemp" :   <?php echo $viessmannApi->getBoilerTemperature() ?>,
    "EcoTemp" :      <?php echo $viessmannApi->getEcoProgramTemperature() ?>,
    "NormalTemp" :   <?php echo $viessmannApi->getNormalProgramTemperature() ?>,
    "ComfortTemp" :  <?php echo $viessmannApi->getComfortProgramTemperature() ?>

}

GetVitoconnetData rule to extract the data for each item, cast as number thanks to JSONPATH Transformation :

// Updates heating related Items with data exposed by the vitoConnect/Viessmann-PHP API :
rule "GetVitoconnetData"
  when
     Time cron "0 0/5 * * * ?" //called every five  minutes
  then

    var jsonVitoData = executeCommandLine("php /etc/openhab2/scripts/viessmann-API/get-vitoconnect-data.php", 5000)
    
    logDebug("GetVitoconnetData","get-vitoconnect-data.php executed !")
    try {
        // Parse the output and post Updates :
        Viessmann_OutsideTemperature.postUpdate( transformRaw("JSONPATH", "$.ExtTemp", jsonVitoData)  ) 
        Viessmann_BoilerTemperature.postUpdate( transformRaw("JSONPATH", "$.BoilerTemp", jsonVitoData)  ) 
        
        Viessmann_EcoTemperature.postUpdate( transformRaw("JSONPATH", "$.EcoTemp", jsonVitoData)  ) 
        Viessmann_NormalTemperature.postUpdate( transformRaw("JSONPATH", "$.NormalTemp", jsonVitoData)  ) 
        Viessmann_ComfortTemperature.postUpdate( transformRaw("JSONPATH", "$.ComfortTemp", jsonVitoData)  ) 
        logDebug("GetVitoconnetData","vitoconnet data updated !")

    }  catch(TransformationException e) {
        logError("GetVitoconnetData", "Unable to extract valid data from script result : " + e.getMessage)
    }
  end

Using above config, my influxdb/grafana is working and will let me know precisely how my heating operate.

I still have to work on persistence of the ‘isBurnerActive’ field, maybe as a 0/1 int.
Another missing information in my influxdb is the ‘circulation pump’ activation… but I dont think vitoconnect give access to this… so sad.

Thank you again for sharing this.

EDIT : on my system, use of ‘@@’ in command line was a mistake : on a raspberry the behaviour with the ‘@@’ is a truncated script output send to the rule… my data was not retrieved as wanted (only first 2 fields at the begining of the json structure were correctly fetch)

2 Likes

Thanks for sharing.
I do store the examples as posted in rrd4j.

@opus @thetrueavatar

Im new to OH, so maybe a silly question…

What is the advantage of using this method (vitoconnect) over using just the optolink and and the Openhab binding?

Thank you

1 Like

You can only use either or. Either you use the Vitoconnect device (which is sending data to the Viessmann server all the time and you are getting the data only via this server!) Or you use the Optolink Cable and connect directly to your installation.
The later sounds more like an Intranet-approach, the Vitoconnect approach more easy to achieve.

1 Like

Thank you @opus

I have 2 circuits in my house.
I have problems setting Viessmann to eco mode using a php script calling the ViessmannAPI on either circuit. This is the error I get:

PHP Fatal error: Uncaught Viessmann\API\ViessmannApiException: Unable to set data for featureheating.circuits.0.operating.programs.ecoand action activate and data{“temperature”:“1”}
Reason: DEVICE_COMMUNICATION_ERROR in phar:///openhab/conf/scripts/Viessmann-Api-0.4-SNAPSHOT.phar/src/API/ViessmannAPI.php:769
Stack trace:
#0 phar:///openhab/conf/scripts/Viessmann-Api-0.4-SNAPSHOT.phar/src/API/ViessmannAPI.php(194): Viessmann\API\ViessmannAPI->setRawJsonData(‘heating.circuit…’, ‘activate’, ‘{“temperature”:…’)
#1 /openhab/conf/scripts/Vitoconnect_activateEcoProgram.php(2): Viessmann\API\ViessmannAPI->activateEcoProgram(1)
#2 {main}
thrown in phar:///openhab/conf/scripts/Viessmann-Api-0.4-SNAPSHOT.phar/src/API/ViessmannAPI.php on line 769

Using this php script:

<?php include DIR.‘/bootstrap.php’; ?>
<?php echo $viessmannApi->activateEcoProgram(1); ?>

Could it be there are some errors in the API or did I miss something?
BTW: I also tried changing the php script to

activateEcoProgram(15,1)

without any difference.
Thanks for your advice on the next step.

I can’t look into the .phar!
From the examples I would say you need to pass a number as a string, like activateEcoProgramm("1").
But that is guessing!

Hello,

DEVICE_COMMUNICATION_ERROR is a temporary error that Viessmann’s server return. Don’t know why but usually after a couple of hour this error vanish.
It suggest that there is a communication problem with the vitoconnect but from my experience this happens even when connection seems ok.

For information, there is now a documentation auto-generated based on code:

https://htmlpreview.github.io/?https://raw.githubusercontent.com/thetrueavatar/Viessmann-Api/develop/docs/class-Viessmann.API.ViessmannAPI.html

You will find thhis activateEcoProgram(

                            $temperature = NULL, $circuitId = NULL )

this means activateEcoProgram have 2 optionnal parameter. Temperature and circuitId.

My code is documented and it should displayed explanation but this seems to failed till now to detect annoation @Param for documentation generation.

Best Regards,

Thetrueavatar

Le dim. 30 déc. 2018 à 21:22, Jürgen Baginski bot@community.openhab.org a écrit :

Hi,

I’m still getting the same error, everytime I run the script. I even tried adding quotes for temperature (despite not necessary when looking at the code), which doesn’t change anything.
I also tried restarting the Vitoconnect (by unplugging it from main power for 10 seconds), but to no avail.

I’m stuck as to why this error still occurs.
Any suggestion?

Setting the mode for circuit 1 works without any trouble.

I have got the exact same error but I don’t have this functionnality. My guess is that your heating system doesn’t have any “eco” mode(which is different from reduced mode). Error return by viessmann are not very consistent as sometimes we receive “FEATURE NOT FOUND”, sometimes a json for the feature without any data and sometimes(this case) a DEVICE_COMMUNICATION_ERROR. I don’t know if the eco functionnality is already available on ViCare App. Could you check it please ? What’s your heating system model ?

Hi

I have a Vitodens 200-W B2HA 26kW, and ViCare App provides the ability to select the eco function. When selecting this option I can indicate which circuit I want to switch to eco mode (or both),

Kind regards

Shakayoda

You’re right, I have the same functionnality. I will check what’s wrong then. However, I have noticed that the temperature choosen for eco program is the same as the reduced program…

Well right now I have just use the script to activate eco program and it’s working…
For information, I have pushed a couple of days ago a change to fix some problem with deactivate program. If you take the last phar deActivateEcoProgram should work…
The problem was that I was sending an empty body while viessman server wanted and empty json. Replacing null by “{}” solved the problem…
I have implemented activate/deactivate comfortProgram but still have DEVICE_COMMUNICATION_ERROR. Just waiting viessman to fix their service…
Here is the last commit message:

added:

  • holiday scheduling/unscheduling and example
  • comfort program activation/deactivation and example

Fixed:

  • setExternalTemperature was set temperature on reduced program
  • activateEcoProgram doesn’t fail anymire if no temperature is provided

I think it’s time to release a 1.0 version btw.

1 Like

Here it is 1.0 version available here https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.0

activateEcoProgram indeed works now, but only when suppyling NULL as the desired temperature. Specifying the temperature results in a DEVICE_COMMUNICATION_ERROR.

echo $viessmannApi->activateEcoProgram(NULL,1); works as expected,

echo $viessmannApi->activateEcoProgram(15,1); results in a DEVICE_COMMUNICATION_ERROR.

echo $viessmannApi->deActivateEcoProgram(1); works as expected.

My heater does not support some of the “advanced” functions like getHeatingBurnerStatistics() or getDhwGasConsumption() and probably some others as well. This is correctly reported as FEATURE_NOT_FOUND

I did not try the holiday function yet, but I will report when tested. Note that it’s not available in the app. In what format do you need to provide the parameters $start and $end?

Well I have the same problem. It seems that temperature for activate eco program is number but I did wrap it with double quote… By removing double quote around temperature value this is working now. I have commited the code a nd release 1.0.1(https://github.com/thetrueavatar/Viessmann-Api/releases/tag/1.0.1). Could you give it a try please ?

It’s working flawlessly now. Thank you for your good work.

Could you still indicate what type $start and $end should be for the holiday function?

Well tbh I don’t know. It’s specified as string but I guess it’s a date. I have tried classical format “yyyy-MM-dd” without success. Since schema specified in json are not available on the internet(guess only on viessmann’s intranet) I will have to start a “trial and error” session until I found or hope this feature becomes available on ViCare to sniff data send…

I found the right format for the datetime for the scheduleHolidayProgram.

echo $viessmannApi->scheduleHolidayProgram(“2019-01-16T08:00:00.419Z”,“2019-01-17T08:00:00.419Z”,1);

This didn’t result in any error message in contrast to other trials. I double checked it on the heater and it reported these dates in the Holiday Program. If I’m right this is the classic serialization of a date with toJSON() method.
Hope this helps others.

Ok so this is datetime xml format. Will update documentation according to this. Thank you for your feedback.