Asterisk binding problem [SOLVED]

Hi everyone,
I’m trying to use the Asterisk binding with openHAB but I run into some problems.

I’m using openHABian with openHAB 2.1.0-1.
I installed the following binding org.openhab.binding.asterisk-1.11.0-SNAPSHOT.jar and added the asterisk.cfg with the right connection parameters.
I also configured the acces into Asterisk’s manager.conf file.

In openHAB I get the following errors when I save the asterisk.cfg file:

2017-10-01 21:15:20.025 [ERROR] [org.apache.felix.configadmin        ] - [org.osgi.service.cm.ManagedService, id=309, bundle=190/file:/usr/share/openhab2/addons/org.openhab.binding.asterisk-1.11.0-SNAPSHOT.jar]: Unexpected problem updating configuration org.openhab.asterisk


java.lang.IllegalStateException: Logoff may only be perfomed when in state CONNECTED or RECONNECTING, but connection is in state DISCONNECTED
	at org.asteriskjava.manager.internal.ManagerConnectionImpl.logoff(ManagerConnectionImpl.java:784)[190:org.openhab.binding.asterisk:1.11.0.201709280110]
	at org.asteriskjava.manager.DefaultManagerConnection.logoff(DefaultManagerConnection.java:305)[190:org.openhab.binding.asterisk:1.11.0.201709280110]
	at org.openhab.binding.asterisk.internal.AsteriskBinding.disconnect(AsteriskBinding.java:130)[190:org.openhab.binding.asterisk:1.11.0.201709280110]
	at org.openhab.binding.asterisk.internal.AsteriskBinding.updated(AsteriskBinding.java:78)[190:org.openhab.binding.asterisk:1.11.0.201709280110]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1772)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.12]
	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.12]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

Looks like Asterisk binding is not in Openhab2 standard addons. Is it still supported?
If yes, does someone have an idea what’s going wrong in my configuration?

Thanks

There’s an asterisk binding built into smarthome in OH2. So you should probably remove the 1.11 asterisk jar and just try using the smarthome version.

It appears I confused the asterisk binding with the astro binding. Please disregard.

Have you tried restarting OH? That should, in theory, work to pickup your changed settings.

Hi namraccr,

Thanks for your sugestion but restart didn’t help (I rebooted my device).

I noticed that this error message came only when I change the parameters value in the asterisk.cfg file. Not if I do a “false” change.

Putting a right or wrong user/password don’t change anything in the error message. I was expecting a connection refused message if I used a wrong password.

From what I see in the calling stack the asterisk addon is used by openhab or am I miss (I’m not used with Java)?

Is there any newer version than 1.11.0 for the astersik binding?

Well I did some progress.
I dive into the code and followed the error’s call stack.

I understanded that it didn’t even tried the username and password. It stops before. Looks like the connection state is hold internally and Openhab can’t get out of it.

I remembered that the first time I installed the addon I got a connection refused. So I unsintalled the addon by removing the file and reinstalled it. This give me back the connection refused message. Strange because asterisk.cfg and manager.conf were set accordly.

I double checked those files and found that I had to change also the bindaddr in the manager.conf file. After that and reinstalling the addon, the connection was possible but with some warnings:

2017-10-03 23:16:05.312 [WARN ] [nager.internal.ManagerConnectionImpl] - Unsupported protocol version 'Asterisk Call Manager/2.10.0'. Use at your own risk.
2017-10-03 23:16:05.371 [WARN ] [va.manager.internal.EventBuilderImpl] - Unable to set property 'eventlist' to 'Complete' on org.asteriskjava.manager.event.StatusCompleteEvent: no setter. Please report at https://github.com/asterisk-java/asterisk-java/issues
2017-10-03 23:16:05.373 [WARN ] [va.manager.internal.EventBuilderImpl] - Unable to set property 'listitems' to '0' on org.asteriskjava.manager.event.StatusCompleteEvent: no setter. Please report at https://github.com/asterisk-java/asterisk-java/issues

What protocol version is supporter for Call Manager?
No setter and probably no getter. Will that addon for openhab 1 work with openhab 2.1?

Those warnings come from the asterisk library, not OH. They appear to indicate you’re connecting to an asterisk system that isn’t fully supported by the asterisk library.

But it sounds like the binding is working in spite of these warnings.

Indeed it is working!

I had time this evening to test it .

The problem was that once the connection is refused, the addon is in a disconnected state and stay stuck in that state whatever you change in the configuration file.

The solution was to set correctly the ip, username and password in OH’s asterisk.cfg file and allowing remote connection in asterisk’s manager.conf file before installing the asterisk addon.

Thanks namraccr for your explanations.

I’m new to openhab and I’m looking for an asterisk binding. Can I ask, where did you find ‘org.openhab.binding.asterisk-1.11.0-SNAPSHOT.jar’ and how did you install it? I cannot see it in the Paper UI when I search the available bindings.

openhabian@openHABianPi:~$ uname -a
Linux openHABianPi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux

openHAB 2.1.0-1 (Release Build)

Hi Randall,

First configure the Asterisk Manager Interface (AMI) on your Asterisk box to allow remote connection from OpenHAB.

Here is what I have in the /etc/asterisk/manager.conf file:

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+

[admin]
secret = PUT_HERE_AMI_PASSWORD
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
permit=PUT_HERE_IP_OF_OPENHAB/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
writetimeout = 5000

You have to put bind address to 0.0.0.0 so AMI listen to all your network connections.

Second on your openhab box, create a file in /etc/openhab2/services/asterisk.cfg:

############################### Asterisk Binding ######################################
#
# Please note: The Asterisk Management Interface (AMI) has to be activated in the
# manager.conf file of your Asterisk PBX.

# hostname of the AMI
host=PUT_HERE_IP_OF_ASTERISK

# the username and password to login to the AMI
username=admin
password=PUT_HERE_AMI_PASSWORD

Third Download astersik addon from here. Note this is for OpenHAB 1 but it works for OpenHAB 2.

Fourth open the OpenHAB log (http://openHABianPi:9001) in your favorit browser so you can follow the installation of the addon.

Fifth and last copy the jar file into the directory /usr/share/openhab2/addons/

You should see something poping in the log. In my case thre were warning as descritbde in my previous post but despite that it works.

To uninstall the addon, just remove it from that same directory.

Good luck

Thank you for the excellent instructions Alex!