[VitoConnect] Getting readings from Viessmann Heating system via VitoConnect

I have added a section to understand the data structure and how to discover the leaf feature based on json

@thetrueavatar, thank you for taking the time to clarify things. As a n00b I’m feeling way out of my depth here but I keep on trying.

I did an in depth guide but I could do kind of cheat sheet because you don’t have to understand the whole stuff. Basically, I could implement a getLeafFeatures that would only display features with property or action field.
EDIT: in fact that’s exactly what getAvailableFeatures does. So basically use getAvailableFeatures, check not yet supported features and use the how to code read/write method for those.

Thank you for sharing your config! It helps me really much!

Im getting a warning for the burner if it is off.

[WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert '' to a state type which item 'Viessmann_BurnerActive' accepts: [DecimalType, QuantityType, UnDefType].

And there are validation issues:

The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object

Do you have a solution for that?

Please show the rule that sets the item “Viessmann_BurnerActive”.
Where do you use a transformation, please show item definition and the rule that sets the item.
Did you install the used transformation service?

I updated the OP in order to show a useable way to set values (SetCurve).

@thetrueavatar:
I noticed a problem!
When starting the script to set Shift and Slope from the command line, handing over the decimal value for slope (0.8) has to be given with the international decimal separator (the dot). However when I let openHAB start the script via a rule using “executeCommandLine” I need to use the localized decimal separator (in my case a comma). It looks to me as if that different behavior is introduced by “executeCommandLine”, but I’m not sure on that. What is your opinion on that?

I’ve used Alex44’s rule with the jsonpath tranformation:

    // Updates heating related Items with data exposed by the vitoConnect/Viessmann-PHP API :
rule "GetVitoconnetData"
  when
    Time cron "0 0/5 * * * ?" or //called every five  minutes
    Item Viessmann_Test changed to ON
  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_Mode.postUpdate( transformRaw("JSONPATH", "$.Mode", jsonVitoData)  )
        Viessmann_Program.postUpdate( transformRaw("JSONPATH", "$.Program", jsonVitoData)  )
        Viessmann_BurnerActive.postUpdate( transformRaw("JSONPATH", "$.IsBurnerAcive", jsonVitoData)  )
        Viessmann_Standby.postUpdate( transformRaw("JSONPATH", "$.IsStandby", jsonVitoData)  )

        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)  )
        Viessmann_WarmwasserTemperature.postUpdate( transformRaw("JSONPATH", "$.HotwaterTemp", jsonVitoData)  )
        logDebug("GetVitoconnetData","vitoconnet data updated !")

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

And this is my items file:

    String  Viessmann_Mode                      //"Warmwasser Temperatur [%.1f °C]"
    String  Viessmann_Program                   "[MAP(viessmann.map):%s]"
    Number  Viessmann_BurnerActive
    Number  Viessmann_Standby
    Number  Viessmann_OutsideTemperature        "Außen Temperatur [%.1f °C]"        (gViessmann)
    Number  Viessmann_BoilerTemperature         "Boiler Temperatur [%.1f °C]"       (gViessmann)
    Number  Viessmann_EcoTemperature            "Eco Temperatur [%.1f °C]"
    Number  Viessmann_NormalTemperature         "Normal Temperatur [%.1f °C]"
    Number  Viessmann_ComfortTemperature        "Komfort Temperatur [%.1f °C]"
    Number  Viessmann_WarmwasserTemperature     "Warmwasser Temperatur [%.1f °C]"   (gViessmann)
    Switch  Viessmann_ComfortOn                                                      {channel="exec:command:comfort:run"}
    Switch  Viessmann_ComfortOff                                                     {channel="exec:command:reduced:run"}
    Switch  Viessmann_ConfortMode

I think the problem is, that openhab is getting “1” from the api if the burner is active, and nothing if the burner is inactive. Do you see a chance to fix that in openHAB?

Well the api is excpecting string not number. There is conversion because at some point it considers it as number. Maybe should you wrap in your executeCommandLine the slope by some extra double quote to be sure that the parameter is not parsed as number.

You are posting the update for the item in your rule, you could quite easily use an if statement to do a correct update. Changing the company ViessmannApi is out of scope.

Will try that, thanks for the response.

I don’t understand what you mean. Could you explain that? Where should I place the if statement and what should it do?

Instead of:

