arnonym/ha-plugins

FreePBX extension

Opened this issue · 4 comments

I have failed to get the add on to register as an extension with freepbx. Looks like this could be a clue in the logs.

null sound device..
15:14:02.080 pjsua_aud.c .Opening null sound device..
15:14:02.080 pjsua_core.c bind() error: Address in use [status=120098]
15:14:02.080 endpoint.cpp pjsua_transport_create(type, &tcfg, &tid) error: Address in use (status=120098) [../src/pjsua2/endpoint.cpp:2261]
Traceback (most recent call last):
File "/ha-sip/main.py", line 115, in
main()
File "/ha-sip/main.py", line 93, in main
end_point = sip.create_endpoint(endpoint_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ha-sip/sip.py", line 31, in create_endpoint
end_point.transportCreate(pj.PJSIP_TRANSPORT_UDP, sip_tp_config)
File "/root/.local/lib/python3.11/site-packages/pjsua2-2.14.1-py3.11-linux-x86_64.egg/pjsua2.py", line 6513, in transportCreate
return _pjsua2.Endpoint_transportCreate(self, type, cfg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pjsua2.Error
15:14:02.091 pjsua_core.c Shutting down, flags=0...

Looks like you already have a SIP client running on the same machine. Do you have the Voice over IP integration enabled? You need to change the port of this one, or ha-sip in the config.

I changed the port on the VoIP integration that receives incoming calls to recognise voice instructions. It is a trunk in freepbx.
It has moved me to a new problem. While other devices can register this extension from this network homeassistant is getting a 404 error.

10:33:47.356 pjsua_acc.c ..Acc 0: Registration sent
10:33:47.357 pjsua_core.c .RX 399 bytes Response msg 404/REGISTER/cseq=9552 (rdata0x7f083dcf8058) from UDP 192.168.4.5:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.5.49:5060;rport=5060;received=192.168.5.49;branch=z9hG4bKPjzVgrugvatpZMQIiVQiCbXc8LdcmMDlnb
Call-ID: XXswifeXVssD4aOTA2oBei4Xqf1sKp6L
From: sip:350@192.168.4.5;tag=sBzV0Zd.c-b2sqzsEr7bcS3M1wR4stwL
To: sip:350@192.168.4.5;tag=z9hG4bKPjzVgrugvatpZMQIiVQiCbXc8LdcmMDlnb
CSeq: 9552 REGISTER
Server: FPBX-15.0.37.4(16.30.0)
Content-Length: 0

--end msg--
10:33:47.357 pjsua_acc.c ....SIP registration failed, status=404 (Not Found)

A 404 error is usually the sign of a non-existing user. I never worked with FreePBX but might you need to use a username instead of the extension number?

FreePBX is a web based gui that sits in front of asterisk. Asterisk is the pbx behind the scenes.
The user name is the extension. I have confirmed that it works using other devices to log into the extension from the same network with the same credentials.
Other addons such as DSS VoIP notifier can also not register with the pbx from homeassistant. I have only been installing one sip addon at a time.

I have just tried disabling the trunk that talks to the VoIP integration for voice recognition in FreePBX. The extension can now register.
It seems that I need to send calls initiated by homeassistant down the same route as it recieves calls to the voip integration to keep the PBX happy.

Any ideas on how to have the two coexist happily on the same server?