TR-064 Thing Action phonebookLookup not working

Still cannot get this to work.
TR-064-Bridge Thing UID is:

tr064:fritzbox:dca2683d47

Item/Transform definition is:

Call Fritz_Incoming_Call "Anrufende Nummer [$1$s an %2$s]" { channel="avmfritz:fritzbox:192_168_178_1:incoming_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3Adca2683d47", phoneNumberIndex=1]}

Log still says:

2021-01-27 15:52:45.635 [WARN ] [.internal.phonebook.PhonebookProfile] - Cannot initialize PHONEBOOK transformation profile: UID must have at least 3 segments.. Profile will be inactive.

What am I missing?

@maihacke
I would say you have to change the Item into a String first and use [%s] as “unit formatter” or however this should be called.

See the example:

Hmm, I’m not sure if this addresses the point. The Item definition itself is working (without the profile). The error log, is also related to the profile…

I did some more tests, now the error message is gone. I did not change the item definition, so it was probably some caching/restart issue.
The problem is, that the phonebook lookup is not working, there is no error, but also no named resolved.

Try this. Seems you’re mixing up Calls and Strings, and you have a $ instead of % in your format string.

The incoming call is a string list (so no PHONEBOOK transformation here):

Call Fritz_Incoming_Call "Eingehender Anruf [von %2$s an %1$s]" (gCALLMONITOR) { channel="avmfritz:fritzbox:192_168_178_1:incoming_call" }

The number you try to find a name for is a single string.

String Fritz_Incoming_Call_Caller "Eingehender Anruf - Anrufer [%s]" { channel="avmfritz:fritzbox:192_168_178_1:incoming_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3Adca2683d47", phoneNumberIndex=1, matchcount="8"] } 

No, sadly this doesn’t make a difference.
Items:

/* Fritzbox */
Call	Fritz_Incoming_Call		    "Anrufende Nummer [%s]"      { channel="avmfritz:fritzbox:192_168_178_1:incoming_call" }
String	Fritz_Incoming_Caller	    "Anrufer [%s]"               { channel="avmfritz:fritzbox:192_168_178_1:incoming_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3Adca2683d47", phoneNumberIndex=1, matchcount="8"]}

Rule

rule "Jemand ruft an"
when
    Item Fritz_Ringing changed to RINGING
then
    //Letze Nummer aktualisieren
    logInfo("Telefon", "Jemand ruft an.")

    val incCall = Fritz_Incoming_Call.state as StringListType
    var callerName = "unbekannt"
	var callerNumber = "-"
		
    logInfo("Telefon", incCall.toFullString())
    logInfo("Telefon", Fritz_Incoming_Caller.state.toFullString())
  ...

Log

2021-01-28 07:30:07.882 [INFO ] [rg.openhab.core.model.script.Telefon] - Jemand ruft an.
2021-01-28 07:30:07.897 [INFO ] [rg.openhab.core.model.script.Telefon] - 9868757,01604772820
2021-01-28 07:30:07.908 [INFO ] [rg.openhab.core.model.script.Telefon] - 9868757

As you can see Fritz_Incoming_Caller.state contains the number not the callers name.
How does the binding decide which phonebook to use on the fritzbox? Could it me that it uses the wrong phonebook?

I got it working!

Actually the problem on my side was reading in the phonebook.

@maihacke: You may should check if you have the same problem.

When restarting openHAB or actualizing the Thing, it reads in the phonebook. And when you have entries with the same number twice, it raises an error. I had to adapt two entries of the phonebook until the reading in worked properly. Unfortunately it seems to skip the complete phonebook in such a case and not just only the one entry.

1 Like

That is probably a problem for me also. My phonebook, contains several number more than once. I like to have different contacts with the same number in my phonebook, e.g. persons with different mobile phones living in the same household and therefore the same landline number. I think this is more a bug in the binding, which should be fixed…

Hello to all,
my English is really bad. Sorry for that.
But luckily there is deepl.com

I got it working!
Here is a little tutorial for all of you who use OH3:

You have to install these two bindings: AVM FRITZ!Box Binding & TR-064 Binding

AVM.items

Group gAnrufmonitor “Anrufmonitor” [“Equipment”]
Call FritzEingehenderAnruf “Eingehender Anruf [von %2$s to %1$s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:incoming_call”}
Call FritzAktiverAnruf “Aktiver Anruf [von %1$s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:active_call” }
Call FritzAusgehenderAnruf “Ausgehender Anruf [von %2$s to %1$s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:outgoing_call”}
String FritzAnrufzustand “Anrufzustand [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:call_state”}
String FritzEingehenderAngerufener “Eingehender Anruf - Angerufener [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:incoming_call” [profile=“transform:PHONEBOOK”, phonebook=“tr064_3Afritzbox_3Ad1e06eda99”]}
String FritzEingehenderAnrufer “Eingehender Anruf - Anrufer [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:incoming_call” [profile=“transform:PHONEBOOK”, phonebook=“tr064_3Afritzbox_3Ad1e06eda99”, phoneNumberIndex=1, matchcount=“8”]}
String FritzAktiverAnrufer “Aktiver Anruf - Anrufer [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:active_call” [profile=“transform:PHONEBOOK”, phonebook=“tr064_3Afritzbox_3Ad1e06eda99”]}
String FritzAusgehenderAngerufener “Ausgehender Anruf - Angerufener [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:outgoing_call” [profile=“transform:PHONEBOOK”, phonebook=“tr064_3Afritzbox_3Ad1e06eda99”]}
String FritzAusgehenderAnrufer “Ausgehender Anruf - Anrufer [%s]” (gAnrufmonitor) [“Status”] {channel=“avmfritz:fritzbox:192_168_178_1:outgoing_call” [profile=“transform:PHONEBOOK”, phonebook=“tr064_3Afritzbox_3Ad1e06eda99”, phoneNumberIndex=1, matchcount=“8”]}

