Share Config + Arduino code - Basic MQTT LED on/off

Hi,

I am wondering if anyone would be able to share their .Sitemap , .Items and arduino code that they use for controlling basic devices such as turning on a LED or relay. Or a Arduino code which acts as a switch and publishes a message to a state topic.

Also, Information on what settings you altered in the MQTT Bindings section of the Openhab.cfg file.

I am having issues getting a arduino to send commands to openhab, although i can open up a new terminal and receive the commands there.

Thanks
Paul

Hello,
i have all this on my old Webspace.
http://blue-pc.net/2014/10/21/nachtlicht-mit-arduino-und-mqtt-ueber-openhab-steuern/
Its all in German but you will understand the sitmap and the sketch.

I hope this helps.
Joerg

Thank you. I think that will help me.

If you just want switches and not dimming values you can look at mine. I am the farthest thing from a programmer so this is a cobbled together hack job with minimal code that works. Arduino with Ethernet shield controlling any number of pins you could want potentially. If somebody smarter than me wants to tell me how to adjust the config (see commented out parts under void callback, copied from Joerg)

https://codebender.cc/sketch:291712

my items per the glorious hack job:
Switch garageLight “Garage Lights” (GF_Garage) {mqtt="<[server:attic/relay1:state:MAP(mqtt.map)],>[server:attic/relay1:command:ON:1],>[server:attic/relay1:command:OFF:0]"}
Switch garageLight2 “Garage Light 2” (GF_Garage) {mqtt="<[server:attic/relay2:state:MAP(mqtt.map)],>[server:attic/relay2:command:ON:3],>[server:attic/relay2:command:OFF:2]"}
Switch garageLight3 “Garage Light 3” (GF_Garage) {mqtt="<[server:attic/relay3:state:MAP(mqtt.map)],>[server:attic/relay3:command:ON:5],>[server:attic/relay3:command:OFF:4]"}

and ridiculous transform in onoff.map
0=OFF
1=ON
2=OFF
3=ON
4=OFF
5=ON