Categories

Keywords

IHC Soap client for esp8266

This is a library to make soap requests to the IHC controller from an esp8266. I am using this library in my DingSwitch project. It implements a limited set of the soap requests: authentication, get and set runtime values and notification.

Download

The library is included in the arduino library manager, so you can install it directly from the arduino IDE.

The library can also be downloaded here from github:

https://github.com/dingusdk/esp8266IHCSoapClient

How does it work

The soap functionally to has been hard coded into regular http requests - no fancy soap library to do the stuff. This is because of the limited memory of the esp8266. The parsing of the soap xml response is also very primitive, but it work. The library implements:

See the examples folder. To make the examples work you should modify the settings.h file with you wifi and ihc settings.

The tricky part here is the notification, because this should be done with the “waitForResourceValueChanges” soap function using long polling. To make this possible the HTTPClient has been modified to make a request where it does not wait for the response.

A callback function is registered with the IHCSoapClient.WaitForResourceValueChanges function, and you enable notification for a resource id using the IHCSoapClient.EnableRuntimeValueNotifications function. You may call the EnableRuntimeValueNotifications multiple time if you want to be notified for more then one resource.

Within the loop function you must call HandleLoop. See the “notify” example.

void loop() { 
  if ( ! IHCSoapClient.HandleLoop()) { 
    // Redo ihc setup in 30 sec 
    // Authenticate, 
    // EnableRuntimeValueNotifications 
    // WaitForResourceValueChanges } 
  }
}

For testing you can ignore the return value of HandleLoop, but if you want to make something that is more stable (handling when the ihc session is lost), you should check the return value of HandleLoop and when false you should wait some time (I use 30 sec), and the reinitialize the ihc setup.

Note: Currently only boolean resources are supported for notification.

The library also have a function to get the project file from the IHC controller, but since the project file is usually too big to be handled in the limited memory available of an esp8266, it should be done client side in the browser. The GetProject will stream the response directly to a WifiClient. I will not go more into details how that is done - this could be a separate post of it own.

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.

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.

Hello I have been using this library and it is awesome but i've encountered a problem that it not deleting the previous recieved and hence the free heap gets lower and lower on memory untill te system crashes. can you tell me how can i resolve this problem?There is a leak when the GetRuntimeValueXXX functions are failing (When the controller responds anything else than status code 200). I have fixed this leak and updated the libraryHej Jens Tusind tak for dit store arbejde med alle dine librarys. Har du en idé om hvad der skulle til at få din IHC soap client til at virke på en ESP32 i stedet? Jeg bruger et library der hedder HomeSpan til at lave en Apple HomeKit bro til at styre udgange på IHC'en, og ESP8266'eren er ikke kraftig nok til denne. Kan du muligvis pege mig i den rigtige retning?Der er ikke noget i det, som er specielt til esp8266, det burde også kunne compilere til esp32Umiddelbart bruger din HTTPClientEx.h et library der hedder ESP8266HTTPClient.h Jeg har prøvet an ændre den til HTTPClient.h og den kan også compile men det ser ikke rigtig ud til at virke. Jeg kan godt få det til at virke på en ESP8266.Eller det vil sige jeg har faktisk været nød til at downgrade til ver. 2.7.3 i Boards Manager for at kunne compile den på ESP8266.Ok, det er ca 5 år siden jeg lavede det. Jeg kommer ikke til at bruge tid på at opdatere det - jeg bruger det ikke selv mere. (Alt er idag i Home assistant og til esp8266/Esp32 bruger jeg esphome)
(c) 2010-2023 dingus.dk