CrunkA3.ViessmannClient 2.4.1

dotnet add package CrunkA3.ViessmannClient --version 2.4.1                
NuGet\Install-Package CrunkA3.ViessmannClient -Version 2.4.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CrunkA3.ViessmannClient" Version="2.4.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CrunkA3.ViessmannClient --version 2.4.1                
#r "nuget: CrunkA3.ViessmannClient, 2.4.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CrunkA3.ViessmannClient as a Cake Addin
#addin nuget:?package=CrunkA3.ViessmannClient&version=2.4.1

// Install CrunkA3.ViessmannClient as a Cake Tool
#tool nuget:?package=CrunkA3.ViessmannClient&version=2.4.1                

NuGet .NET .NET

ViessmannClient

Based on PhilipDaubmeier.ViessmannClient

This class library provides a way to call the Viessmann Developer Portal API. It encapsulates all authentication, retry and parsing logic and provides a strongly typed method interface for reading all details of an installation as well as all setting and sensor values of devices.

NuGet

PM> Install-Package CrunkA3.ViessmannClient

Usage

For getting access to Viessmann APIs, first register on the Viessmann Developer Portal and create a client via "API Keys", which will generate a client id for you and lets you set one or more redirect URIs.

To then use this library, you have to implement the interfaces IViessmannAuth and IViessmannConnectionProvider<T> to provide the Viessmann webservice clients with all information necessary to authenticate and establish a connection.

The minimal viable example for playing around with the client would be to create a connection provider and generate the login form uri as shown here:

var auth = new ViessmannAuth();
var viessmannConnProvider = new ViessmannConnectionProvider<ViessmannPlatformClient>(auth)
{
    ClientId = "<clientId>",
    RedirectUri = "http://localhost:4000"
};

var client = new ViessmannPlatformClient(viessmannConnProvider);
var uri = client.GetLoginUri();

Console.WriteLine($"Login here: {uri.AbsoluteUri}");

For playing around you can now copy the uri that was written to the console into a browser and log in there. The browser will then redirect to a page that does not exist and will show a "page not found" message. Just use the part after ?code= in the browser address bar and input it into the program, which is shown in the following.

Console.WriteLine("After logging in you should be redirected to a non-existent page.");
Console.WriteLine("Enter the code you see in the browsers address bar behind '?code=':");
var code = Console.ReadLine();
await client.TryCompleteLogin(code);

After this step, the auth object will contain a valid access token and also a refresh token. The refresh token can be permanently persisted and loaded after each startup and will automatically be used for refreshing the access token if expired.

Note: in a productive use you will want to launch the login uri in an embedded browser view or redirect to this uri in case of a web application. After sucessful login either capture the resulting uri from the embedded browser or use a productive callback API on your server side.

With being logged in sucessfully and having a valid refresh token in the auth object, you can now go ahead and use the library to actually traverse through installations, gateways and devices and finally query for data on the Viessmann API:

// Get the first installation, gateway and device id of the logged in user
var installationId = (await client.GetInstallations()).First().LongId;
var gatewayId = (await client.GetGateways(installationId)).First().LongId;
var deviceId = (await client.GetDevices(installationId, gatewayId)).First().LongId;

// Get sensor values
var features = await client.GetDeviceFeatures(installationId, gatewayId, deviceId);
var outsideTemp = features.GetHeatingSensorsTemperatureOutside();
var boilerTemp = features.GetHeatingBoilerTemperature();
Console.WriteLine($"Outside temp: {outsideTemp} °C, boiler temp: {boilerTemp} °C");

For more usage examples you can also have a look at the unit tests.

A full list of status and sensor values of devices can be found in the DeviceFeatureList class and in the Viessmann Developer Portal, "IoT Features", chapter "List of features".

Platform Support

ViessmannClient is targeted for .NET 6.0 or higher.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.1 282 4/16/2023
2.4.0 168 4/16/2023