Hello OH Community,
I have a rule for dimming my light with a switch, in general it’s working. But sometimes it doesn’t.
These messages appear sometimes in my log:
2017-11-02 21:22:16.008 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'LED Strip higher': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(T,org.eclipse.xtex
t.xbase.lib.Procedures$Procedure1) on instance: null
2017-11-02 21:22:23.095 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'LED Strip higher': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(T,org.eclipse.xtex
t.xbase.lib.Procedures$Procedure1) on instance: null
This is my rule
rule "LED Strip higher"
when
Item Switch_Livingroom_C2_Short changed to ON
then
if ((Light_Livingroom_LEDStrip_brightness.state as DecimalType) => 80) {
Light_Livingroom_LEDStrip_brightness.sendCommand(100)
} else {
Light_Livingroom_LEDStrip_brightness.sendCommand((Light_Livingroom_LEDStrip_brightness.state as DecimalType) + 20)
}
end
Try logging some info first (check the karaf console for output) and get the state value before sending the command, like this:
rule "LED Strip higher"
when
Item Switch_Livingroom_C2_Short changed to ON
then
logInfo("LEDStripStateInfo", Light_Livingroom_LEDStrip_brightness.state.toString)
if ((Light_Livingroom_LEDStrip_brightness.state as DecimalType) => 80) {
Light_Livingroom_LEDStrip_brightness.sendCommand(100)
} else {
var int tempLEDvalue=(Light_Livingroom_LEDStrip_brightness.state as DecimalType).intValue
Light_Livingroom_LEDStrip_brightness.sendCommand(tempLEDvalue + 20)
}
end
rule "LED-Strip brightness increase"
when
Item Switch_Livingroom_C2_Short changed to ON
then
logDebug(filename, "LED-Strip brightness increase triggered - current brightness state: {}", Light_Livingroom_LEDStrip_brightness.state)
if ((Light_Livingroom_LEDStrip_brightness.state as DecimalType) => 80) {
logDebug(filename, "Brightness state higher-equal 80: {}", Light_Livingroom_LEDStrip_brightness.state)
if (Light_Livingroom_LEDStrip_brightness.state != NULL)
Light_Livingroom_LEDStrip_brightness.sendCommand(100)
else
logDebug(filename, "WARNING: Light_Livingroom_LEDStrip_brightness.state is NULL")
} else {
logDebug(filename, "Brightness state lower-equal 80: {}", Light_Livingroom_LEDStrip_brightness.state)
var tempLEDValue = (Light_Livingroom_LEDStrip_brightness.state as DecimalType).intValue
logDebug(filename, "Brightness state: {}", tempLEDValue)
if (Light_Livingroom_LEDStrip_brightness.state != NULL)
Light_Livingroom_LEDStrip_brightness.sendCommand((Light_Livingroom_LEDStrip_brightness.state as DecimalType) + 20)
else
logDebug(filename, "WARNING: Light_Livingroom_LEDStrip_brightness.state is NULL")
}
end
Error does still occur:
2017-11-08 19:44:10.642 [DEBUG] [.model.script.livingroom_light.rules] - LED-Strip brightness increase triggered - current brightness state: 50
2017-11-08 19:44:10.654 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'LED-Strip brightness increase': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(T,org.eclipse.xtext.xbase.lib.Procedures$Procedure1) on instance: null
2017-11-08 19:44:13.170 [DEBUG] [.model.script.livingroom_light.rules] - LED-Strip brightness increase triggered - current brightness state: 50
2017-11-08 19:44:13.184 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'LED-Strip brightness increase': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_doubleArrow(T,org.eclipse.xtext.xbase.lib.Procedures$Procedure1) on instance: null
What r u using to write with?
Eclipse smart home designer will let u know when u have syntax errors like the above and also if u use Ctrl space bar it will also suggest code.