HTTP binding with Color item

346 views
Skip to first unread message

Petr Klus

unread,
Mar 11, 2014, 6:38:42 PM3/11/14
to ope...@googlegroups.com
Hi,

I am trying to control my legacy home automation using the HTTP binding. I would like to use RGB light but I am struggling to see what are the right commands to set. I am using following for testing:

Color  IND_LivingRoom_Lamp_RGB "RGB Light" {http=">[INCREASE:GET:http://192.168.2.202:7777/views/nook/light_SET/aa/bb/cc]"}

The code above works and triggers the URL, however, I would like the URL to be triggered on colour wheel change - after digging through the code I found that Color item accepts HSBtype to get hue/saturation etc. passed - exactly what I need.

What I imagine would be the right format:

Color  IND_LivingRoom_Lamp_RGB "RGB Light" {http=">[HSB:GET:http://192.168.2.202:7777/views/nook/light_SET/%1$s/%2$s/%3$s]"}

However, the HSB command does not work and I simply cannot seem to be able to find the right word. I have of course tried * as a command too, however, this does not cause the URL to be hit.

Any help please?

Petr Klus

unread,
Mar 18, 2014, 10:52:40 AM3/18/14
to ope...@googlegroups.com
(Sorry for spam, but BUMP)

Gert Konemann

unread,
Mar 18, 2014, 12:29:53 PM3/18/14
to ope...@googlegroups.com
Petr,

I have no experience with color items, but use the openhab http binding. Maybe some questions can help you on the right track
1. Can you issue http://192.168.2.202:7777/views/nook/light_SET/%1$s/%2$s/%3$s in a browser and does it give the expected reaction ? 
2. Are the procent signs meant as parameter prefixes or as literal escape ?
3. Are the openhab samples maybe helpful for you. See:

Gert

Op dinsdag 18 maart 2014 15:52:40 UTC+1 schreef Petr Klus:

Petr Klus

unread,
Mar 20, 2014, 2:21:47 PM3/20/14
to ope...@googlegroups.com
Thank you very much for the tip! with the help of rules, I was able to get it to work:

import org.openhab.core.library.types.*

var HSBType hsbValue
var String  redValue
var String  greenValue
var String  blueValue

rule "Set RGB value"
when
        Item IND_LivingRoom_Lamp_RGB changed
then
        hsbValue = IND_LivingRoom_Lamp_RGB.state as HSBType

        redValue   = hsbValue.red.intValue.toString
        greenValue = hsbValue.green.intValue.toString
        blueValue  = hsbValue.blue.intValue.toString
                
        sendHttpGetRequest("http://192.168.2.202:7777/views/nook/light_SET/"+redValue+"/"+greenValue+"/"+blueValue)
end


--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/3eD_JR3aHb4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages