FritzBox TR064 Binding - Creation of ESH-Event failed

Everything is working as expected with this binding, exept from the call items.

Call    fboxIncomingCall    "Incoming call: [%1$s to %2$s]"     {fritzboxtr064="callmonitor_ringing" } 
Call    fboxOutgoingCall    "Outgoing call: [%1$s to %2$s]"     {fritzboxtr064="callmonitor_outgoing" }

When an incoming or outgoing call is active, i can see that the binding is recognizing them correct:

19:06:07.837 [INFO ] [xtr064.internal.FritzboxTr064Binding] - Trying to resolve number ************ to name comparing 7 characters
19:06:07.839 [INFO ] [xtr064.internal.FritzboxTr064Binding] - found name match ********* in phonebook by comparing ***********with ********

but then the following error is raised:

19:06:07.847 [ERROR] [ore.internal.events.OSGiEventManager] - Creation of ESH-Event failed, because one of the registered event factories has thrown an exception: Parsing of item state event failed.
java.lang.IllegalArgumentException: Parsing of item state event failed.
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:123)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:106)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createEventByType(ItemEventFactory.java:66)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.events.AbstractEventFactory.createEvent(AbstractEventFactory.java:46)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.internal.events.OSGiEventManager.createESHEvent(OSGiEventManager.java:175)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:161)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:146)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[3:org.apache.karaf.services.eventadmin:4.0.3]
        at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[3:org.apache.karaf.services.eventadmin:4.0.3]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.lang.ClassNotFoundException: org.eclipse.smarthome.core.library.types.ESHCallType cannot be found by org.eclipse.smarthome.core_0.8.0.201604012011
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_65]
        at java.lang.Class.forName0(Native Method)[:1.8.0_65]
        at java.lang.Class.forName(Class.java:264)[:1.8.0_65]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.parse(ItemEventFactory.java:151)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:121)[88:org.eclipse.smarthome.core:0.8.0.201604012011]
        ... 13 more

Has anyone else experienced this problem and knows what the reason could be?

This is clearly a bug and not your fault :slight_smile:

The main reason is that the CallType does not yet exist in Eclipse SmartHome, see https://github.com/eclipse/smarthome/pull/236.

Probably it’s time to get this issue done soon…

Should the problem fixed ?

I have the same error with the newest oh2 version …

2016-11-09 10:20:28.603 [ERROR] [ore.internal.events.OSGiEventManager] - Creation of ESH-Event failed, because one of the registered event factories has thrown an exception: Parsing of item state event failed.
java.lang.IllegalArgumentException: Parsing of item state event failed.
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:123)[100:org.eclipse.smarthome.core:0.9.0.201611041332]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:106)[100:org.eclipse.smarthome.core:0.9.0.201611041332]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createEventByType(ItemEventFactory.java:66)[100:org.eclipse.smarthome.core:0.9.0.201611041332]
        at org.eclipse.smarthome.core.events.AbstractEventFactory.

The CallItem indeed now exists in ESH, what was still missing was to adapt the compatibility layer to correctly map the type. I have just created and merged https://github.com/openhab/openhab-core/pull/73 for this. Could you please test with tomorrows snapshot build to see if the issue is resolved?

I’ve got the same issue. I installed today the new OH2 Snapshot, but the issue is not solved. Any ideas?

I’ve got exactly the same issue with the newest OH2 Snapshot.

Same problem here :frowning:

In the log you can find the same messages with the updated core:

2016-12-01 14:02:51.356 [ERROR] [ore.internal.events.OSGiEventManager] - Creation of ESH-Event failed, because one of the registered event factories has thrown an exception: Parsing of item state event failed.
java.lang.IllegalArgumentException: Parsing of item state event failed.
	at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:123)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:106)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.items.events.ItemEventFactory.createEventByType(ItemEventFactory.java:66)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.events.AbstractEventFactory.createEvent(AbstractEventFactory.java:46)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.createESHEvent(OSGiEventManager.java:175)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:161)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:146)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[3:org.apache.karaf.services.eventadmin:4.0.4]
	at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[3:org.apache.karaf.services.eventadmin:4.0.4]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.lang.NoSuchMethodException: org.eclipse.smarthome.core.library.types.StringListType.valueOf(java.lang.String)
	at java.lang.Class.getMethod(Class.java:1786)[:1.8.0_65]
	at org.eclipse.smarthome.core.items.events.ItemEventFactory.parse(ItemEventFactory.java:152)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	at org.eclipse.smarthome.core.items.events.ItemEventFactory.getState(ItemEventFactory.java:121)[96:org.eclipse.smarthome.core:0.9.0.201611191809]
	... 13 more

