Turning switch On through VSCode Java

Hello,

I am looking for someone who may have an example of what I need to do. I am using VS code and want to turn on a plug from an exteral app that I have created with a GUI. I imported the cfg workspace and have the items in here, what I need to know is how do I access them and turn the switch on with the java code? Is there a way to import them to the java program or is there something else I need to do? For now I just want to run the code in the main program to just turn on the switch.

Thanks for the help!

image

If it’s an external application you use the REST API. In MainUI go to Developer Tools->API Explorer which brings up interactive docs for the full openHAB REST API. You’ll be making HTTP GET, PUT, and POST requests for the most part. You will also probably want to subscribe to the SSE feed of events to know when Item events happen.

Okay So I got that in but now my issue is when the example is provided it is not in java not will it run in anything other than the “Try it” button. Do you have an example of running a POST command in java to turn soemthing on? This is currently my roadblock. Thanks!

Google is your friend: