I have several items I want to control by voice, one such item is called “CL_Toggle”. Here’s a simplified version of my rule file.
import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
import java.util.*
rule VoiceEngine
when
Item VoiceCommand received command
then
var State newstate = null
var String typename = null
var String thingname = null
newstate = ON
thingname = "CL"
typename = "Toggle"
logError("Voice.Send", "VoiceCommand: Set " + thingname + "_" + typename + " to " + newstate.toString)
sendCommand(thingname + "_" + typename,newstate)
end
This produces the following error:
Error during the execution of rule 'VoiceEngine': The name '<XFeatureCallImplCustom>.toString' cannot be resolved to an item or type.
or on deleting that particular line
Error during the execution of rule 'VoiceEngine': Could not invoke method: org.openhab.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,org.openhab.core.types.Command) on instance: null
Have I missed something? Using a RPi 2 with OpenHAB v1.8.0
2016-01-15 15:52:34.340 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'VoiceEngine': Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
Which is strange, because newstate is definitely set. thingname + “_” + typename evaluates to CL_Toggle as it should.
I’ve got it working to some extent by using String throughout. Most types seem to readily convert to string so states of HSBType etc just need a .toString.
I thought they should be the same, but on reading documentation sendCommand() defaults to “String ItemName, String Command String” so I don’t have much trouble with this on using strings.