Connect FreePBX and Home Assistant

Once FreePBX installed, We'll link him to Home Assistant.

Add a Manager Asterisk

Allow Home Assistant IP

192.168.1.200 in my example

Correct bindadrr in /etc/asterisk/manager.conf

Simply edit the /etc/asterisk/manager.conf file from an SSH command line

nano /etc/asterisk/manager.conf

replace bindaddr = 127.0.0.1 by bindaddr = 0.0.0.0

Optional, if you want, you can check that Manager (AMI) indicates well Yes by going to the Asterisk console:

asterisk -r

and then by questioning him:

manager show settings

Install Asterisk-hass-integration

Everything is explained in the extension doc

https://github.com/TECH7Fox/asterisk-hass-integration

Add Asterisk integration

Identify your user on the integration

And this is the drama.

For an unknown reason, since version 1.x of the integration, the equipment does not go back:

So we will change the version and go back to the version v0.9.8

We relaunch Home Assistant

Device and Entity Management

And here, at the relaunch, the devices (1 server + 3 lines) and the corresponding entities appeared.

There is a dedicated Card 

Go to HACS and then deposit customize, you can find this card (from the same author as the integration)

https://github.com/TECH7Fox/sip-hass-card

I tested this card but it allows me to make and receive calls, I am not interested, my home automation does not phone. I will use the information provided by the Asterisk-hass-integration integration to detect a call.

What information is retrieved?

The Asterisk Server

He gives me two pieces of information, the first is to Success, we are very happy to have succeeded, at this stage I do not know what, but as long as it remains to Success, I imagine it is a good sign. For the second information, Lastest DTMF Signal, I pressed all the keys to try to see what it refers to, we will see in time. I will come to complete this text if I understand.

Finally, we see that my three lines 100, 201 and 203 are well connected to the server, very well.

Lines

Callee

In this entity, we will find the number of the correspondent.

The number of the caller at the addressee and the number of the addressee at the caller.

channel

This entity provides link information. If 100 phones at 201, both will have the same channel, we know that they are in communication.

Registered

Obviously, this is to check that the extension is well identified and connected to the server.

It is interesting to have this in order to be able to signal a disconnection. When the extension is no longer registered, the value ‘Disabled’ appears. I have noted that switching off is quite fast if you disconnect equipment.

State 

Can take values:

UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING | RINGINUSE | ONHOLD

But overall, I used:

  • RINGING when it rings
  • INUSE when I am in communication (or when the caller rings)
  • NOT_INUSE the rest of the time

What concrete applications now?

If, as in my case, one of the lines is the doorman, one can imagine:

  • Relay the doorbell on the doorman with music, an Alexa message or any sound or light information.
  • To support the doorbell, turn on the external lights
  • If there is no one in the house, receive a notification on the phone with a photo of the entrance camera