Kodi Binding Manual Setup Broken Since Update

So I had recently updated to the OpenHAB 2.2 Build as it included new bindings I needed to work with some of my home automation system. Today I noticed while doing some modifications to my files that the Kodi manual setup I had done in the Things file has stopped working (Auto Discovery works though oddly). For some reason it refuses to set the ports needed and returns with the two following errors in Karaf.

17:50:52.234 [WARN ] [e.smarthome.config.core.Configuration] - Could not set field value for field 'port': Can not set java.lang.Integer field org.openhab.binding.kodi.internal.config.KodiConfig.port to java.lang.String
java.lang.IllegalArgumentException: Can not set java.lang.Integer field org.openhab.binding.kodi.internal.config.KodiConfig.port to java.lang.String
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) [?:?]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) [?:?]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [?:?]
        at java.lang.reflect.Field.set(Field.java:764) [?:?]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) [41:org.apache.commons.lang:2.6.0]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) [41:org.apache.commons.lang:2.6.0]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) [41:org.apache.commons.lang:2.6.0]
        at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:106) [103:org.eclipse.smarthome.config.core:0.10.0.b1]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:284) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at org.openhab.binding.kodi.handler.KodiHandler.getImageBaseUrl(KodiHandler.java:228) [214:org.openhab.binding.kodi:2.2.0]
        at org.openhab.binding.kodi.handler.KodiHandler.initialize(KodiHandler.java:276) [214:org.openhab.binding.kodi:2.2.0]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:228) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
17:50:54.369 [WARN ] [e.smarthome.config.core.Configuration] - Could not set field value for field 'httpPort': Can not set java.lang.Integer field org.openhab.binding.kodi.internal.config.KodiConfig.httpPort to java.lang.String
java.lang.IllegalArgumentException: Can not set java.lang.Integer field org.openhab.binding.kodi.internal.config.KodiConfig.httpPort to java.lang.String
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) [?:?]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) [?:?]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [?:?]
        at java.lang.reflect.Field.set(Field.java:764) [?:?]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) [41:org.apache.commons.lang:2.6.0]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) [41:org.apache.commons.lang:2.6.0]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) [41:org.apache.commons.lang:2.6.0]
        at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:106) [103:org.eclipse.smarthome.config.core:0.10.0.b1]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:284) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at org.openhab.binding.kodi.handler.KodiHandler.getImageBaseUrl(KodiHandler.java:228) [214:org.openhab.binding.kodi:2.2.0]
        at org.openhab.binding.kodi.handler.KodiHandler.initialize(KodiHandler.java:276) [214:org.openhab.binding.kodi:2.2.0]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:228) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
        at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

My current things file uses the this entry for kodi, which according to documentation should be correct (It still accurately gets the username and password, but not the rest).

Thing kodi:kodi:Kodi "Kodi" [ipAddress="192.168.2.102", httpUser="BLANK", httpPassword="BLANK", port="9090", httpPort="8080"]

While auto discovery works and will set the ports correctly (And I can enter the username and password for them), I prefer to use manual setup in the configuration files so if I ever have to rebuild I can do so easily by just dropping in backups of the configuration files. Any help would be appreciated, and if any more information is needed, let me know.

Hi,

Can you please try to change your Thing configuration to use ports without quotes? I will correct the documentation if it works.

Thing kodi:kodi:Kodi "Kodi" [ipAddress="192.168.2.102", httpUser="BLANK", httpPassword="BLANK", port=9090, httpPort=8080]

Yup. That indeed was the issue. Works like a charm now. Thanks.

Sounds good. I’m glad you got it working.

I changed it in the documentation.

3 Likes

Is it possible to add “Kodi State” channel ? Previous xbmc biding has it. May be I am missing something, but I don’t see channel reporting current state - play, pause, stop.

Use the control channel. But be aware that this item will not work with persistence (if you try to persist, you will see an error) because the persistence services are falling behind the times, and need to be upgraded to work properly with OH2.

This will not include stop though… you’ll need a separate item linked to the stop channel for that.

Well I don’t need control channel. I was asking about state channel, string that reports - play, stop or pause. Not switch!

Right now I am using old XBMC binding only for this item. Based on output of “state” I control lights. “If kodi_status changed to play, turn off lights”.

I don’t use OH interface to control kodi, I just need it to read status of player. And once again I was just suggesting to add state channel to this binding.

With the Kodi V2 binding, an item linked to the control channel can be used to control Kodi, but it also provides the current state of the Kodi system. Here is an example of how I use such an item in a rule for controlling the lights where my TV is located:

rule "Light: Family Room"
when
    Item gDS_FamilyRoom_Motion changed
    or
	Item DS_FamilyRoom_Kodi_Control changed
	or
	Item DS_FamilyRoom_Kodi_DimWhenPlaying changed
    or
    Item Outlet6 changed
then
    
    if (gDS_FamilyRoom_Motion.state == ON || (gDS_FamilyRoom_Motion.state == OFF && Outlet6.state == OFF)) { // keep light from turning off if TV is on
        if (DS_FamilyRoom_Kodi_DimWhenPlaying.state == ON && DS_FamilyRoom_Kodi_SystemState.state == ON && DS_FamilyRoom_Kodi_Control.state.toString == "PLAY") {
            actionLight.apply(triggerAction.apply(gDS_FamilyRoom_Motion,true),gKodiFamilyRoom,roomLightLevels.get("gKodiFamilyRoom").get(Mode.state.toString).get("Low_Lux_Trigger"),roomLightLevels.get("gKodiFamilyRoom").get(Mode.state.toString).get("Level"))
        }
        else if (!(Mode.state.toString == "Night" && gDS_FamilyRoom_Bulb.state > 1) || (gDS_FamilyRoom_Motion.state == OFF && Outlet6.state == OFF)) {
            actionLight.apply(triggerAction.apply(gDS_FamilyRoom_Motion,true),gDS_FamilyRoom_Bulb,roomLightLevels.get("gDS_FamilyRoom_Bulb").get(Mode.state.toString).get("Low_Lux_Trigger"),roomLightLevels.get("gDS_FamilyRoom_Bulb").get(Mode.state.toString).get("Level"))
        }
    }
end

Got it! Sorry, it is confusing that channel name is “control”, probably because I used previous biding.

Thank you so much!