Send Color Command to Tradfri Bulb

Hello,

today i “installed” the Ikea Tradfri Binding on my Openhab3 and also added my Color Lightbulbs.
Now i want send a “color” to Bulb but it is not working.

The Channel hast Type - “Color” and i have 3 Sliders for HSB and they are working.
So i want to create a rule to set the Bulb to specified color.

So wenn I try to send in a script:

StehlampeWohnzimmer_Color.sendCommand(ON)

this works.

but

StehlampeWohnzimmer_Color.sendCommand(new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)))

nothing happend

so i tryed in the console with:

openhab:send StehlampeWohnzimmer_Color (new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)))

but i always get:

Error executing command: HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)) cannot be found by org.apache.karaf.shell.core_4.3.1

what am i doing wrong here? or is this the wrong command?

The item didn’t change states, but something probably happened. If you don’t get the result you are expecting, always check your logs to see what did happen instead. In this case, most likely, you would have found some sort of indication that the sendCommand function can’t handle an HSBtype input very well. sendCommand tends to work best when you give it a string input and let it work out how best to represent that as a command.

To get your desired HSBtype as a string all you need to do is add .toString to the end:

StehlampeWohnzimmer_Color.sendCommand(new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)).toString)

That’s getting a little convoluted and hard to read, however, so for better readability I might split that into a variable and then a command:

var lampColor = new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67))
StehlampeWohnzimmer_Color.sendCommand(lampColor.toString)
1 Like