Call telephone from rule

I would like to create a rule that calls my telephone and plays a short audio file. (e.g. if a smoke detector detected a fire)

I found a guide here

Sadly the sipcmd command does not seam to work with my sip provider. ( I’ve already created an issue on GitHub but I don’t expect an answer soon because the developer seams to be inactive.

Are there any other examples on how to make a call using SIP to a “real” phone number in OpenHab? I also found some Java librarys for sip. Has maybe someone has already created a plugin to do this?

There isa binding and integration instructions for integration with Asterisk. If you can get Asterisk to work with your SIP provider (probably very likely) you can use it to bridge between SIP and OH.

Yep I do this using the Freeswitch service in mqttwarn. I obviously have Freeswitch setup at home for my VOIP calls and it was relatively easy to set it up for my SIP provider. When I want to make an announcement I just publish the message to a special MQTT topic (in openHAB using the MQTT binding) and mqttwarn picks this up, initiates a call using Freeswitch and plays it using a TTS URL of your choice.

I used to use the Google TTS service but that has changed recently so I now use a local service (see here).

Thanks for the tipps, but I’am looking for a simpler solution which doesn’t require additional services. There are serveral java sip libraries, but I didn’t found any good examples on how to initiate a call with the. Is there no good alternative to sipcmd that works directly with my sip provider?

Perhaps this is a dumb question: Who is your SIP provider? And did you have a look at their webpage to see if they have a FAQ or developer section?

I’m going to guess here, and say he doesn’t have one. Which is likely why he’s confusing SIP with being able to make a call. SIP is just a protocol for calls, it’s not a way to “make a call”. To make a call, you need a SIP provider, not just some java implementation of SIP. Installing Asterisk will give you a “provider” that is local, but you still need a way for that Asterisk to make the call(usually done with SIP, or like mine were it was a ton of T1’s). Asterisk will basically be the middle man between whatever application you want(OH), and a SIP provider.

Or you can try to go down the path of using one of the java implementations, but it’s not going to be a fun trip. Asterisk is pretty easy to get going, but requires about the same love for editing files as OH does, it can be a bit tricky. I used to manage an Asterisk box w/ about 40 extensions, and I also installed it from scratch, etc, so I do tend to think I know what I’m talking about.

Short answer for your question is it’s likely not going to happen without an outside service.

I’am using the provider. (Server But that provider doesn’t seam to work with sipcmd as I described here:

Does anyone have an idea what could be the problem there and how this could be solved?

I have now decided to use Asterisk for the alarm calls because every other solution seams to be unstable or with very bad audio quality. I’ve written an expect script to communicate with Asterisk directly using telnet. This script accepts a parameter containing multiple telephone numbers. Every number will be called until one call is picked up:


set i 0
set telnrstring [lindex $argv 0];
set telnrlist [ split $telnrstring , ]
set arrsize [llength $telnrlist]
set currentnr [lindex $telnrlist $i]

spawn telnet 5038 
expect "Asterisk Call Manager/*\n"
send "Action: Login\n"
send "Username: manager1\n"
send "Secret: mysecret\n"
send "\n"
expect "Status: Fully Booted"
set timeout 60

proc callnext {currentnr} {
    send "Action: Originate\n"
    send "Channel: SIP/Fritzbox/$currentnr\n"
    send "Application: Playback\n"
    send "Data: silence/1&Smokealert&silence/1&Smokealert&silence/1&Smokealert\n"
    send "Context: default\n"
    send "Exten: 2001\n"
    send "Priority: 1\n"
    send "Rauchalarm\n"
    send "\n"

callnext $currentnr

expect {
  "Message: Originate failed" {
	incr i
    if {$i < $arrsize} {
      set currentnr [lindex $telnrlist $i]
      callnext $currentnr
  "Value: SUCCESS" {

send "Action: Logoff\n"
send "\n"
expect "Response: Goodbye"
1 Like

Out of curiosity, why did you decide not to use the Astrisk binding?

Regarding the OpenHAB wiki the binding can just handle incoming calls. But I want to initiate an outgoing call which plays an audio file three times, then hangup the phone. Or ist this also possible using the binding?

A quick scan of the wiki pages seemed to indicate it was but a closer reading shows it primarily receives data. It might be worth adding this script to the Asterisk Integration Wiki page.

Hi sir can you show us your configurations and steps to add this function to our system

@TheNetStriker Very useful script for calling out from OpenHAB. - Thanks for sharing.
Got it running from the command line, making Asterisk dial to a 7170 Fritz!Box that serves as a SIP provider to in-house phones and other slave 7270 Fritz!Boxes that provide DECT (send “Channel: SIP/sip_proxy-out/$currentnr\n” and setting that up as a peer).
I will use this with OpenHAB’s exec binding and wanted to set a spoofed caller ID so that upon ringing a specific message is delivered in the display without the need to answer the call - e. g. which sensor triggered where. (Still ends up in the “missed calls” list with timestamp then.)
So after your Context: line, I added a hardcoded …
send "CallerID: \"Rauch OG2\"<234>\n"
… however only the spoofed “virtual” telephone number shows up on the telephone displays, not the string, whilst in Asterik’s extensions.conf, this line does work:
same => n,Set(CALLERID(all)="Rauch OG2"<234>)
(I could work around this by adding telephone book entries for all these “virtual” numbers but do not want to.)
Once this works, it would give fine-grained notifications in rules and could be further enhanced by depending on variable values like arming states for groups of sensors like:
rule "alarmPresent" when Item motionSensor1 changed from OFF to ON and isArmedPresent then var String myExec=executeCommandLine("/etc/asterisk/\"Bewegung OG2\"<123>") logInfo("exec","myExec = {}",myExec) end