PhilipDaubmeier.ViessmannClient 2.5.0

dotnet add package PhilipDaubmeier.ViessmannClient --version 2.5.0                
NuGet\Install-Package PhilipDaubmeier.ViessmannClient -Version 2.5.0                
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="PhilipDaubmeier.ViessmannClient" Version="2.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PhilipDaubmeier.ViessmannClient --version 2.5.0                
#r "nuget: PhilipDaubmeier.ViessmannClient, 2.5.0"                
#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 PhilipDaubmeier.ViessmannClient as a Cake Addin
#addin nuget:?package=PhilipDaubmeier.ViessmannClient&version=2.5.0

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

NuGet Build status

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 PhilipDaubmeier.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.

Note: also, you may want to implement your own IViessmannConnectionProvider<T> and load your client id and redirect uri from a configuration file and store and load refresh tokens across program restarts. You can have a look at the respective classes in GraphIoT.Viessmann as an example for IViessmannAuth and IViessmannConnectionProvider<T> implemenations with storing/loading of configuration, access tokens and refresh tokens.

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 9.0 or higher.

License

The MIT License (MIT)

Copyright (c) 2019-2024 Philip Daubmeier

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.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.5.0 82 12/2/2024
2.3.0 574 7/15/2021
2.2.0 419 6/27/2021
2.1.0 328 6/23/2021
2.0.0 341 6/21/2021
1.8.2 472 9/16/2020
1.8.1 490 4/17/2020
1.8.0 439 4/14/2020
1.7.1 480 4/9/2020
1.7.0 511 4/9/2020
1.6.0 503 3/29/2020
1.5.0 474 3/23/2020
1.4.0 476 3/22/2020
1.3.0 519 3/21/2020
1.1.0 514 10/16/2019
1.0.0 485 10/8/2019

2.5.0 - upgraded to target framework net9.0
2.4.0 - upgraded to target framework net8.0
2.3.0 - changed data point naming of burners according to Viessmann Developer Portal changelog
2.2.0 - upgraded to target framework net5.0
2.1.0 - changed to new iot/v1 API and new base uri
2.0.0 - upgraded library to be used with official API keys of the Viessmann Developer Portal which went live in May 2021
1.8.2 - fixed parsing issue of message lists
1.8.1 - fixed multi TFM issues
1.8.0 - widened range of supported platforms by targeting netstandard2.1
1.7.1 - bug fixes
1.7.0 - moved to System.Text.Json and removed dependency to Json.NET
1.6.0 - upgraded to target framework netcoreapp3.1
1.5.0 - breaking change: renamed and extended ViessmannPlatformClient interfaces. Added getter methods for strongly typed access of device properties.
1.4.0 - breaking change: refactored ViessmannPlatformClient interface. It returns IEnumerables of respective items.
1.3.0 - breaking change: removed feature specific methods and introduced one-in-all method for querying all sensor values of a device in one request.
1.2.0-beta1 - added support for HttpClientFactory and Polly. Enabled non-nullable reference types.
1.1.0 - migrated to netcoreapp3.0
1.0.0 - Initial version with publishing version 1.0 of GraphIoT