This are my Files.
The problem is I can not get the number from the outgoing call.
//Fritz.Items
Switch fboxRinging “Phone ringing [%s]” {fritzboxtr064=“callmonitor_ringing” }
Switch fboxRinging_Out “Phone ringing [%s]” {fritzboxtr064=“callmonitor_outgoing” }
Call fboxIncomingCall “Incoming call: [%1$s to %2$s]” {fritzboxtr064=“callmonitor_ringing” }
Call fboxOutgoingCall “Outgoing call: [%1$s to %2$s]” {fritzboxtr064=“callmonitor_outgoing” }
Number FritzTestNumb “FBox Test Number [%s]”
String FritzTestTXT “FBox Test Text [%s]”
//Fritz.Sitemap
…
{
Frame label=“FritzBox” {
Switch item=fboxRinging_Out
Switch item=fboxRinging
Text item=fboxOutgoingCall
Text item=fboxIncomingCallResolved
Text item=FritzTestNumb
Text item=FritzTestTXT }
rule "Alarm Call"
when
Item fboxRinging_Out changed from OFF to ON
then
val outCall = fboxOutgoingCall.state as StringListType
val callNumber = outCall.getValue(0)
if (callNumber == "0123456789"){
// do something
}
end
Hello, Thank U, but it
it doesn’t work. The same mistakes I always got in my attempts. It’s somehow due to the ‘% 2 $ s’ specifier. have a look at the LOG.
Outgoing number: 28287xxx
Destination Number: 01577xxxx
I want to tap the outgoing number
LOG:
2018-04-01 10:12:34.382 [INFO ] [tzboxtr064.internal.PhonebookManager] - Trying to resolve number 01577191xxxx to name comparing 7 characters
2018-04-01 10:12:34.387 [INFO ] [tzboxtr064.internal.PhonebookManager] - found name match Christian in phonebook by comparing 0379191xxxxxx with 0379191
==> /var/log/openhab2/events.log <==
2018-04-01 10:12:34.420 [vent.ItemStateChangedEvent] - fboxOutgoingCall changed from NULL to 015771xxxxxx,28287xxxx
2018-04-01 10:12:34.425 [vent.ItemStateChangedEvent] - fboxRinging_Out changed from NULL to ON
2018-04-01 10:12:42.517 [vent.ItemStateChangedEvent] - fboxOutgoingCall changed from 0157719xxxxx,2828xxx to
2018-04-01 10:12:42.525 [vent.ItemStateChangedEvent] - fboxIncomingCall changed from NULL to
2018-04-01 10:12:42.536 [vent.ItemStateChangedEvent] - fboxIncomingCallResolved changed from NULL to
2018-04-01 10:12:42.541 [vent.ItemStateChangedEvent] - fboxRinging_Out changed from ON to OFF
2018-04-01 10:12:42.545 [vent.ItemStateChangedEvent] - fboxRinging changed from NULL to OFF
==> /var/log/openhab2/openhab.log <==
2018-04-01 10:12:42.688 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘’ of item fboxOutgoingCall with format ‘%1$s to %2$s’: {}
java.util.MissingFormatArgumentException: Format specifier ‘%2$s’
at java.util.Formatter.format(Formatter.java:2525) [?:?]
at java.util.Formatter.format(Formatter.java:2455) [?:?]
at java.lang.String.format(String.java:2940) [?:?]
I tested my solution again on my system and it works as expected.
You can switch between the outgoing number and destination number by altering the line val callNumber = outCall.getValue(0) to val callNumber = outCall.getValue(1).
I have the same warning in my log, but it shouldn’t effect the rule, because it’s only a matter of the User Interface and on my sitemap fboxOutgoingCall is displayed correctly anyhow. I think, it shows up because the state of fboxOutgoingCall is set to null or '', when there is no call, so there is no first and second string to be displayed. Again, it shouldn’t be the root of your problem.
Is your rule loaded correctly? Sometimes it is a problem, when you copy something from the forum, that you have the wrong quotes (“ ” instead of " ").
Try to add some more logging, to locate the fault. Like this:
rule "Alarm Call"
when
Item fboxRinging_Out changed from OFF to ON
then
logInfo("Alarm Call", "Alarm Call rule triggered...")
val outCall = fboxOutgoingCall.state as StringListType
logInfo("Alarm Call", outCall.toString)
val callNumber = outCall.getValue(0)
logInfo("Alarm Call", callNumber.toString)
if (callNumber == "0123456789"){
logInfo("Alarm Call", "The numbers match...")
}
end
Can’t help, but i am interested in the use case. What’s your use case? You are inside your home and want to start a function by an outgoing call to a special number. Why?
There is a Alarmsystem which calls me by a special number. So when the Alarm triggers, all light should be switched on, the Rollershutters should go open, and so on
2018-04-01 12:39:21.708 [INFO ] [se.smarthome.model.script.Alarm Call] - The numbers match…
2018-04-01 12:39:21.713 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Alarm Call’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null