Binding request: Viessmann (API/ViCare - not vitotronic)

If you are running openhab from a Linux box

1- install pyvicare from the repository

# pip3 install pyvicare

2- create a python script with the following (change username and password to the same you are using for the vicare application)

#!/usr/bin/python3

import argparse
import sys
import logging
import requests
from requests import Session
from PyViCare.PyViCareGazBoiler import GazBoiler

# ViCare Credentials
username = '<username>'
password = '<password>'

# OpenHAB
OpenHABIP = 'localhost:8080'

class ViCareConnectHeating(object):

    def ohPutValue(self, item, value):
        rc = requests.put('http://'+OpenHABIP+'/rest/items/'+item+'/state', str(value),headers={'Content-type': 'text/plain'})
        if(rc.status_code != 202):
            print("Warning: couldn't save item "+item+" to openHAB")
            exit(1)

    def ohGetValue(self, item):
        rc = requests.get('http://'+OpenHABIP+'/rest/items/'+item)
        print(rc.content)
        if(rc.status_code != 200):
            print("Status code ", rc.status_code)
            print("Warning: couldn't get item " + item + " from openHAB")
        data = json.loads(rc.content)
        return data['state']

    def queryData(self, session):
        self.ohPutValue('Viessmann_HWTargetTemperature',session.getDomesticHotWaterConfiguredTemperature())
        self.ohPutValue('Viessmann_HWCurrentTemperature',session.getDomesticHotWaterStorageTemperature())
        self.ohPutValue('Viessmann_supplyTemperature',session.getSupplyTemperature())
        self.ohPutValue('Viessmann_activeProgram',session.getActiveProgram())
        self.ohPutValue('Viessmann_activeMode',session.getActiveMode())
        self.ohPutValue('Viessmann_getOneTimeCharge',session.getOneTimeCharge())
        self.ohPutValue('Viessmann_outsideTemperature',session.getOutsideTemperature())

    def doCommand(self, session, command):
        if (command == 'activatecharge'):
            print('One time charge')
            session.activateOneTimeCharge()
        elif (command == 'desactivatecharge'):
            print('desactivate time charge')
            session.deactivateOneTimeCharge()

def main():

    usage = '%prog [options] arg'
    parser = argparse.ArgumentParser(usage)
    parser.add_argument('-c', action='store', dest='command', choices=['activatecharge', 'desactivatecharge'], help='send command to vicare')

    args = parser.parse_args()

    c = ViCareConnectHeating()
    t = GazBoiler(username,password,"token.save")

    if args.command:
        print('Executing: Command')
        returnVal = c.doCommand(t,args.command)
    else :
        s = c.queryData(t)

if __name__ == '__main__':
    main()

3- create openhab items

if you run the script, openhab items shall be populated. Mind that Viessmann limit the use of the API, so do not query (run the script) more than once every 10min or so.

-> run the script with no params and data gets refresh.

-> run the script with -c activatecharge or -c desactivatecharge to active / desactivation one time charge of the hot water.

Thanks for this explanation, Fred!
One thing before I start: I’m interested in current electricity production and gas consumption values. I guess I’ll have to add commands like “self.ohPutValue(‘Viessmann_HWCurrentTemperature’,session.getDomesticHotWaterStorageTemperature())” to get this. Do you know which commands exactly or how to figure them out?

The possibilities are provided by the library, see the documentation at GitHub - somm15/PyViCare: Python Library to access Viessmann ViCare API

Getting consumption is not part of it I’m afraid. I trust library (this one and others) will evolve and new possibilities will arise as viessmann opens its API platform.

I’m very interested too in getting consumption, will post here when it becomes available.

I’m also a user of Viessmann Smart Climate, if someone has information to share on how to get temperature and settings not from the Heating only but also from the Rooms associated with the heating ??

Getting temperature reading from a room is no problem within openHAB, however getting such a (non-Viessmann) reading into the heating-system would by nice. Although I doubt Viessmann will ever open such a door.

API documentation

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

Seams the library from thetrueavatar has consumption tracking capabilites. Will try this week and revert.

I did a quick test drive, you can get gas consumption from thetrueavatar libraries

Here is what you get for a week

HotWater
array(8) { [0]=> int(1) [1]=> float(2.8) [2]=> float(1.5) [3]=> int(0) [4]=> int(0) [5]=> float(1.6) [6]=> float(2.9) [7]=> int(2) }
Heating
array(8) { [0]=> float(2.1) [1]=> float(6.5) [2]=> float(5.9) [3]=> float(7.3) [4]=> int(9) [5]=> float(9.1) [6]=> float(9.4) [7]=> float(9.7) }

If you need guidance on how to integrate this library in openhab see above post referencing

What I was referring to is Viessmann Smart Climate, where you have smart heating valves

image

I’m searching to get each valve data loaded in openhab for reporting, graphing, etc…

