I know, there are a few threads concerning this topic, but as they are shattered across the forum and time, I guess it’s best to consolidate the information floating around.
At first, please see the documentation of the binding itself:
https://docs.openhab.org/addons/bindings/fritzboxtr0641/readme.html
I figured, my Fritz!Box 6360 Cable (v06.54) didn’t give out all the information, which is described in the binding (e.g. all the “DSL Statistics” and the “WanIP”), which is fine as it is a cable router and not a DSL router - and I’m not so sure, what all those statistics are worth doing something with them…
What I did encounter is what I like to do with the Call Monitor. I’d like to have a “lastCaller” item, which I can use to display or to send notifications with. But there are two obstacles here
- the
callmonitor_ringing
item is only active while the call is active and Returns a blank, when the caller hung up - the information for Call Monitor Comes with the (undocumented?)
itemtype Call
.
So to have the last caller Handy within OH2 after the caller hung up, you have to create an proxy item for it, which is filled, when the call is active. and for the second you have to extract the information.
So, this is my fritzbox.items:
/* Call Monitor */
Switch Fritz_Ringing "eingehender Anruf [%s]" {fritzboxtr064="callmonitor_ringing" }
Switch Fritz_RingOut "ausgehender Anruf [%s]" {fritzboxtr064="callmonitor_outgoing" }
Call Fritz_Incoming "eingehende Nummer: [%1$s to %2$s]" {fritzboxtr064="callmonitor_ringing" }
Call Fritz_Outgoing "ausgehende Nummer: [%1$s to %2$s]" {fritzboxtr064="callmonitor_outgoing" }
Call Fritz_IncomingResolved "eingehender Anrufe: [%1$s to %2$s]" {fritzboxtr064="callmonitor_ringing:resolveName" }
// last Call items
Number Fritz_MissedCalls "Anrufe in Abwesenheit [%s]" {fritzboxtr064="missedCallsInDays:5"}
String Fritz_LastIncoming "letzter eingehender Anruf [%s]"
String Fritz_LastIncomingDest "letzter Anruf an [%s]"
String Fritz_LastIncomingResolved "letzter eingehender Anrufer [%s]"
now to the fritzbox.rules
rule "Telefon klingelt"
when
Item Fritz_Ringing changed to ON
then
/* read out CallType */
val TmpCall = Fritz_Incoming.state as StringListType // change Call Itemtype for numbers only
val CallerNumber = TmpCall.getValue(1) // Number of Caller is Value 1
val CallTo = TmpCall.getValue(0) // internal number called (useful, if you have more than one number)
val TmpCall2 = Fritz_IncomingResolved.state as StringListType // Change Call Itemtype for resolved name from phonebook
val CallerName = TmpCall2.getValue(1) // This is the equivalent name from the phonebook (or again the caller number if nomatch)
var String CallToName = "-" // prepare the name of the caller
// who was called
if (CallTo == "12345") { CallToName = "xxx" } // first number
if (CallTo == "67890") { CallToName = "yyy" } // second number
Fritz_LastIncomingDest.sendCommand(CallToName) // Name of number called
// If entry was not found in phonebook - shorten CallerName
if(CallerName.startsWith("Name not found for")) {
// fill the name with unknown
CallerName = "unknown"
}
// Update the proxy items
Fritz_LastIncoming.sendCommand(CallerNumber)
Fritz_LastIncomingResolved.sendCommand(CallerName)
var String text = "call saved: " + CallerNumber + " (" + CallerName + ")" + " to " + CallToName + "."
logInfo("Fritz Call", "Fritz!Box says: "+text)
end
rule "verpasster Anruf"
when
Item Fritz_MissedCalls changed // if you didnt pick up, the missedcall item will increment
then
// log the entry
var String text = Fritz_LastIncomingDest.state + ": Missed Call from " + Fritz_LastIncomingResolved.state + ", " + Fritz_LastIncoming.state
logInfo("Fritz Call", "Fritz!Box says: "+text)
end