OH3 TR-064 save the last call

Hello everyone,

on the basis of Openhab 3.1 I have now achieved a working result. I still don’t have the option to save incoming and outgoing phone numbers with names. Under the link

I found an example from @Bredmich, but this refers to the binding Fritzbox TR-064 1.9.0 SNAPSHOT.

My attempts to save the calls in dummy items or in existing ones have always failed. Preferably I would build the code into the existing rules, but other variations are also accepted.

If someone can help me on the subject, I would be very happy.



Group gCALLMONITOR "Call Monitor" ["Equipment"]

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

Call fritzActiveCall "Aktiver Anruf [von %1$s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:active_call" }

Call fritzOutgoingCall "Ausgehender Anruf [von %2$s an %1$s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:outgoing_call" }

String fritzCallRinging "Status [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:call_state" }

String fritzIncomingCallCallee "Eingehender Anruf - Angerufener [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:incoming_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3A1"] }

String fritzIncomingCallCaller "Eingehender Anruf - Anrufer [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:incoming_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3A1", phoneNumberIndex=1, matchcount="8"] }

String fritzActiveCallCaller "Aktiver Anruf - Anrufer [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:active_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3A1"] }

String fritzOutgoingCallCallee "Ausgehender Anruf - Angerufener [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:outgoing_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3A1"] }

String fritzOutgoingCallCaller "Ausgehender Anruf - Anrufer [%s]" (gCALLMONITOR) ["Point"] { channel="avmfritz:fritzbox:xxx_xx_xxx_x:outgoing_call" [profile="transform:PHONEBOOK", phonebook="tr064_3Afritzbox_3A1", phoneNumberIndex=1, matchcount="8"] }


rule “Eingehender Anruf”
Item fritzCallRinging changed to RINGING
// die Rufnummern mit avmfritz Binding zerlegen

val incCall = fritzIncomingCall.state as StringListType
val ourNumber = incCall.getValue(0)
val callerNumber = incCall.getValue(1)

var String msg = "Eingehender Anruf: " + fritzIncomingCallCaller.state + " (" + callerNumber + ") auf " + ourNumber
logInfo("FRITZ!Box", msg)


rule “Ausgehender Anruf”
Item fritzCallRinging changed to DIALING
// die Rufnummern mit avmfritz Binding zerlegen

val outCall = fritzOutgoingCall.state as StringListType

var String calledNumber = outCall.getValue(0)
var String ourNumber = outCall.getValue(1)

var String msg = "Ausgehender Anruf: " + fritzOutgoingCallCallee.state + " (" + calledNumber + ") über " + ourNumber
logInfo("FRITZ!Box", msg)


rule “Verbindung aufgebaut - ausgehend”
Item fritzCallRinging changed from DIALING to ACTIVE
logInfo(“FRITZ!Box”, “Ausgehender Anruf: Verbindung hergestellt”)

rule “Verbindung hergestellt - eingehend”
Item fritzCallRinging changed from RINGING to ACTIVE
logInfo(“FRITZ!Box”, “Eingehender Anruf: Verbindung hergestellt”)

rule “Verbindung unterbrochen”
Item CallStatfritzCallRinging changed from ACTIVE to IDLE
logInfo(“FRITZ!Box”, “Aktiver Anruf: Verbindung unterbrochen”)

Does that work?
Just do as well


So, logInfo (“FRITZ! Box”, msg) works.

Can you explain “someStringItemForLastCaller” to me? What does the command do? Such an item does not yet exist.

2021-11-04 17:48:10.549 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'fritzbox_9-2' failed: The name 'someStringItemForLastCaller' cannot be resolved to an item or type

That’s right. Create an Item of type String with any name you like (but unique) and use it to store the info you want. Substitute the name of this new Item for someStringItemForLastCaller and postUpdate whatever text you are interested in to it.

Create a string dummy item? I had tried that before with “String Flag_FritzAusgendenderAnrufer” outgoing call from “(gAnrufmonitor) [” Point “]”, which unfortunately did not work.
Can you give us an example of this?

Here is your example

If only we knew more about that, there might be something sensible to say about it.

If we knew more about it, I didn’t need to ask :wink:

Sorry, maybe this question is too easy for you:
is your “someStringItemForLastCaller” a dummy? How do I create this as a string under OH3?

To create an Item

official version, somewhat hidden under Semantics

No idea what you want to do with this, but once its in an Item state you can do whatever with it.

Hello @rossko57, now I understand everything and of course it works. Many thanks for your support!
But I would like to briefly explain why I did not understand it: if there is a possibility, I work text-based. That’s why I was always on the wrong track in my mind.
Fortunately, the standard procedure then works and everything works as expected.

Many greetings

