Can't get sample rule for Hue to work

1,404 views
Skip to first unread message

Dries Dokter

unread,
Mar 9, 2015, 1:02:27 PM3/9/15
to ope...@googlegroups.com
Hi all,

I am just starting to discover openHAB. I have my Philips Hue connected to it without problems, that works fine.
To be able to switch on a light in a specific color of my choosing I tried the example on the Hue binding page:

import org.openhab.core.library.types.*  //THIS LINE IS NOT IN THE SAMPLE, I ADDED IT
var DecimalType hue = new DecimalType(240) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
var PercentType sat = new PercentType(100) // 0-100
var PercentType bright = new PercentType(100) // 0-100
var HSBType light = new HSBType(hue,sat,bright)

sendCommand(Color_1, light)
This generates an error: 
Variable 'light' on rule file 'hue.rules' cannot be initialized with value 'org.eclipse.xtext.xbase.impl.XConstructorCallImplCustom@1601a9(invalidFeatureIssueCode: org.eclipse.xtext.xbase.validation.IssueCodes.invalid_generic_argument_types, validFeature: false)': An error occured during the script execution: The name 'hue' cannot be resolved to an item or type.

If I use sendCommand(Color_1, HSBType::RED) instead it works just fine and the light turns red.

What am I missing here?

Dries Dokter

unread,
Mar 11, 2015, 2:53:41 AM3/11/15
to ope...@googlegroups.com
What does work:

cat /opt/openhab/configurations/rules/hue.rules
import org.openhab.core.library.types.*
var HSBType herfstzl = new HSBType("0,0,50")
var HSBType herfstsl = new HSBType("70,100,100")
var HSBType herfstlc = new HSBType("88,100,100")
var HSBType uit = new HSBType("0,0,0")

rule "Herfst scene on"
when
        Item Herfst received command ON
then
        sendCommand(ZonneLamp, herfstzl)
        sendCommand(SchemerLamp, herfstsl)
        sendCommand(LivingColor, herfstlc)
end

Think it would be nice if the sample on the wiki would actually work.....

Klaus Hildner

unread,
Jul 8, 2015, 7:06:07 AM7/8/15
to ope...@googlegroups.com
Hi Dries Dokter,

thanks for spotting and suggesting a fix. But it's a wiki, so you can always jump in yourself, correct things and make it better for others to come.

best regards

Klaus

Reply all
Reply to author
Forward
0 new messages