Viessmann_BurnerActive.postUpdate( transformRaw("JSONPATH", "$.IsBurnerAcive", jsonVitoData) )

try this ( not tested, written on a phone!)

var temp=transformRaw("JSONPATH", "$.IsBurnerAcive", jsonVitoData)
if temp=1 {
Viessmann_BurnerActive.postUpdate(temp) 
} else {
Viessmann_BurnerActive.postUpdate(0)
}
1 Like

Awesome. Thank you JĂŒrgen. I’ve changed it a littlebit:

    var burner = transformRaw("JSONPATH", "$.IsBurnerAcive", jsonVitoData)
        if(burner==1) { Viessmann_BurnerActive.postUpdate(ON) }
        else { Viessmann_BurnerActive.postUpdate(OFF) }

      var standby = transformRaw("JSONPATH", "$.IsStandby", jsonVitoData)
        if(standby==1) { Viessmann_BurnerActive.postUpdate(ON) }
        else { Viessmann_BurnerActive.postUpdate(OFF) }

The burner and stanby items are now switch items.
There are still some other issues. One of it is a validation issue. Not urgent, but I dont like to see issues in my logs:

[INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'viessmann-api.rules', using it anyway:
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
The method transformRaw(String, String, String) from the type Transformation refers to the missing type Object
2019-12-17 09:59:29.222 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'viessmann-api.rules'

And the other one:

[ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'GetVitoconnetData': json string can not be null or empty

I think I have to live with this one
right?

For information, this is the way php manage boolean. The echo function displays empty when a boolean is false
 However, there is a way to fix that by casting the boolean in int:
echo (int)$viessmannApi->isHeatingBurnerActive();

2 Likes

Ups! I did it the “old basic” way again. Yes, you need double == !
As for the Validation Issue, I use “transform” instead of “transformRaw” without issues!

1 Like

Hi @opus ,
thank you for your great tutorial.
I tried it and it works pretty good.

Just two comments on your description:
I had to put a semicolon behind the @. So it looks like this:

 <?php include __DIR__.'/bootstrap.php';
 echo $viessmannApi->getOutsideTemperature();
 echo "@";
 echo $viessmannApi->getHotWaterStorageTemperature();

And the item definition has a typing error. It is called:
String BoilerTemperature "BoilerTemeprature [%s °C]"

If you may correct this, so others will not do the same mistakes like me.
Thank you.

1 Like

Viessmann company has written to all(?) users of their API.

**From the coming week on, a threshold will become active that prevents from unauthorized use of the API** **.** This will affect all third-party solutions, which can thereby no longer be used.

 We are aware that the demand for APIs to our technologies for integration
  into other solutions and third-party systems is increasing. 

To provide you with an opportunity for this, we will launch a portal in the next two months for all developers to get access to our API. With the **Viessmann Developer Portal** , we intend to open ourselves up, release a documentation of the interface and co-develop new solutions together with you

So, don’t be surprised if the solution posted above stops to work!

What’s your source for this mail ? I didn’t receive it. Anyway I have never had the chance to receive any information from Viessmann even if I have filled in their form to participate in the test of their new api
 I do fear they will force kind of subscription to allow us to use the api 


Hi there,
I read it here:
https://www.viessmann-community.com/t5/Experten-fragen/ViCare-Blick-zur%C3%BCck-und-nach-vorne/qaq-p/84614/comment-id/103306#

Ok the ban is quite long in fact. The limit is 1450 request/day. Once you have reached the quota you’re a banned for a lot of time. For instance, I’m currently ban till 17h20
 I guess this is something like a 24h ban if you exceed the limit. Moreover this is per request. The problem is that with my api every information asked is a request. 10 informations every 5 min -> 1680 request/day -> boum !!! A workaround would be to use the getFeatures() method that retrieve all the information and to parse it


Here is the response received
{
“errorType”: “RATE_LIMIT_EXCEEDED”,
“extendedPayload”: {
“clientId”: “XXX”,
“limitReset”: 1584462010106,
“name”: “ViCare day limit”,
“requestCountLimit”: 1450,
“userId”: “XXXX”
},
“message”: “API calls rate limit has been exceeded. Please wait until your limit will renew.”,
“statusCode”: 429,
“viErrorId”: “XXXXX”

This limit is pretty a non-sense as they have developped an approach HATEOAS which is means to force client to discover the api bit by bit and so implies a lot of call