There is an officially supported binding here. It requires the Mochad daemon which works with the CM15A and CM19A controllers so I don’t know if it will be much help for you.
There is a discussion about adding X10 to openHAB here. One of the posts is for a CM11a compatible binding on this discussion but it looks like it was abandonded as it could not be made to work reliably on Windows.
The last posting on this thread has a solution if you are running on Windows with Active Home Pro installed. If Misterhouse can be triggered through an API or from the command line (i.e. trigger switches, read sensors, etc) you can use the appropriate binding for the API (e.g. HTTP) or the Exec binding to call scripts. That is what this Active Home Pro solution is based on.
Beyond that the most I can find it to work through the Insteon PLM.
Another person posted how they created an Arduino gateway to bridge between X10 and probably MQTT (didn’t say what protocol they used) to communicate with openHAB.
I think X10 is very possible, but you may need to interact with an intermediary.
For the most part, X10 is mainly popular in the US and the majority of the developers and maintainers are in Europe so to add X10 to openHAB will require a developer with lots of X10 devices and some Java experience to code it up.
I have been testing OH with misterhouse. As MH can read/write X10 great, I was thinking of using that as a device controller. I can easily enough send an HTTP command to MH to turn on or off a light, but I need to be able to send the state of a light back to OH.
I was thinking of using OH as a server, and MH can send OH data like “Living_Room_Lamp=on”, but I don’t know how to set it up in OH. I was thinking it would be like:
If you can get MH to make HTTP GET, PUT, and POST calls, just have it use OH’s REST API. If you do this you only need set up the Item without a binding and MH, or something MH calls will update and/or command the Items directly.
Alternatively you can set MH up to publish to MQTT and OH to subscribe to MQTT and issue messages and commands that way.
Personally, I’ve only resort to tcp as a very last resort.
You can see an example script where I publish GPIO states and receive commands for GPIO states over MQTT here which might provide some inspiration. There is at least one Perl MQTT client library in CPAN
If you still prefer TCP, see the wiki page for the TCP binding:
The big design piece will be setting up the REGEX to parse out the incoming Strings and assign the correct value to the correct Item. For example:
Thanks for the info. For now I would like use TCP as I know how to send the info from MH already. What I can’t figure out is how to start the server on the OH2 side. I get no activity that I can find in the logs that any thing is happening. On the MH side it fails with “connection refused” I will do more reading on the configuration.
I’ll forewarn you that the TCP binding is one of the more difficult to get working in OH 2.
I believe you have to edit the start script of OH so it will be able to start up the server thread to start listening. I don’t use this binding though (MQTT was soooooo much easier to get working from both sides) so am not sure.