Categories

Keywords

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("http://192.168.1.3");
if ( ! ihc.Authenticate("myusername", "mypassword")) { 
  Console.WriteLine( "Authentication failed"); 
}
...
ihc.Disconnect();

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()); 
}); 
ihc.StartNotify(); 
//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.

License

See the license page

Comments

The comments below has been imported from the old website. Currently comments are readonly, meaning you can not make new comments. You will be able to do that when it is ready. For now if you want to get in touch, you can send me an email. If you have problems with something that has a github repository, please make a github issue.

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.Hej Jens, Kan din sdk/api for .NET komme til at virke med .NET Core ? P.S. Hvis du lagde koden op på github, kunne vi andre måske hjælpe ? Mvh MortenDet er lavet med "Web References" fra wsdl filerne i IHC. Det var ikke muligt da jeg lavede det at bruge .Net Core, fordi soap gemmem web references ikke var understøttet. Det kan have ændret sig siden - der er sket meget med .NET core. Jeg har ikke tid til at kigge på det nu, men det kommer på min todo list. Her har du wsdl url'erne hvis du selv vil forsøge: ihc/wsdl/authentication.wsdl ihc/wsdl/configuration.wsdl ihc/wsdl/controller.wsdl ihc/wsdl/messagecontrollog.wsdl ihc/wsdl/module.wsdl ihc/wsdl/notificationmanager.wsdl ihc/wsdl/resourceinteraction.wsdl ihc/wsdl/timemanager.wsdl ihc/wsdl/usermanager.wsdl Erstat ihc med http://ipJeg bruger Zensehome og vil gerne have home assistant integration hvilket de ikke har mulighed for, men de vil lave en RS485 adgang og ligge api offentlig, vil det være muligt at lave en gateway mellem de 2 systemer som du har lavet med IHC ?Jeg har ingen kendskab til Zensehome, men hvis der er et api med interface til det går jeg ud fra det er muligt.Ser cool ud. Findes der nogen "Wildcard" resourceid, så man kan lytte med på det hele uden at skulle kalde notify en million gange...Nej - Det er ikke noget det er muligt på controlleren mig bekendt. Controlleren har mulighed for at man kan sende en liste af resource id'er, men så vidt jeg husker har jeg ikke lavet en "wrapper" funktion til det (så det må du selv gøre).Tror den er fixet. I powershell kan man skrive $o.ResourceInteraction.getRuntimeValues($o.ResourceInteraction.getAllDatalineInputs().resourceId).value Og det går vildt meget hurtigere end foreach ($res in $o.ResourceInteraction.getAllDatalineInputs()) { $o.ResourceInteraction.getRuntimeValue($res.ResourceId) }Hi, Thanks for your inspiring IHC SDK. I have released a modern .NET 7 SDK for v3.0 controllers. I have released my work as full open source on github, at "https://github.com/mmc41/IHCClientSDK" to better allow for co-operation from the community. I am open to co-operation if you are interested? Sincerely, Morten Christensen / [email protected]
(c) 2010-2023 dingus.dk