It is been a while since @halloween posted a nice solution to get the values from the incoming call in on a Fritzbox here:
As this is a connected topic I like to mention it here, but think I start a new one because of a different issue. I seem to have some issues with a working Fritzbox rule. I started to switch to another val definition which works great, but sometimes I get this error at an incoming call. The funny thing is, at the next call the rule works again as expected without the error… since upgrading to 2.2 I get occassionally this error message and no caller identification…:
2018-01-05 21:22:55.732 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Eingehender Anruf': Index is out of range
Here is the rule based on various great input from this community:
rule "Eingehender Anruf"
when
Item fboxRinging changed to ON
then
// Read Data of Calltype
val callerNumber = fboxIncomingCall.state.toString.split(',').get(1)
val incCall2 = fboxIncomingCallResolved.state as StringListType
val LastCallName = incCall2.getValue(1)
val CallTo = fboxIncomingCall.state.toString.split(',').get(0)
// Remove own number from the variables
LastCallName = LastCallName.removeStart("123456")
// Check if caller is unknown
if(LastCallName.startsWith("Name not found for"))
{
// Update Name with Unbekannt
LastCallName = "Unbekannt"
}
// Update Caller data into Sitemap items
fbLastNumber.postUpdate(callerNumber)
fbLastName.postUpdate(LastCallName)
logInfo("RuleLastCaller", "Der Anruf von " + callerNumber + " (" + LastCallName + ")" + " an die Nummer " + CallTo + " wurde als Letzter Anrufer gespeichert.")
if (callerNumber == "017212345") {
sendTelegram("mygroup", "mymessage!")
}
end
I get two validation issues when refreshing the rule:
Assignment to final variable
But I have no glue why this in 2.2 works sometimes and sometimes not.
Are you guys probably aware of any changes in 2.2 that could have impacted this rule?
@namraccr, I changed LastCallName to var as I change this one, the rest is values I do not modify. However I keep getting the error message from time to time (Index out of range). No validation issues though while loading the rule.
I only see three candidates for where the out of range error could be originating. They’re each of the lines above that end with get(X) (or getValue(X)).
To narrow it down, you could log out the values that each of the get operations is using as input.
Thing is, i also have this Setup and I narrowed it already down to the “StringListType”, when “unknown” caller is in the list.
val incCall2 = fboxIncomingCallResolved.state as StringListType
val LastCallName = incCall2.getValue(1)
val CallTo = fboxIncomingCall.state.toString.split(',').get(0)
if there’s a unknown caller, the incCall2.getValue(1) runs into an NPE, because, there is not (1), only (0).
I didn’t find out, how to call/count/whatever a StringlistType. Neither .Count, nor .List, … worked for me… So the rule always breaks at that.
if there’s no way to get the Count of a StringListType, we have to rewrite the rule into Splitting a .toString - but I’d like to avoid that.
I have a bit different observations so far, as I get the error also with known numbers. But I followed the recommendation from @namraccr to replace the val definitions with var definition. Did so also for the other two variables (not just last caller name). I’ll keep watching the error log
@namraccr I changed every value to var removed all val definitions but still get this irregular out of range errors… haven’t yet logged out the values…