Categories

Keywords

IHC MQTT Gateway

As an example to the IHC SDK for .NET I have made a IHC to MQTT gateway. It is actually some old code I made long time ago to interface to a specific home automation system (I think it was domoticz). I have now made it mode general so you can configure the MQTT topics for each IHC resource.

Many home automation system have support for MQTT today, so the MQTT gateway will allow you to connect IHC to these systems. The gateway will also be able to run on a raspberry pi with mono.

If you do not already have a MQTT broker running, look at “mosquitto” it is also available for raspberry pi.

Download

You can download the code for the example from github here:

https://github.com/dingusdk/ihcmqttgateway

If you do not want to compile the program yourself, you can download download it here:

Compiled Ihc MQTT gateway

Configuration

The configuration of the gateway is located in the ihcmqttgateway.conf file. It is a simple text file you can edit in notepad or whatever you like. There are comments in the file explaining what to do. You can define a mqtt topic to map the a IHC resource id and  you can have separate topics for in and out.

By default the programs will look for the ihcmqttgateway.conf file but you can also specify a path to the configuration file as an argument to the program. Syntax:

IhcMqttGateway.exe \[-v\] pathtoconffile

The -v option will log changes from both IHC and MQTT to the output.

Limitations  note

This program is not tested in “production” - I have never used it myself to anything but playing around. There are know limitations like if you send data to an ihc resoruce and the type does not match. Maybe I will improve on it later, or you can do it yourself - you have to code on githut (Just remember to share if you do so)

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.

Super - thanks for sharing.Looks promising :-) what's the delay from an IHC wireless switch is pressed, until a message is sent on MQTT?It is hard to tell the delay, but my guess it is only a few milliseconds because it is barely noticeable. (Add the -v parameter when you start the program – then you will see on the screen when something changes)Have you tried it on Linux (Raspberry)?Yes - it runs on raspberry pi.Hi, I have been playing around with the gateway. But after around 20 sec it looses the connection to the IHC controller but there no errors. Have you had any issues like that? My firmware is: 2.7.220(Jeg er fra Danmark, men skriver på engelsk, så det kan deles med andre) Hi, thanks for this nice gateway. I have it running on a RPi4 with Mone and Mosquitto. Stability will be tested in near future but so far it looks promising. I created an XPath for extracting the configuration data from the *.vis file. With the help of free online XPath testers (like https://www.freeformatter.com/xpath-tester.html) your can upload the *.vis file, enter the XPath expression and get the configuration lines for the gateway. All hardware inputs and outouts are listed. :-) Remember to use Latin-1252 charset to get special/national chars right. The XPath is: for $input in /utcs_project/groups/group/product_dataline/*[string(node-name()) = ("dataline_input", "dataline_output")] return concat( number(replace(replace(replace(replace(replace(replace(substring($input/@id, 4, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 5, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 6, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 7, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 8, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")), if(string($input/node-name()) = "dataline_input") then " <- " else " ", replace($input/../../@name, "/", "-"), "/", replace($input/../@position, "/", "-"), "/", replace(replace($input/../@name, "LK FUGA.*", "Fuga"), "/", "-"), "/", replace($input/@name, "/", "-") )Oops, the directions were switched. I added some ugle XPath more to make to output nicer. This is the updated XPath: for $input in /utcs_project/groups/group/product_dataline/*[string(node-name()) = ("dataline_input", "dataline_output")] return concat( number(replace(replace(replace(replace(replace(replace(substring($input/@id, 4, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 5, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 6, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 7, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 8, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")), if( number(replace(replace(replace(replace(replace(replace(substring($input/@id, 4, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 5, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16*256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 6, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *256 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 7, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) *16 + number(replace(replace(replace(replace(replace(replace(substring($input/@id, 8, 1), "a", "10"), "b", "11"), "c", "12"), "d", "13"), "e", "14"), "f", "15")) >99999 ) then "" else " ", if(string($input/node-name()) = "dataline_input") then " -> " else " ", replace($input/../../@name, "/", "-"), "/", replace($input/../@position, "/", "-"), "/", replace(replace($input/../@name, "LK FUGA.*", "Fuga"), "/", "-"), "/", replace($input/@name, "/", "-") )Hmm, I see that the posted text is processed and changed quite a bit. Replaced quotes are invalid and the bidictional arrow is removed :-( I guess Dingus must help here if an error-free version should be provided.Hi Jacob The comment fields in wordpress has limited formating. It is better to fork the existing github project and make your own changes there, or start a new github project. Then you can make a link to it from your comment here. Note that the IHC MQTT Gateway is not a project I plan to maintain or development further, it was only an example of how to use the IHCSdkWR library. (This was from before I started using Home Assistant) But it is nice to see that you can use it for something.
(c) 2010-2023 dingus.dk