Exemple of one valve entity:

 [9]=>
            object(TomPHP\Siren\Entity)#1459 (6) {
              ["classes":"TomPHP\Siren\Entity":private]=>
              array(1) {
                [0]=>
                string(12) "model.device"
              }
              ["properties":"TomPHP\Siren\Entity":private]=>
              array(12) {
                ["gatewaySerial"]=>
                string(16) "<MASKED>"
                ["id"]=>
                string(23) "zigbee-ccccccfffe1f7c4b"
                ["boilerSerial"]=>
                NULL
                ["boilerSerialEditor"]=>
                NULL
                ["bmuSerial"]=>
                NULL
                ["bmuSerialEditor"]=>
                NULL
                ["createdAt"]=>
                string(24) "2021-02-04T18:57:12.507Z"
                ["editedAt"]=>
                string(24) "2021-02-04T18:57:12.507Z"
                ["modelId"]=>
                string(19) "E3_RadiatorActuator"
                ["status"]=>
                string(6) "Online"
                ["deviceType"]=>
                string(6) "zigbee"
                ["roles"]=>
                array(2) {
                  [0]=>
                  string(3) "trv"
                  [1]=>
                  string(12) "zigbeeDevice"
                }
              }
              ["links":"TomPHP\Siren\Entity":private]=>
              array(0) {
              }
              ["title":"TomPHP\Siren\Entity":private]=>
              NULL
              ["actions":"TomPHP\Siren\Entity":private]=>
              array(0) {
              }
              ["entities":"TomPHP\Siren\Entity":private]=>
              array(0) {
              }
            }

This is how to get valve temperature.

https://api.viessmann-platform.io/iot/v1/equipment/installations/<installationID>/gateways/<gatewayID>/devices/zigbee-<zigbeeID>/features/cs.sensors.temperature

Others of interest

cs.sensors.humidity
device.roomId
device.heatingCircuitId
device.power.battery

Does anyone got the PyViCare tool working on a Raspberry PI?

Not PyViCare but my openHAB instance is running on a RaspPi and I’m actually using the Viessmann API via rules:

Looked at the PyViCare code, at least the used settings for apiURLBase and redirect_uri are not looking as documented by Viessmann. Using this apiURLBase I was not able to send a command to my system, using the documented URL it worked.

Hi, everyone.

I have good news. A new binding for Viessmann is available in the SmartHomeJ project.

On oh3.2 there is a new way to install 3rd party addons. You just need to add this: https://download.smarthomej.org/addons.json

Then you can install the binding. It is currently still under development. If some features are not available please let me know.

Best regards,

Ronny

1 Like

Great news. Is there already any documentation ?

You can find the general documentation of the SmartHome/J project here: https://github.com/smarthomej/addons

and here:
https://docs.smarthomej.org/

or the documentation of the binding here on GitHub:
https://github.com/smarthomej/addons/tree/3.2.x/bundles/org.smarthomej.binding.viessmann

1 Like

Thank you! Great work!

With the new version of the binding the “viessmann device”-thing (Device Id = 0) does not get online.
Before it was working and I was able to read out the values of my heatpump.
Here is the error-message:

java.lang.IllegalArgumentException: Invalid Quantity value: 2094.4 null

viessmann.txt (3.2 KB)

Another question is:
Does the binding also support the control?
I could not get this working till now.

The version 3.2.10 is broken since support of uom.
A PR is with the fix is in progress. You can download the new version here:
https://jenkins.smarthomej.org/job/SmartHomeJ%203.2.x%20Snapshot/lastSuccessfulBuild/org.smarthomej.addons.bundles$org.smarthomej.binding.viessmann/artifact/org.smarthomej.addons.bundles/org.smarthomej.binding.viessmann/3.2.11-20220121.033935-9/org.smarthomej.binding.viessmann-3.2.11-20220121.033935-9.jar

You also have to download the commons JAR here: https://jenkins.smarthomej.org/job/SmartHomeJ%203.2.x%20Snapshot/lastSuccessfulBuild/org.smarthomej.addons.bundles$org.smarthomej.commons/artifact/org.smarthomej.addons.bundles/org.smarthomej.commons/3.2.11-20220121.033037-9/org.smarthomej.commons-3.2.11-20220121.033037-9.jar

At first deinstall the binding. After this put at first the commons jar into the addons folder. Wait 1-2 minutes and then put the binding into addons folder.

Never install two versions of a binding.

Yes it supports control. What do you want to control?
Maybe I can assist.

I get this error :

HANDLER_INITIALIZING_ERROR

Illegal character in query at index 104: https://iam.viessmann.com/idp/v2/authorize?response_type=code&client_id=xxxxxxxxxxxxxx&code_challenge=xxxxxxxxxxxxxx&redirect_uri=http://localhost:8080/viessmann/authcode/&scope=IoT%20User%20offline_access

where is the mistake??

I did. New addons are active:

openhab> la -l|grep smarthomej
296 x Active   x  80 x 3.2.11.202201210329     x file:/usr/share/openhab/addons/org.smarthomej.commons-3.2.11-20220121.033037-9.jar
297 x Active   x  80 x 3.2.11.202201210339     x file:/usr/share/openhab/addons/org.smarthomej.binding.viessmann-3.2.11-20220121.033935-9.jar

Bit still the samer error. Some data can not be parsed correctly…

Exception occurred while initializing handler of thing 'viessmann:device:96afd7d3df:0': Invalid Quantity value: 2098.1 null

@nikos7179
Everything seems right. Pleas PM me the complete log in TCRACE mode.

log:set TRACE org.smarthomej.binding.viessmann

@Tuny I‘ll check it later. I need some time. You‘ll get response soon

ok i found the mistake. i think it was wrong my Client ID.
now it is online but i have the same error like @Tuny

2022-01-21 18:19:24.566 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing ‘viessmann:device:acac21cdf6:0’: Invalid Quantity value: 11.4 null

java.lang.IllegalArgumentException: Invalid Quantity value: 11.4 null