Fritzboxtr064 - once again...rule's not working in OH2 for call identification etc

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 former 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

With code fences it’s so much easier to read…

Second what do the lods show?

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
    fbLastNumber.postUpdate(LastCallNumber)
    fbLastName.postUpdate(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

Hi,

here the log…
the rule is not executed due to an error…

2020-02-17 17:45:45.064 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP GET request at ‘items/CallState’ for the unknown item ‘CallState’.
2020-02-17 17:45:45.672 [INFO ] [tzboxtr064.internal.PhonebookManager] - Trying to resolve number 639252471 to name comparing 7 characters
2020-02-17 17:45:45.672 [INFO ] [tzboxtr064.internal.PhonebookManager] - Trying to resolve number 639252471 to name comparing 7 characters
2020-02-17 17:45:45.672 [INFO ] [tzboxtr064.internal.PhonebookManager] - Found name match ‘Olly’ in phonebook by comparing incoming number ‘xxxx’ with address book entry ‘xxxxxx’
2020-02-17 17:45:45.672 [INFO ] [tzboxtr064.internal.PhonebookManager] - Found name match ‘Olly’ in phonebook by comparing incoming number ‘xxxx’ with address book entry ‘xxxxx’
2020-02-17 17:45:45.676 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Eingehender Anruf’: An error occurred during the script execution: index=1, size=1
2020-02-17 17:45:47.737 [INFO ] [thome.model.script.cam1LastRecording] - front:1581960127309
2020-02-17 17:45:51.852 [INFO ] [arthome.model.script.cam1MotionState] - front motion state:true
2020-02-17 17:45:51.861 [INFO ] [se.smarthome.model.script.motioncam1] - front motion state change:ON
2020-02-17 17:45:56.942 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Anruf aus’: The name ‘sonos’ cannot be resolved to an item or type; line 58, column 14, length 5
2020-02-17 17:45:57.494 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP GET request at ‘items/CallState’ for the unknown item ‘CallState’.

Add some logInfo to find out what is going on:
It look like there is no index 1 in your stringlist

rule “Eingehender Anruf”
when
    Item fbKlingel changed from OFF to ON
then
    // Daten des CallType auslesen
    logInfo("TEST", fbAnruf.state.toString)
    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
1 Like

i put the loginfo there… but no entry in log. it doesn’t effect this rule it seems…
i found so much examples about this binding… all with problems, different statements… by changing from oh1 to oh2… so i dont know what to do…

Then the rule didn’t trigger

Yes, thats what i know from the beginning and therefore i put this post… but its a copied rule from another threat, were i posted my question before… and i have no idea whats going wrong…

Has nobody an idea why the rule is not triggered ???
the datatype should be correct since OH2… the name resolving works… so what ?
please help…

oliver

You have the information, we don’t.

Your rule was triggering but generating errors one day ago.
You said you added a logInfo() to it, and now the rule does not trigger.

Let’s start from there … can you see a “rules file loaded” message in your openhab.log from when you edited your rules file?
Can you see the expected trigger in your events.log, the Item fbKlingel reporting state changes?

Hi Rossko,

the rule is loaded correctly. I think the rule never was triggered… that was my problem from the beginning… the loginfo was allways there but not the first statement after the “then”… still the error:

2020-02-17 17:45:45.676 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Eingehender Anruf’: An error occurred during the script execution: index=1, size=1

If the rule is generating an error when it runs … it is being triggered, starts to run, then has an error.

Your rule is being triggered.

May we see the output of the logInfo that runs in your rule before it has the error? That will tell us something about the data that relates to the error.

Hi,

i was one week away… no further idea here ?

here the log output:

2020-02-27 17:23:58.779 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP GET request at ‘items/CallState’ for the unknown item ‘CallState’.
2020-02-27 17:23:59.499 [INFO ] [tzboxtr064.internal.PhonebookManager] - Trying to resolve number 639252471 to name comparing 7 characters
2020-02-27 17:23:59.500 [INFO ] [tzboxtr064.internal.PhonebookManager] - Found name match ‘Olly’ in phonebook by comparing incoming number ‘xxxxxx’ with address book entry ‘xxxxxxx’
2020-02-27 17:23:59.503 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Eingehender Anruf’: An error occurred during the script execution: index=1, size=1
2020-02-27 17:24:01.797 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP GET request at ‘items/CallState’ for the unknown item ‘CallState’.

The output from the logInfo() suggested is not there. Did you add it to the rule after all?

No entry in log…

rule “Eingehender Anruf”

when

Item fbKlingel changed from OFF to ON

then

// Daten des CallType auslesen

logInfo(“Fritzbox: Eingehender Anruf - 1”)

val inccall = fbAnruf.state as StringListType

// Die Variablen anlegen und mit der Nummer bzw. Namen des Anrufers füllen

logInfo(“Fritzbox: Eingehender Anruf - 2”)

val LastCallNumber = inccall.getValue(1)

logInfo(“Fritzbox: Eingehender Anruf - 3”)

val LastCallName2 = fbAnrufName.state as StringListType

// Die eigene Rufnummer aus der Variable entfernen

logInfo(“Fritzbox: Eingehender Anruf - 4”)

val LastCallName = LastCallName2.getValue(1)

// Prüfen ob der Anrufer unbekannt ist

logInfo("Fritzbox: Eingehender Anruf von " + LastCallName)

if(LastCallName.startsWith(“Name not found for”)){

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

Then I suspect the rule version you have shown us is not loaded.
The error does come from a rule named ‘Eingehender Anruf’ , so there are two possiblities.
You’ve got duplicate rules - every rule “name” must be unique.
or
You’ve introduced an error into your rules file so that it no longer loads (in which case the old rule still exists in memory). Make an edit like adding a harmless space, save the file, look in openhab.log for file load messages.

yes, there might be something wrong… but the rule is loaded new , isnt it ?

2020-02-27 21:34:02.224 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘fritzboxtr064.rules’, using it anyway:
Assignment to final variable
2020-02-27 21:34:02.246 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘fritzboxtr064.rules’
2020-02-27 21:34:04.101 [INFO ] [thome.model.script.cam1LastRecording] - front:1582819729730
2020-02-27 21:34:09.215 [INFO ] [arthome.model.script.cam1MotionState] - front motion state:false
2020-02-27 21:34:19.265 [INFO ] [arthome.model.script.cam1MotionState] - front motion state:false
2020-02-27 21:34:22.531 [INFO ] [tzboxtr064.internal.PhonebookManager] - Trying to resolve number 639252471 to name comparing 7 characters
2020-02-27 21:34:22.532 [INFO ] [tzboxtr064.internal.PhonebookManager] - Found name match ‘Olly’ in phonebook by comparing incoming number ‘xxxx’ with address book entry ‘xxxx’
2020-02-27 21:34:22.662 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Eingehender Anruf’: An error occurred during the script execution: index=1, size=1