2021-01-26 20:52:38.290 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCall' changed from UNDEF to 012345678,0987654321
2021-01-26 20:52:38.290 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCallCaller' changed from UNDEF to Doe John
2021-01-26 20:52:38.290 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCallCallee' changed from UNDEF to Miller Jane
2021-01-26 20:52:38.290 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzCallRinging' changed from IDLE to DIALING
2021-01-26 20:52:49.796 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzActiveCall' changed from UNDEF to 012345678,
2021-01-26 20:52:49.796 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzActiveCallCaller' changed from UNDEF to Miller Jane
2021-01-26 20:52:49.796 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCall' changed from 012345678,09876543211 to UNDEF
2021-01-26 20:52:49.796 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCallCaller' changed from Doe John to UNDEF
2021-01-26 20:52:49.797 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzOutgoingCallCallee' changed from Miller Jane to UNDEF
2021-01-26 20:52:49.797 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzCallRinging' changed from DIALING to ACTIVE
and hanging up:
2021-01-26 21:05:52.563 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzActiveCall' changed from 0621896949, to UNDEF
2021-01-26 21:05:52.563 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzActiveCallCaller' changed from Miller Jane to UNDEF
2021-01-26 21:05:52.563 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'fritzCallRinging' changed from ACTIVE to IDLE
The example code in post #19should to my best knowledge use all phonebooks available.
If you have a “space” character in your phonebook’s name, try substituting this (if you select it at all…) with _20, like in Google_20Telefonbuch. But you should not have to do this as the items (as shown above) can be used directly in rules, without translation.
Bonus: rules to push the identified caller name / numbers via pushover binding:
fritzbox.rules
rule "Incoming Call"
when
Item fritzCallRinging changed to RINGING
then
// dissect the calling numbers with avmfritz binding
val incCall = fritzIncomingCall.state as StringListType
val ourNumber = incCall.getValue(0)
val callerNumber = incCall.getValue(1)
// do something with callerNumber
val actions = getActions("pushover", "pushover:pushover-account:account")
var String msg = "Eingehender Anruf: " + fritzIncomingCallCaller.state + " (" + callerNumber + ") auf " + ourNumber
logInfo("FRITZ!Box", msg)
actions.sendMessage(msg, "openHAB")
end
rule "Outgoing Call"
when
Item fritzCallRinging changed to DIALING
then
// dissect the calling numbers with avmfritz binding
val outCall = fritzOutgoingCall.state as StringListType
var String calledNumber = outCall.getValue(0)
var String ourNumber = outCall.getValue(1)
val actions = getActions("pushover", "pushover:pushover-account:account")
var String msg = "Ausgehender Anruf: " + fritzOutgoingCallCallee.state + " (" + calledNumber + ") über " + ourNumber
logInfo("FRITZ!Box", msg)
actions.sendMessage(msg, "openHAB")
end
rule "Connection established - outgoing"
when
Item fritzCallRinging changed from DIALING to ACTIVE
then
logInfo("FRITZ!Box", "Outgoing call: Connection established")
end
rule "Connection established - incoming"
when
Item fritzCallRinging changed from RINGING to ACTIVE
then
logInfo("FRITZ!Box", "Incoming call: Connection established")
end
rule "Connection dropped"
when
Item CallStatfritzCallRinging changed from ACTIVE to IDLE
then
logInfo("FRITZ!Box", "Active call: Connection dropped")
end
I tried several things, but still don´t get any name.
What I changed/resolved:
By reading in the phonebook, a warning was raised “Scheduled runnable ended with an exception: java.lang.IllegalStateException: Duplicate key …”
I removed the empty space in the name of the phonebook in the Fritz!Box
I changed “matchCount” into “matchcount” as I found this difference compared to your example. But actually with “machtcount” it didn´t show me the defined value in the UI, therefore I changed it back. Also in this regard, I added the quotes to the number, but thereby I did also not get it working
I activated the DEBUG logging for the TR-064 binding. It proves me the following info “Number ‘’ not found in phonebook ‘null’ from provider ‘tr064:fritzbox:1’”. Does this tell that it can´t refer to a phonebook?
When I set the binding to TRACE logging, I can see that it retrieves the list of calls with all the names
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.
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.
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())
...
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?
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.
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…
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).
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.
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)
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.
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