Missing Call Monitor for Fritzbox after OH3 Upgrade

Hi,

I upgraded to OH3.
I used the Callmonitor feature of the “old” avm FritzTR64 Binding.
Now I figured out, that this featrue is “moved” to the AVM Fritzbinding.
My Problem now is, that the Thing doesn’t support the channels, as described in the documentation.
My Thing looks like this:

So my question is:
How can I add the Channels for the Call Monitor?

I created this, but the Items never receives an update:
String i_CallState “Call State [%s]” { channel=“avmfritz:fritzbox:192_168_1_1:call_state” }

Call i_EingehenderCall_Nummer “Incoming call: [%1$s to %2$s]” { channel=“avmfritz:fritzbox:192_168_1_1:incoming_call” }

Call i_ActiveCall “Call established [%1$s]” { channel=“avmfritz:fritzbox:192_168_1_1:active_call” }

I use textual config and found that the following works:

Item
Call IncomingCall "Incoming call: [%1$s to %2$s]" { channel="avmfritz:fritzbox:1:incoming_call" }

Rule

rule "test incoming call"
    when
        Item IncomingCall changed
    then
        logInfo(LOG, "IncomingCall changed to " + IncomingCall.state)
        if(IncomingCall.state == UNDEF){
            logInfo(LOG, "call stopped")
        } else {
            logInfo(LOG, "call started")
        }
end

How can you pass the two values %1$s , %2$s to strings in a Ruhle?

I do it that way:

var String[] callarray = i_EingehenderCall_Nummer.state.toString.split(",")
// In callarray.get(1) steht die Quellrufnummer.
var String[] von = callarray.get(1).split(" \(")

I wrote a comprehensive example of how to use the new features provided by avmfritz Binding combined with TR-064 Binding.

avmfritz Binding

  • provides the Call Monitor

TR-064 Binding

  • provides information about number of incoming, outgoing or missed calls
  • provides the phone book: a Profile and Thing Actions to look-up phone numbers
  • (optionally) allows to configure and a FRITZ!Box integrated TAM (Telephone Answering Machine) - not included in the example

Example

Assuming we have a FRITZ!Box with IP-Address XXX.YYY.ZZZ.1 (<IP>) represented in openHAB by two Things (one for avmfritz, the other one for tr064) with <THING_ID> = XXX_YYY_ZZZ_1. We use the same Id for both Bindings.

For simplification I replaced the name of the phone book by <PHONEBOOK_NAME>. You can extract the available phone book names when configuring a phone book Profile via UI. There always is a default phone book which name is related to the IP-Address (e.g. "tr064_3Afritzbox_3AXXX_5FYYY_5FZZZ_5F1" - be aware of the "XXX", "YYY", "ZZZ" and "1").

*.things

Bridge avmfritz:fritzbox:<THING_ID> "FRITZ!Box" [ipAddress="<IP>", user="<USER>", password="<PASSWORD>"]
Bridge tr064:fritzbox:<THING_ID> "FRITZ!Box" [host="<IP>", user="<USER>", password="<PASSWORD>"]

avmfritz.items

// Call Monitor Equipment
Group gCALLMONITOR "Call Monitor" ["Equipment"]

Call fritzIncomingCall "Incoming Call [von %2$s an %1$s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:incoming_call" }
Call fritzActiveCall "Active Call [von %1$s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:active_call" }
Call fritzOutgoingCall "Outgoing Call [von %2$s an %1$s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:outgoing_call" }
String fritzCallRinging "Status [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:call_state" }

// resolved numbers (only if TR-064 binding is installed)
String fritzIncomingCallCallee "Incoming Call - Callee [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:incoming_call" [profile="transform:PHONEBOOK", phonebook="<PHONEBOOK_NAME>"] 
String fritzIncomingCallCaller "Incoming Call - Caller [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:incoming_call" [profile="transform:PHONEBOOK", phonebook="<PHONEBOOK_NAME>", phoneNumberIndex=1] }

String fritzActiveCallCaller "Active Call - Caller [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:active_call" [profile="transform:PHONEBOOK", phonebook="<PHONEBOOK_NAME>"] }

