Hi, I am trying to set up an MQTT controlled LED strip analogue to https://github.com/openhab/openhab/wiki/Samples-Rules#how-to-use-colorpicker-widget-with-knxdali-rgb-led-stripe
I don’t think I changed anything but the variable names in my code:
import org.openhab.core.library.types.*
var HSBType BH_Livingroom_hsbValue
var String BH_Livingroom_redValue
var String BH_Livingroom_greenValue
var String BH_Livingroom_blueValue
rule "Set BH_Livingroom_RGB value"
when
Item BH_Livingroom_RGB changed
then
hsbValue = BH_Livingroom_RGB.state as HSBType
BH_Livingroom_redValue = BH_Livingroom_hsbValue.red.intValue.toString
BH_Livingroom_greenValue = BH_Livingroom_hsbValue.green.intValue.toString
BH_Livingroom_blueValue = BH_Livingroom_hsbValue.blue.intValue.toString
sendCommand( BH_Livingroom_LedR, BH_Livingroom_redValue )
sendCommand( BH_Livingroom_LedG, BH_Livingroom_greenValue )
sendCommand( BH_Livingroom_LedB, BH_Livingroom_blueValue )
end
However, I get
2016-09-07 21:09:27.490 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Set BH_Livingroom_RGB value': org.eclipse.xtext.util.PolymorphicDispatcher$NoSuchMethodException: Couldn't find method ''_assignValue'' for objects [JvmVoid: (eProxyURI: bh_livingroom_rgb.rules#xtextLink_::0.2.0.2.0.0::0::/1), <null> hsbValue <XCastedExpressionImpl>, 4.096385542168675,97.6470588235294,100, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@59cf8bff, org.eclipse.xtext.util.CancelIndicator$1@26a7d4e0]
I have no idea what is wrong here.
Also, I need the reverse channel, since the device can be controlled from other sides. For this purpose, it reports it’s state to an MQTT topic. I set autoupdate to false for the items and configured the back channel. How do I set up the rule, though? It is not quite clear to me how to work with the HSBType variable (and why the values are cast to String in the forward rule).
These are the items:
Dimmer BH_Livingroom_LedR "LED Red" <dimmer> (All) { mqtt=">[home-le:home-le/bh/livingroom/light/indirect/r/cmd:command:*:default],<[home-le:home-le/bh/livingroom/light/indirect/r/state:state:default]", autoupdate="false", sendFrequency="200" }
Dimmer BH_Livingroom_LedG "LED Green" <dimmer> (All) { mqtt=">[home-le:home-le/bh/livingroom/light/indirect/g/cmd:command:*:default],<[home-le:home-le/bh/livingroom/light/indirect/g/state:state:default]", autoupdate="false", sendFrequency="200" }
Dimmer BH_Livingroom_LedB "LED Blue" <dimmer> (All) { mqtt=">[home-le:home-le/bh/livingroom/light/indirect/b/cmd:command:*:default],<[home-le:home-le/bh/livingroom/light/indirect/b/state:state:default]", autoupdate="false", sendFrequency="200" }
Color BH_Livingroom_RGB "RGB Light" <slider>