Fritzbox TR064 - rule for identifying number fails at first time

Hi,

I have a rule running for quiet some time now to identify the last caller numbers. This can be found in other posts here in the community in parts and looks currently like this:

rule "Initialize Lastcaller"

when
        System started
then
        postUpdate(fbLastNumber, "12345")
        postUpdate(fbLastName, "openHAB")
        postUpdate(fboxIncomingCall, "12345")
end


rule "Eingehender Anruf"

when

  Item fboxRinging changed from OFF to ON

then

  // Daten des CallType auslesen
  val incCall = fboxIncomingCall.state as StringListType
  val callerNumber = incCall.getValue(1)
  val incCall2 = fboxIncomingCallResolved.state as StringListType
  val LastCallName = incCall2.getValue(1)

  // Die eigene Rufnummer aus der Variable entfernen
  LastCallName = LastCallName.removeStart("12345")

 // 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("RuleLastCaller", "Der Anruf von " + callerNumber + " (" + LastCallName + ")" + " wurde als Letzter Anrufer gespeichert.")

end

This one works almost perfect, besides after a restart of openHAB the first call is not put into the fblastname and fblastnumber items. Starting with the second call it runs smoothly. I started to postUpdate the values after
system initialization but without success. (running openHAB 2.1 stable).

Would appreciate a hint what I’m missing here… :thinking:

Cheers, Bernd

I guess after Initialization fboxRinging is of State NULL, so it does not change from OFF to ON but from NULL to ON and your Rule is not triggered.
I’d suggest you either add a “postUpdate(fboxRinging, OFF)” to your initialization rule or remove “from OFF” from your trigger expression.

@RaimundGl Thank a lot! Sometimes you just don’t see the forest in front of trees. :wink: I modified the obvious in the rule to “fboxringing changed to ON” and it works as expected ! :+1: