Beginner Please Help Arduino, Ethernet, OpenHab,

Hey guys im completely new to the world of home automation and arduino but im trying to get my head around it all (im more hardware than software)
I hope this is okay to post in here and hopefully someone may be able to steer me in the correct direction.

im still learning to code arduino so far i have managed to get basic things happening based purely on i/o pins
what im hoping for is if anyone can help me get over this next hurdle (iv read so much searched etc and im just confusing myself more and more)

what i have so far:
*i have an arduino mega with ethernet sheild
*i have a 16 relay board
*im using a windows 7 pc and have installed openhab and mosquitto onto it
*openhab connects to ios openhab app

where i am lost
*i cannot work out what code or how to get the arduino to communicate with open hab and let me use each i/o set as a different switch etc in openhab

is there any chance anyone has a basic sketch or something with notes that for example would allow the arduino to communicate with open hab and make a switch for led pin 13 to turn on, from that i think i would be able to understand what parts identify the arduino to openhab and what parts identify a switch and output in arduino.
i do plan on using esp8266’s down the track but for now i wish to start with the ethernet

Thanks to any help im given

attached is a crude drawing of my basic idea i wish to start with also i am unsure if my switch idea will work or not at this stage functionally it works, however for eg if i attached a light to the relay i want to be able to have openhab understand which state the light is in, so if i push the button it turns the light on, then if i went into the app on my phone it would know its turned on and id be able to switch it off.

*i cannot work out what code or how to get the arduino to communicate with open hab

The Arduino communicates with the PC via a serial port, using the Serial instance. If "open hab" communicates with a serial port, AND it communicates with the one that the Arduino is listening to, AND you know what the app is sending to the serial port, having the Arduino read and understand the data is not that difficult. Otherwise, it's all but impossible.

If you can't figure out the serial answers, post a link to the software, and perhaps someone else can.

I too am a new Arduino and openhab user. I am doing something similar wanting to control RGB LED strips.

You need to program your Arduino to respond to MQTT. a communication protocol.

Then install a MQTT broker on your Openhab server. A raspberry pi is an energy efficient option.

I am trying currently to figure out how to set up an MQTT ethernet interface for Arduino as I type this.

Then you just drive the Pins based on the MQTT 1-0 (On/OFF) messages.

Others might be able to help with the code for this.

You'll need an IP for the Arduino and one for the MQTT broker.