String fritzOutgoingCallCallee "Outgoing Call - Callee [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:outgoing_call" [profile="transform:PHONEBOOK", phonebook="<PHONEBOOK_NAME>"] }
String fritzOutgoingCallCaller "Outgoing Call - Caller [%s]" (gCALLMONITOR) ["Status"] { channel="avmfritz:fritzbox:<THING_ID>:outgoing_call" [profile="transform:PHONEBOOK", phonebook="<PHONEBOOK_NAME>", phoneNumberIndex=1] }

You can omit the PHONEBOOK_NAME in the Profile configuration as it is an optional parameter. If you do not pass it, all available phonebooks will used to determine the name. Additionally there is another optional parameter matchCount.A configured integer vauue is counted from the right end of the phone number and denotes the number of matching characters needed to consider this number as match for a name.

tr064.items

// Incoming, Outgoing and missed calls in the last 7 days
Number fritzboxIncomingCalls "Incoming Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:<THING_ID>:inboundCalls_7" }
Number fritzboxOutgoingCalls "Outgoing Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:<THING_ID>:outboundCalls_7" }
Number fritzboxMissedCalls "Missed Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:<THING_ID>:missedCalls_7" }

Jython Rule

from core.actions import LogAction
from core.rules import rule
from core.triggers import when

def getTR064Actions():
    return actions.get("tr064","tr064:fritzbox:<THING_ID>")

@rule("Trigger for fritzOutgoingCall changed")
@when("Item fritzOutgoingCall changed")
def Changed(event):
    if not isinstance(event.itemState, UnDefType):
        callee = event.itemState.getValue(0)
        caller = event.itemState.getValue(1)
        LogAction.logInfo("avmfritz", "Outgoing call: {} [Caller={}, Callee={}]", event.itemState, caller, callee)

        tr064Actions = getTR064Actions()
        #calleeResolved = tr064Actions.phonebookLookup(callee)
        calleeResolved = tr064Actions.phonebookLookup(callee, <PHONEBOOK_NAME>)
        #callerResolved = tr064Actions.phonebookLookup(caller)
        callerResolved = tr064Actions.phonebookLookup(caller, <PHONEBOOK_NAME>)
        LogAction.logInfo("avmfritz", "Caller={}, Callee={}", callerResolved, calleeResolved)

Output

2021-01-07 12:00:23.067 [INFO ] [g.openhab.core.model.script.avmfritz] - Outgoing call: 015119644845,6816477 [Caller=123, Callee=555 - 555 666 777]
2021-01-07 12:00:23.075 [INFO ] [g.openhab.core.model.script.avmfritz] - Caller=Mr. X, Callee=Christoph

Call Monitor Card

7 Likes

Hi,

unfourtnately I don’t know, how I can configure a phone book Profile via UI-
Could you paste a screenshot, where the configuration of the profile is shown?

Thanks in advance

I am afraid I have to revoke my statement. You cannot see the name of the phonebooks in the UI. I then suggested to omit the defining that parameter. In that case all available phonebooks will be used.

Hi,

I tried this Item, with the name of my Phonebook (out of Fritzbox Webinterface):
String fritzIncomingCallCaller “Incoming Call - Caller [%s]” (gCALLMONITOR) [“Status”] { channel=“avmfritz:fritzbox:<THING_ID>:incoming_call” [profile=“transform:PHONEBOOK”, phonebook="<PHONEBOOK_NAME>", phoneNumberIndex=1] }

But I only receive that error, when a call is coming in:
2021-01-08 15:56:15.481 [WARN ] [.internal.phonebook.PhonebookProfile] - Cannot initialize PHONEBOOK transformation profile: UID must have at least 3 segments… Profile will be inactive.

The name of the phone book can be found on the Fritzbox website.

If I don’t enter a phone book name, only the Fritzbox phone book is searched.

I experience the same problem. With and without defining the phonebook. Have you already found a solution?

Same to me (Openhab3 release version). I also get this error message “UID must have at least 3 …”
.
Some more questions to @cweitkamp regarding this example:

  1. What is the TR064 binding then for? All channels bind to the avmfritz thing!
  2. Why do you write in your example, given that all channels are avmfritz channels:
    // resolved numbers (only if TR-04 binding is installed)
  3. Is it required that the avmfritz and tr064 things use the same identifier? Some hidden logic behind that?
  4. Do I have to upgrade some of the bindings, and if so, how?
  5. Why does your script example use tr064 actions for resolving the names, if you use the resolved names from the phonebook profile of the avmfritz binding?

BTW: If I configure these phonebook profile items via UI, it does not allow me to leave the phonebook name blank.

As you can see, I am totally confused…

Thanks a lot for helping.

2 Likes

Just wrote a solution here. Perhaps that helps.

2 Likes

Thank you!
I configured, as you described, now it’s working

Thank’s for your good work!!!

1 Like

Hi together,

Based on the provided description, I also got it working. Great to have this possibility in OH3.

However, I recognised two issues which may could be improved:

  • When the phone book includes entries with having the same number included twice in one entry, the reading in of the complete phonebook fails. In best case, it should ignore the duplicate from my prospective.
  • When having a number with a seperator in the phonebook, e.g. 1234-5678, the name doesn´t get resolved. It would be great when spaces and seperators like “-” or “/” could be removed for the resolving of the name. I recognised the issue as the FritzPhone showed the name.

May this could be considered for the further development of the binding.

Hi @Intenos,
I stumbled on the same topics as you.
I found out, that they are already solved in the latest snapshot-version (the team behind the binding where really quick - kudos!):

For the normalization (removal of extrachars), I did not check what kind of characters will be eliminated, but you will find more information in the linked issue.
Cheers!
Bastian

Hi @bastian,
Thanks a lot for the info. That´s fairly great! I updated the binding accordingly.

Here’s how to get the information about new messages on the answering machine. Adding the parameter tamIndices=“0” is the important part to get it working:

Thing:
Bridge tr064:fritzbox:FritzBox6490 "FritzBox 6490 TR064" @ "Home" [ host="192.168.1.xxx", user="username", password="password", phonebookInterval="0", tamIndices="0"]

Item:
Number VoiceBox "Anrufbeantworter [%s Nachricht(en)]" <phone_connection> (Phone) {channel="tr064:fritzbox:FritzBox6490:tamNewMessages_0"}

Alternatively, when using the UI to configure Things, add “0” in the field “TAM” advanced configuration of the Fritzbox Bridge.

1 Like

I can’t get this tr-64 binding to connect

COMMUNICATION_ERROR
java.util.concurrent.TimeoutException: Total timeout 2000 ms elapsed

My suspect is the changed port.

I already tried ip:port but then i only get status unknown

The avm binding works, but only when defining the setup port

Using OH 3.0.1. The avmfritz items are working for me, including automatic phone book lookup, so this is great!

But the tr064 items stay NULL.

With TRACE enabled, I see this error, when saving the thing config:

2021-02-12 15:48:58.581 [DEBUG] [hab.binding.tr064.internal.util.Util] - Channel missedCalls not available: Could not get required parameter for channel 'missedCalls' from thing config (missing, empty or invalid)

Items:

// Incoming, Outgoing and missed calls in the last 7 days
Number fritzboxIncomingCalls "Incoming Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:192_168_0_1:inboundCalls_7" }
Number fritzboxOutgoingCalls "Outgoing Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:192_168_0_1:outboundCalls_7" }
Number fritzboxMissedCalls "Missed Calls [%d]" (gCALLMONITOR) ["Status"] { channel="tr064:fritzbox:192_168_0_1:missedCalls_7" }

Edit:
I got it. The channels only exist after configuring the number of days in the tr064 thing config.

3 Likes

just for completeness, as the binding documentatino did not mention it:

the thing configuration in file: openhab-addons/thing-types.xml at main · openhab/openhab-addons (github.com)

callListDays="7",
inboundCallDays="7",
outboundCallDays="7",
missedCallDays="7",