IMPORTANT: To be able to read the phonebook, the identifier of the profile (phonebook=“tr064_3Afritzbox_3Ad1e06eda99”) must be adjusted to your ID!

AVM.rules

rule “Eingehender Anruf”
when
Item FritzAnrufzustand changed to RINGING
then
val incCall = FritzEingehenderAnruf.state as StringListType
val ourNumber = incCall.getValue(0)
val callerNumber = incCall.getValue(1)
var String msg = “Eingehender Anruf: " + FritzEingehenderAnrufer.state + " (” + callerNumber + ") auf " + ourNumber
var String msg2 = "Eingehender Anruf von: " + FritzEingehenderAnrufer.state
logInfo(“FRITZ!Box”, msg)
Alexa_Bad_EG_Ankuendigung.sendCommand(msg2)
end

The Rule stores in the LOG who is calling your number and with which number.

In addition, the Alexa outputs the following: Incoming call from CALLER

I hope I can help someone with this!

Best regards
DJFlaxi

1 Like

Hey @maihacke,
As I have been informed, the issue we experienced has already been solved in the further development of the binding. So please try to update the binding to the latest snapshot (the command for it you find further up in a post from 8 of January 2021).

That (post #19) is how it worked. Thanks a lot, Alexander, I simply did it the same way, and it correctly resolves the names.

BTW: I had to update to the latest snapshot of the TR064 binding by

bundle:list
bundle:update xyz https://ci.openhab.org/job/openHAB-Addons/lastSuccessfulBuild/artifact/bundles/org.openhab.binding.tr064/target/org.openhab.binding.tr064-3.1.0-SNAPSHOT.jar

where xyz is the id of the tr064 binding. The reason in my case was that my fritzbox is not reachable via the hostname fritz.box, and there was a bug in the 3.0.0 TR064 binding that asks for fritz.box instead of the specified IP address.

I also have the problem that the TR064 thing apparently has no actions. So, this does not work:

val tr064Actions = getActions("tr064","tr064:fritzbox:102_168_0_1")
val result = tr064Actions.phonebookLookup("49157712341234", 5)

The method phonebookLookup(String, int) is undefined for the type ThingActions; line 2, column 94, length 15

Do I need to update to the 3.1.0 snapshot version? If yes, how can I get back, if it causes other problems? Thanks!

Hi,
I wanted to test the above with log in order to see which part is not working, but got different error:

val tr064Actions = getActions("tr064","tr064:fritzbox:67c0b81d39")
logInfo("Fritz", "Log 1" )
val result = tr064Actions.phonebookLookup("49157712341234", 5)
logInfo("Fritz", "Success - the nuber is: " + result )

results in

[INFO ] [org.openhab.core.model.script.Fritz ] - Log 1
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'cb2e13b7f9' failed: class org.openhab.binding.tr064.internal.phonebook.PhonebookActions cannot be cast to class org.openhab.binding.tr064.internal.phonebook.PhonebookActions (org.openhab.binding.tr064.internal.phonebook.PhonebookActions is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @60301e; org.openhab.binding.tr064.internal.phonebook.PhonebookActions is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @1ca12b8)

binding

253 │ Active │  80 │ 3.1.0.202102140343      │ openHAB Add-ons :: Bundles :: TR-064 Binding

Perhaps @cweitkamp can help?

This should have been fixed quite a while ago (see here). But it looks like it occurs every once in a while. Most of the time if a related binding was installed manually by putting it into the addons/ folder. In general a restart of openHAB should be sufficient to solve this error.

1 Like

Oh no… I don’t believe I did not try to turn it off and on again :man_facepalming:

Yeah…sorry for bothering - now it’s working.

For outgoing calls, the number of the person called always has a equal and parallel sign 012345678# at the back. This means that it cannot be found in the phone book. Does anyone else have that

Correct, here as well.

You can use .state.toString.replace("#","") within rules to eliminate this

2 Likes

Can someone help me please. How can I figure out my Phonebook ID which should be like such a number ’ d1e06eda99’ ?

You only need the ID if you have different Phonebooks added in eg Fritzbox and only want to lookup in a special one.

If searching all different phonebooks, no need to have it. But if i remember right: In openhab logs (maybe increase loglevel) you can see it. Otherwise maybe in Support-Logging of the Fritzbox.