Card
Now we have a PBX to connect to, we can install the card.
warning
The card only works in HTTPS. This is required by the browser to send your mic/cam trough. You can use something like Duck DNS or Let's Encrypt.
Installation
- HACS
- Manual
- Go to HACS
- Click on Frontend
- Click on the 3 points in the upper right corner and click on Custom repositories
- Paste
https://github.com/TECH7Fox/HA-SIP/
into Add custom repository URL and by category choose Lovelace - Click on add and check if the repository is there.
- You should now see SIP Client. Click INSTALL
- Go to the latest release on github.
- Copy
sipjs-card.js
to/www/
. - Add
sipjs-card.js
to resources.
Configuration
- In edit mode, click on add card.
- Search for SIP Card.
Now we need to configure it.
tip
Most things are configurable from the editor, except for the ICE settings. We recommend using the card editor for all other settings.
type: 'custom:sipjs-card'
server: 'your-local-ip' # Set your local HA IP here!
prefix: '' # If you have a prefix in your URL you can add it here.
port: '8089' # WSS default is 8089.
video: false # Send and receive video. Can require extra configuration.
auto_answer: false # Auto-answer when called.
hide_me: false # Hide the extension your registered as.
state_color: true # Show the set entity state in the icon.
custom_title: ''
ringtone: /local/asterisk/ringtone.mp3 # Optional, this points to /www/asterisk/ringtone.mp3
ringbacktone: /local/asterisk/backtone.mp3 # Optional, this points to /www/asterisk/backtone.mp3
button_size: 42
extensions: # Set here the WSS extensions you can register as.
- person: person.person1 # Your first person entity here
name: Person1
extension: '100'
secret: 'your-auto-generated-secret' # Set the auto_generated_secret you set in the add-on here!
icon: mdi:monitor
entity: binary_sensor.sensor1
camera: ''
- person: person.person2 # Your second person entity here
name: Person2
extension: '101'
secret: 'your-auto-generated-secret' # Set the auto_generated_secret you set in the add-on here!
icon: mdi:monitor
entity: binary_sensor.sensor1
camera: ''
custom: []
dtmfs: []
buttons: []
caution
If your new options doesn't seem to be working, make sure to clear your browser cache and refresh the card. In your browser press F12, check Clear Cache and press ctrl + F5 to fully refresh the page.
caution
If you don't use some arrays like custom
, dtmfs
or buttons
, make sure to include the empty arrays as shown in the example above.
Otherwise you will get a Cannot reach properties of undefined (reading 'foreach')
error.
Now you might get a 9006
error. That's because the certificate doesn't match the domain. (in this case the server option)
So now we need to fix SSL.
SSL
WSS (Secure WebSocket) requires SSL for security reason. The add-on set's up Asterisk's part of that, but you still need to setup your network to work with it.
Manual
You can temporary accept the certificate manually by going to https://<YOUR-HA-ADDRESS>:8089/ws
, click continue and accept. You should see Upgrade Required
.
Now your browser accepts this certificate, even if the domain doesn't match.
warning
Warning! This only works for a couple days max. When the certificate changes you have to do this again.
This is not a permanent solution!
Port Forwarding
Best way is to port forward 8089
. Then you can set the server
option to your domain. But then you also need to forward the RTP ports, which is by default 10000-20000
.
caution
If you do this, make sure you have secure passwords for your extensions! Bot's may try to brute-force it.
If that happens often, you could set 8089
to another non-standard port.
DNS Rewrite
It's possible to set a DNS rewrite in your router, so your certificate domain points towards your local IP. This way you don't have to port forward anything, but this only works locally.
You can find more info here.