IHC sdk/api for .NET

This is a library for connecting to the IHC controller using .NET.  LK (the manufacture for the IHC controller) has not made any sdk or api documentation available. This library has been made by looking at the communication from the ihc applications to the controller. The url’s for the wsdl was found and from these the .net Web References has been made.

Were can I get the library?

The IHC SDK for .NET is available from nuget under the name “Dingus.IHCSdkWR”.

In Visual Studio right click your project and select “Manage nuget packages..” then search for Dingus.IHCSdkWR.

How does this work

The IHCSdkWR library implements the soap connection to the IHC controller and the soap services available on the controller.  Each soap service is exposed as a property on the IHCSoapClient object if you want  to access then directly. To make it easier to use, some of the must common functions has been wrapped to functions directly on the IHCSoapClient object. The usage of these will be described below.

The soap connection are made using C# Web References (That is why the Library has WR in the end of the name). I did make a first version using the newer service references, but has problems getting this to run on mono raspberry. Yes IHCSdkWR will run on raspberry pi 🙂

The IHC soap service uses long polling (A request that will wait until there are changes) to notify the client of changes to resources. To make this easier you can use the IHCController object. This implements a notification thread to handle the long polling.

How to use the library

Authentication & Disconnect

You code should always start by creating an IHCSoapClient object (or IHCController) – authenticate with the controller, do you stuff and when done you disconnect from the controller:

IHCSoapClient ihc = new IHCSoapClient(""); 
if ( ! ihc.Authenticate("myusername", "mypassword")) {
  Console.WriteLine( "Authentication failed");

I am not sure how important the disconnect is, but it is probably a good idea always to do it since each Authenticate will make a new session on the IHC controller and there must be some limit of how make the controller can handle. The IHCController will end the notification thread on disconnect – see more below.

Getting a runtime value

IHCSoapClient wraps 3 functions to get runtime values for bool, integer and float. Here is and example of how to get a bool value

bool value = ihc.GetRuntimeValueBool( 1234); 

Setting a runtime value

Setting a runtime value is as easy at getting – again there a 3 functions for bool, integer and float.

ihc.SetRuntimeValueBool( 1234,true);

If you want to get/set value of other types – you will have to use the soap service functions directly.
(These are located on the “ResourceInteraction” service object).

Notification on resource changes

If you want to be notified when a resource changes you can setup a callback function to be called when the resource changes like this

ihc.RegisterNotify( 1234, ( int id, object v) => {
 Console.WriteLine(id.ToString() + " -> " + v.ToString()); Console.WriteLine(id.ToString() + " -> " + v.ToString());
//wait or do something else ...

For simplicity here it has been done as an inline function, but if you have more than one resource you can use the same function.  Call RegisterNotify for each resource id, and StartNotify when you are ready to be notified.

Download complete example

You can see a simple example here on github

For a more complete example see the IHC MQTT Gateway

IHC Resources ids

You can find ihc resource ids by looking in the IHC project file – it is a XML file.
An easier way is to use my IHC Alternative Service View application

In this application you can see a tree view of you your installation, expand and click the resource and get the id.


See the license page

One response to “IHC sdk/api for .NET”

  1. Torben says:

    Hej Jens,

    I have been playing with your library and would like to encourage you to open source it on github to let people contribute and possibly port it to other platforms too. I am working on OO mapping the insane XML that is returned by the controller.

    Thanks for your efforts anyway.

Leave a Reply

Your email address will not be published. Required fields are marked *