OpenHab + MQTT setting up rgb color picker

2,970 views
Skip to first unread message

david...@googlemail.com

unread,
Oct 25, 2014, 9:11:23 AM10/25/14
to
Hi I am David,

I have been playing around with home automation stuff for quite a while now.
Everything I automate has a mqtt connection of some kind.
For example I can change the color of a RGB light by sending a mqqt message like "2-6-255-255-255" to a topic "livingroom/ardunio/rc".
Now I want to use openhab as automation and HMI. I managed to turn lights on and of, but that's about it.
My next goal was to integrate the RGB light with the color picker widget. However I CAN'T GET IT TO WORK. I don't seem to understand the process yet.

Can anyone give me a push start? That would be awesome.

Basically I need send that message "2-6-$RED-$GREEN-$BLUE" to topic "livingroom/ardunio/rc" according to the color picker.

I tried:
+++++++++++++++++++++++++++++++++
Item:

Color  RGB_NT "RGB Night Light" <slider>

Number RGB_LED_MQTT {mqtt=">[raspberrypi:livingroom/ardunio/rc:state:default]"} 
Sitemap:

Colorpicker item=RGB_NT icon="slider"

Rule:

rule "Set RGB value"

when

        Item RGB_NT changed

then

        hsbValue = RGB_NT.state as HSBType


        redValue   = hsbValue.red.intValue.toString

        greenValue = hsbValue.green.intValue.toString

        blueValue  = hsbValue.blue.intValue.toString

        

        rgbMqttSring = "2-6-" + redValue + "-" + blueValue + "-" + greenValue

+++++++++++++++++++++++++++++++++++++++


     //   sendState( RGB_LED_MQTT, rgbMqttSring )

        postUpdate(RGB_LED_MQTT, rgbMqttSring )

end


I am looking forward to your gracious help!
Thanks
David

ope...@blue-pc.net

unread,
Oct 25, 2014, 11:55:48 AM10/25/14
to ope...@googlegroups.com
Hallo David,

i build a nightlight with a Arduino UNO and a RGB Strip.
My Website is in German but you can read sourecode from Arduino and the openHAB files.
I have a colorpicker and three dimmer items for each color.
The colorpicker is similar with yours, but i change in the rule the value of each color.
The Binding for each color has its own topic for the coresponding color.
The Arduino reads the three topics and change the color.
Color  flNachtlicht     "Nachtlicht"    <slider> (gNachtlicht)
Dimmer flNachtlicht_R   "Rot [%d %%]"   <switch> (gNachtlicht) {mqtt=">[localbroker:/openHAB/Nachtlicht/RED:state:*:default]"}
Dimmer flNachtlicht_G   "Grün [%d %%]"  <switch> (gNachtlicht) {mqtt=">[localbroker:/openHAB/Nachtlicht/GREEN:state:*:default]"}
Dimmer flNachtlicht_B   "Blau [%d %%]"  <switch> (gNachtlicht) {mqtt=">[localbroker:/openHAB/Nachtlicht/BLUE:state:*:default]"}

I hope this helps.
Sorry for my english.

Joerg

ope...@blue-pc.net

unread,
Oct 26, 2014, 5:24:55 AM10/26/14
to ope...@googlegroups.com
Hello David,

i made a Nightlight with an Arduino. I controll this over openHAB and MQTT. You can see my Sourcecode and the openHAB config on my site blue-pc.net . The site is in German but you can read the sourcecode.
My light use a Topic for each color and the Arduino has a subscription for the three colors.
When i change the colorpicker it writes the value for the three color to Number items which have a binding to mqtt.

Joerg

jkar...@blue-pc.net

unread,
Oct 26, 2014, 5:54:47 AM10/26/14
to ope...@googlegroups.com

David Arenz

unread,
Oct 27, 2014, 3:02:38 AM10/27/14
to ope...@googlegroups.com, ope...@blue-pc.net
Hey Joerg,

thanks a lot for the quick help. That was just what I needed. Sometimes I just need do see some working code, to figure out how to do it.
Nice Website by the way!

Vielen Dank für die Hilfe!
David
Reply all
Reply to author
Forward
0 new messages