Okeydoke, so you add a new line defining a new Item to your xxx.items file

But then I still have one question: how do I proceed if several items of the type “someStringItemForLastCaller” are required? Can names like someStringItemForLastCaller1,
someStringItemForLastCaller2 … be used?

Starting point: you can have as many Items as you like, name them (uniquely) what you like, load them with whatever info you like.

Sounds like you’ve now changed your requirement to wanting a list of historic previous calls. Before you can select a suitable mechanism, decide your requirement properly. How long a list - if just the last half-dozen, you might manage a set of Items, like xx1 to xx6 as you suggest. You’ll have to write rules for that.
If you want an everlasting historicallog, look to persistence services. Again, you’ll have to write rules to make use of that (although the storage can be pretty much automated).


I’m picking up this thread again because you’ve given me valuable help a number of times and I’m understanding OH3 better and better now. A little more knowledge of Javascript would not be bad, but up to this point I’ve gotten along quite well.
My project, in which you have already supported me elsewhere, is actually almost complete. The display of the last calls alone, which is based on the item “Call List 7” or “tr064:fritzbox:1:callList_7 (String)”, is not optimal. That’s why I decided to manage the last 10 calls (incoming and outgoing) according to the scheme xx1 to xx10. Criteria would be:

  • Names of caller / callee
  • Telephone number of caller / called
  • Date of the call
  • Time of the call
    However, I need help to create the necessary rules. Would you support me?

I trust myself to build a widget that displays all calls (both incoming and outgoing). This is where I gained a lot of experience.

Alright, it’s probably easiest to have an interim Item xx00 as well.

Have the rule(s) that collect that info assemble it into a single string and postUpdate xx00 with it.

Then write a list manager rule, that triggers from xx00 update. This should copy xx09.state and update xx10 with it (discarding oldest value); then copy xx08.state to xx09, etc. Ending with the ‘working copy’ xx00 to xx01

Don’t worry about making loops to iterate through Items 1-10, just write each step out by hand. Simple, efficient to execute; the rule runs quicker.

If you make sure xx01-10 are persisted and restored (use MAPDB perhaps) then your list will appear to surbive an openHAB reboot.

This is now more complicated than I thought and totally new territory for me.

I have a rough idea of how it could go (copy?):
Copy xx08.state to xx09
Copy xx07.state to xx08
Copy xx06.state to xx07

xx00.state = last phone call

but what is the exact command for this?

RRD4j is currently set, but it doesn’t seem to be working yet. I would also like to switch to influxdb2 and Grafana later, so that everything should run in Docker.
So many questions arise and I therefore doubt that this path will end successfully. Or is it not that difficult after all?

It’s just Items. You’ve already done this in other rules.
yourItem.postUpdate(new state)

rrd4j does not “do” strings, plain and simple.

MapDB is a very simple add-on, specifically created to store last value and restore it at boot-up.

It’s still missing from the OH3 docs, grumble. Though nothing much has changed since OH2

Creat ten Items, write one rule.
Figure out how to display text of ten Items.
Persisting is a nice-to-have to do later.


Rule “outgoing calls”

Item fritzCallRinging changed to DIALING ???
myLogItemA00.postUpdate(myLogItemA00.state)msg ???

Rule “incoming calls”

Item fritzCallRinging changed to RINGING ???
myLogItemE00.postUpdate(myLogItemE00.state)msg1 ??? (last phone call)

I assume that the item myLogItemE00 contains all information about the name of caller, telephone number of caller, date of the call and time of the call!

These lines from Fritzbox_92.rules cause the entry in the openhab.log. How do I have to change it so that the date and time (format: 21.12.2022 and 24:00) are recorded. How exactly is the command “myLogItemE00.postUpdate(myLogItemE00.state)msg1 ???”.

var String msg = "Der Anruf von" + " '" + callerName +"' " + " Telefon-Nr. " + callerNumber + " erfolgte an die eigene Nr. " + ourNumber
logInfo("FRITZ!Box", msg1)

Alright, you’ve chosen to trigger your rules in a different way to what I suggested.
Be sure all the information that you want is available at the moment these rules are triggered.

Basic process

yourItem.postUpdate("some string")

We can expand to

var myVariable = "some" + " " +"string"

to assemble a single string out of parts.
Now we can substitute other stuff for the string parts.
(now is a special system variable with the current datetime)

var myVariable = thisItem.state.toString + " " + now.toString

You’re really going to have to find out how to find and adapt other people’s examples for the niceties of formatting etc.

No, I didn’t do that consciously. Then I misunderstood you! I have already written above that such extensive rules are new to me and I am considering completing this project successfully. Let’s take a break at this point. Perhaps I’ll revisit the matter at a later date.

Thank you for the support.