[SOLVED] Fritzbox-Binding - use part of phonenumber in rule

Hi,
i use the fritzbox-binding.

This is one of my items:

Call    Call_Incoming_No        "Caller No. [%2$s to %1$s]"     (gPhone)    { fritzbox="inbound" } 

How can i only use the first part of the item for a rule?

I want to use only the the number from the person, which is calling me (%2$s).

If i use the wohle item, i get both numbers, caller and called number.

I don’t think you can. You will have to parse out the number from the full String. The %2$s stuff is only for labels and I think unavailable in rules.

EDIT:

Got it…

rule "Test - eingehender Anruf"
when
    Item Call_Incoming received update
then
		val tel00 = Call_Incoming_No.state.toString.split(',').get(0)
		val tel01 = Call_Incoming_No.state.toString.split(',').get(1)
		logInfo("Fritzbox", "TEST 00 --- Incomming call first number" +tel00)
		logInfo("Fritzbox", "TEST 01 --- Incomming call second number " +tel01)
end

Output in log-file:

2017-07-05 09:56:31.222 [INFO ] [ipse.smarthome.model.script.Fritzbox] - TEST 00 --- Incomming call first number 0123456789
2017-07-05 09:56:31.222 [INFO ] [ipse.smarthome.model.script.Fritzbox] - TEST 01 --- Incomming call second number 0987654321

@halloween - it’s been a while since you posted this and I just found it. As I seem to have some issues with a working
Fritzbox rule I started to switch to your val definition which works great, but sometimes I get this error at an incoming call. The funny thing is, at the next call the rule works again as expected without the error… since upgrading to 2.2 I get occassionally this error message and no caller identification…:

2018-01-05 21:22:55.732 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Eingehender Anruf': Index is out of range
rule "Eingehender Anruf"

when

  Item fboxRinging changed to ON

then

  // Read Data of Calltype
  val callerNumber = fboxIncomingCall.state.toString.split(',').get(1)
  val incCall2 = fboxIncomingCallResolved.state as StringListType
  val LastCallName = incCall2.getValue(1)
  val CallTo = fboxIncomingCall.state.toString.split(',').get(0)

  // Remove own number from the variables
  LastCallName = LastCallName.removeStart("123456")

 // Check if caller is unknown
  if(LastCallName.startsWith("Name not found for"))
  {
    // Update Name with Unbekannt
  LastCallName = "Unbekannt"
  }
  // Update Caller data into Sitemap items

  fbLastNumber.postUpdate(callerNumber)
  fbLastName.postUpdate(LastCallName)

  logInfo("RuleLastCaller", "Der Anruf von " + callerNumber + " (" + LastCallName + ")" + " an die Nummer " + CallTo + " wurde als Letzter Anrufer gespeichert.")

  if (callerNumber == "017212345") {
        sendTelegram("mygroup", "mymessage!")
        }

end

I get two validation issues when refreshing the rule: Assignment to final variable
But I have no glue why this in 2.2 works sometimes and sometimes not.

Are you probably aware of any changes in 2.2 that could have impacted this rule?

Cheers
Bernd

I´m running oh 2.4 snapshot and it works without problems.

But i only read out the two calling numbers, no caller-names. Maybe it is related to this?