Fritz!Box TR-064 - Save the number of the last call

OK got it.
Look in the post marked as solution.
You need two Items to get this; one for the number and one for the Number resolved to name from phonebook(or to “Name not found for”).

Call fbAnruf "Anruf von [%1$s]" <phone> {fritzboxtr064="callmonitor_ringing"}//Nummer des Anrufers
Call fbAnrufName "Anruf von [%1$s]" <phone> {fritzboxtr064="callmonitor_ringing:resolveName"}//Name des Anrufers, wenn in Telefonbuch, sonst "Name not found for"

these are both Items of type “Call”, so in your rule use " as StringListType" for both.

Hi Oli,

I tried the following rule with the mentioned items:

rule "Eingehender Anruf"

when

  Item fboxRinging changed from OFF to ON

then

  // Daten des CallType auslesen
  val incCall = fbAnruf.state as StringListType
  val callerNumber = incCall.getValue(1)
  // Die Variablen anlegen und mit der Nummer bzw. Namen des Anrufers füllen
  val String LastCallName   = fbAnrufName.state.toString()
  // Die eigene Rufnummer aus der Variable entfernen
 LastCallName = LastCallName.removeStart("1234567##")
  // Prüfen ob der Anrufer unbekannt ist
 if(LastCallName.startsWith("Name not found for"))
  {
    // Den Namen mit Unbekannt füllen
  LastCallName = "Unbekannt"
  }
  // Die Daten in die Items eintragen
  postUpdate(fbLastNumber, callerNumber)
  postUpdate(fbLastName, LastCallName)
	logInfo("RuleLastCall", "Der Anruf von " + callerNumber + " (" + LastCallName + ")" + " wurde als Letzter Anrufer gespeichert.")
end

With the following output:

Der Anruf von 0987654321 (1234567, Johannes (Mobile)) wurde als Letzter Anrufer gespeichert.

I think “LastCallName = LastCallName.removeStart(“1234567##”)” doesn’t work.

Any ideas?

Thank you for your help and your effort

johannes

check: LastCallName.removeStart(“1234567##”)

i doubt your own number starts with “1234567##”

1 Like

For sure, I replaced it for the post. Filled with my number same result… I double checked this.

uh…quick and dirty…try:

val String helper   = fbAnrufName.state.toString()
  // Die eigene Rufnummer aus der Variable entfernen
val String LastCallName = helper.removeStart("1234567##")

Sorry…same result. Your solution with the helper String didn’t solve the problem. It seems that .removeStart has no influence or are there any other imports for the rule file I need?. But also no errors in the log.
Any other idea or hints?

Looking at it again, i think yes.
you should use the same method for lastcallname than for callernumber
Try this:
remove:

// Die Variablen anlegen und mit der Nummer bzw. Namen des Anrufers füllen
  val String LastCallName   = fbAnrufName.state.toString()
  // Die eigene Rufnummer aus der Variable entfernen
 LastCallName = LastCallName.removeStart("1234567##")
  // Prüfen ob der Anrufer unbekannt ist

with:

// Die Variablen anlegen und mit der Nummer bzw. Namen des Anrufers füllen
  val incCall2   = fbAnrufName.state as StringListType
  // Die eigene Rufnummer aus der Variable entfernen
 val LastCallName =incCall2.getValue(1)

the rest should work as is.

Thank you!!!

But it should be:

val LastCallName =incCall2.getValue(1)

instead of

val LastCallName =incCall.getValue(1)

But through your tip I need an explanation about the expression inCall.getValue(1). What does .getValue(1) makes?

Glad you got it working!
sorry for the typo :wink: fixed it in the post.

fbAnrufName.state holds two values in comma separated form. Your own number that was called and the name of the caller(or "Name not found for"plus the number if not found in phonebook), like so:
123456, Karl Handy
123456, “Name not found for” +49 30 182722720)
getValue() either returns the part in front of the comma (getValue(0)) or the part behind the comma (getValue(1))

1 Like

Thank You for your help!

de rien…

So… to finish this off; which version of the add-on needs to be loaded on OH1 to make this work?
1.9.0?
And can the outgoing call captured with name and number too?

Sorry my OH1 days are over :slight_smile:
Using OH2, FritzboxTr064 Binding 1.10.0.201703140213
Haven’t tested outgoing call but I see no reason why it should not work.
Log shows that outgoing call Items get set appropriately.

Post removed to:

Hi all,

i go mad with this binding…
presence detection is working fine, but i cannot get it running with call identification or reaction to an incoming call… I think my rules have some problems, although should be the same like her in some examples…
andy idea ?

items:
Switch fbKlingel “Telefon klingel [%s]” {fritzboxtr064=“callmonitor_ringing” }
Call fbAnruf “Anruf von [%1$s]” {fritzboxtr064=“callmonitor_ringing” }
Call fbAnrufName “Anruf von [%1$s]” {fritzboxtr064=“callmonitor_ringing:resolveName” }
String fbLastNumber “Letzter Anrufer: [%s]” (gfritzbox)
String fbLastName “Letzter Anrufer: [%s]” (gfritzbox)

rule:

import org.openhab.library.tel.types.CallType
import org.openhab.core.library.types.CallType
import org.openhab.core.persistence.CallType
import org.openhab.model.script.actions.CallType

rule “Eingehender Anruf”
when
Item fbKlingel changed from OFF to ON
then
// Daten des CallType auslesen
val call = fbAnruf.state as StringListType
// Die Variablen anlegen und mit der Nummer bzw. Namen des Anrufers füllen
val LastCallNumber = call.getValue(1)
val LastCallName2 = fbAnrufName.state as StringListType
// Die eigene Rufnummer aus der Variable entfernen
val LastCallName = LastCallName2.getValue(1)
// Prüfen ob der Anrufer unbekannt ist
if(LastCallName.startsWith(“Name not found for”))
{
// Den Namen mit Unbekannt füllen
LastCallName = “Unbekannt”
}
// Die Daten in die Items eintragen
postUpdate(fbLastNumber, LastCallNumber)
postUpdate(fbLastName, LastCallName)
logInfo(“RuleLastCall”, “Der Anruf von " + LastCallNumber + " (” + LastCallName + “)” + " wurde als Letzter Anrufer gespeichert.")
sendBroadcastNotification(“Eingehender Anruf von”, LastCallName)
sendTelegram(“bot1”,“Eingehender Anruf von”, LastCallName)
end

hope anyone finds the errors i have for sure in… its not working…

oliver

You should have started a new thread for this.