Please test again with the latest snapshot - I have recently created this fix, which is by now part of the distro - with this, I was successfully able to use the Call item of the fritzbox (didn’t test fritzboxtr64) binding.

Thank you. It’s looking good. But there are still 2 issues, now:
If the call is over, the following error is shown in the log:

2016-12-02 17:39:33.106 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '' of item fboxIncomingCall with format '%1$s to %2$s': java.util.MissingFormatArgumentException: Format specifier '%2$s'

In the UI i see the state “Err”, if the call is over.

Is that a core issue, too?

The second issue:
In OH1 this rule was working fine, but in the current OH2 Snapshot this rule is not working:

val CallType incCall = fboxIncomingCallResolved.state as CallType
    var callerName = incCall.destNum
    var strTemp = callerName.toString as String           
    postUpdate(fboxlastIncomingCall, strTemp)

In this rule I want to get last caller and put them into an item to show him in the UI. I tried to comment nearly everything out. If only the first line of the rule is implemented (val CallType incCall = fboxIncomingCallResolved.state as CallType), the following error is shown in the log:

2016-12-02 17:53:48.207 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Jemand ruft an': void

I have the same problem. I tried something to get the caller number to an item.

CallType does not exist anymore, you will have to adapt your rule to StringListType instead. Without having tested it, it should be something like:

val incCall = fboxIncomingCallResolved.state as StringListType
val callerNumber = incCall.getValue(0)

I have created https://github.com/openhab/openhab/pull/4858, which adds the binding to the distro as it seems to work in general. For any further issues, simply open an issue for the binding itself, so that it can be addressed.

Now it works, but how can i show the calerNumber as lastcallerNumber in the sitemap? I tried something, but its not shown in the UI.

It’s working, thank you very much! :slight_smile:
It is only the second entry in the StringList. The first is the called number itself. So I implemented incCall.getValue(1) instead of incCall.getValue(0)

@re-vo-lution:
Item (some usefull and some necessary items):
Switch fboxRinging “Telefon klingelt eingehend [%s]” (gFritzbox) {fritzboxtr064=“callmonitor_ringing” }
Switch fboxRinging_Out “Telefon klingelt ausgehend [%s]” (gFritzbox) {fritzboxtr064=“callmonitor_outgoing” }
Call fboxIncomingCall “Eingehender Anruf: [%1$s to %2$s]” (gFritzbox) {fritzboxtr064=“callmonitor_ringing” }
Call fboxOutgoingCall “Ausgehender Anruf: [%1$s to %2$s]” (gFritzbox) {fritzboxtr064=“callmonitor_outgoing” }
Call fboxIncomingCallResolved “Eingehender Anruf: [%1$s to %2$s]” (gFritzbox) {fritzboxtr064=“callmonitor_ringing:resolveName” }

String fboxlastIncomingCall “Letzter Anrufer: [%s]” (gFritzbox)

//Number after tamSwitch is ID of configured TAM, start with 0
Switch fboxTAM0Switch “Anrufbeantworter” (gFritzbox) {fritzboxtr064=“tamSwitch:0”}
Number fboxTAM0NewMsg “Neue AB Nachrichten [%s]” (gFritzbox) {fritzboxtr064=“tamNewMessages:0”}

//Missed calls: specify the number of last days which should be searched for missed calls
Number fboxMissedCalls “Verpasste Anrufe 24h[%s]” (gFritzbox) {fritzboxtr064=“missedCallsInDays:1”}

Rule:
rule "Jemand ruft an"
when
Item fboxRinging changed from OFF to ON
then
val incCall = fboxIncomingCallResolved.state as StringListType
val callerNumber = incCall.getValue(1)
var strTemp = callerNumber.toString as String
postUpdate(fboxlastIncomingCall, strTemp)

//Samsung-TV Ton aus
sendCommand(TV_Mute, ON)      

end

Sitemap:
Text item=fboxRinging
Text item=fboxRinging_Out
Text item=fboxIncomingCall
Text item=fboxOutgoingCall
Text item=fboxIncomingCallResolved
Switch item=fboxTAM0Switch
Text item=fboxTAM0NewMsg
Text item=fboxMissedCalls
Text item=fboxlastIncomingCall

Great, glad to hear!