Create Server Connection

Hello,
I have one question: Is it possible to program a server- client system with java. I want to code my own Java program, with this program I want to control my Smart Home. Because of this, I want to create a server-client connection with openHAB, so that when something happens the server(openHab) sends it to the client(Java Programm).
Thank you for your help.

Can your app simply subscribe to an Item using the Rest API in openHAB2 or can it receive command line messages?

Or MQTT?

Or TCP / UDP packets?

1 Like

It can recive commands

You might need to give a little more information before you get any useful replies…

If your java app can receive commands via the command line, then the Exec binding or the executeCommandLine in the DSL rules might be your easiest way forward.


FYI…

1 Like

I want to create an external APP where you can switch some ligths, for example. So I think the best way to do this is to create a server client connection, where the server sends a command (for example: "/item switch ") and the client something like: "/item updatestate ". So my question is can you do this and if yes how and with which commands.

Use the rest api commands in openHAB that is the purpose of the rest api.

1 Like

i know but this is only json and i want a live time update

The existing UI use the REST API to issue live commands and get live status.

If you are stuck with JSON, you can’t use that.

But it would probably be easier for you to write a JSON-to-REST broker than to create some new openHAB service.

I did mention Subscribe, not poll :smile:

1 Like