I use a RPI to run an LED-RGB stripe.
Now i want to control that LED-Stripe via OpenHAB using a Colour-picker to choose the colour for the stripe.
on the RPI there is a scritp that expect some input of that form #redvalue,#greenvalue,#bluevalue,#brightness
i tried to use the exec-binding to run the script.
have checked out some tutorials but don’t see how to configurate the items-file
unfortunatly, the exec binding and runing scripts isn’t my problem.
My problem is, how i can make the item send an command
with a switch it is {“ON: …”}
but how ca i manage that with an colorpicker?
how can i translate the inernal system to RGB by that?
i tried it this way:
“color color_led_cinema_binclockLED “Farbe Hintergrundbeleuchtung Binäruhr” (ld_cinema, log) {exec=”>[OFF:/opt/openhab/scripts/LED-RGB-off.sh 0 2] >[ON:/opt/openhab/scripts/LED-RGB-on.sh 0 2 start static 100 100 100 100]"}"
But it didn’t work in any way
for example this as switch works well:
“Switch switch_led_cinema_binclockLED “Schalter Hintergrundbeleuchtung Binäruhr” (ld_cinema, log) {exec=”>[OFF:/opt/openhab/scripts/LED-RGB-off.sh 0 2] >[ON:/opt/openhab/scripts/LED-RGB-on.sh 0 2 start static 100 100 100 100]"}"
I have solved the Problem with a simple Convertion-Rule.
Last Thing to do was using the
"ExecuteCommandLine()" instead of “SendCommand()” as, i found no way to use the exec-binding in a rule
The complete Rule now looks like:
import org.openhab.core.library.types.*
var HSBType hsbValue
var String redValue
var String greenValue
var String blueValue
rule "Set color_led_cinema_binclockLED value"
when
Item color_led_cinema_binclockLED changed
then
hsbValue = color_led_cinema_binclockLED.state as HSBType
redValue = hsbValue.red.intValue.toString
greenValue = hsbValue.green.intValue.toString
blueValue = hsbValue.blue.intValue.toString
executeCommandLine("/opt/openhab/scripts/LED-RGB-on.sh@@0@@2@@restart@@static@@" + redValue + "@@" + greenValue + "@@" + blueValue + "@@100")
end
At the Moment i keep the switch in use to turn the stripe “on” and “off”