Controlling openHAB with your voice / HSBType NullPointerException

Hi,
i found the Wiki entry “Controlling openHAB with your voice” It works fine, until the RGB part.

  } else if (command.contains("rot")) {
        newState = new HSBType(new Color(255, 0, 0));
    } else if (command.contains("blau")) {
        newState = new HSBType(new Color(0, 0, 255));
    } else if (command.contains("weiß")) {
        newState = new HSBType(new Color(255, 255, 255));
    }

When i place the voice command “licht flur rot” i recived.

2016-03-09 06:17:15.331 [INFO ] [openhab.model.script.Voice.Rec] - VoiceCommand received licht flur rot
2016-03-09 06:17:15.348 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Voice control'
java.lang.NullPointerException: null
	at org.eclipse.xtext.common.types.util.JavaReflectAccess.getRawType(JavaReflectAccess.java:107) ~[na:na]
	at org.eclipse.xtext.common.types.util.JavaReflectAccess.getConstructor(JavaReflectAccess.java:90) ~[na:na]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateConstructorCall(XbaseInterpreter.java:511) ~[na:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_79]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_79]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_79]
	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_79]

Does anybody now what happen ?

Thanks regards Mario

  1. Did you import org.openhab.core.library.types.HSBType?
  2. Could you instead use HSBType::RED, HSBType::BLUE and HSBType::WHITE?

Hello Watou,

thanks for the reply.

Point 1 Yes/No - i have imported import org.openhab.core.library.types.*

to 2 - tried HSBType::RED instead of HSBType(new Color(255, 0, 0)) and got following

2016-03-09 18:51:01.914 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Voice control': index=0, size=0

In the meanwhile, i use this command to got an working rule.

if (command.contains("rot")) {
                        // Wenn eine Farbe angesprochen wird, dann RGB
                itemType = "beleuchtung_rgb"
                        // und entsprechende Farbe
                        itemSubType = "_rot"
                }

Thanks regards Mario

That might be the winner of the award for most obscure, least helpful error message ever. Glad you got it working another way!