Monitoring my VOIP provider with Home Assistant

The worst time to find out that your telephones aren’t working is when you pick up the phone to try to make a call.

David Cameron
May 29, 2017 · 3 min read

I have a small Cisco ATA (SPA122) that sits in my basement and connects to all of the telephone ports throughout the house. It has two VOIP provider lines on it, and generally provides us with pretty reliable telephone service at a reasonable monthly rate.

In order to make it more reliable, I was going to have to figure out a way to identify when it wasn’t working.

Reading the Cisco ATA API documentation

I found out that the Cisco ATA (SPA122) has documentation readily available for business level deployments for automating the configuration. I also discovered that there was an XML document that tells you the status of the router that is easily accessible at /admin/status.xml&xuser=*****&xpassword=*****

This would allow me to check to see if the phone lines were connected properly with my VOIP provider. Next I needed to integrate it with something to notify me when things weren’t working.

Integrating it into Home Assistant

I use home-assistant.io as a home automation platform in my house. What’s great about it is it’s written in Python, open source, and has a large community surrounding it. Unfortunately, there wasn’t anything already built for my Cisco ATA. In order to get the phone line data into Home Assistant I was going to have to write something myself.

There are 2 components that are necessary for this to work. I needed to write a python utility that could connect to the ATA and grab the status information so that it could be used within Home Assistant to display that data.

I decided to write, an open source my first python module called pyciscsospa you can download it and use it for your own ATA as well.

I then needed to write a custom component to display the phone data that leverages the python module.

Home Assistant Config

In order to integrate with Home Assistant I added the following configuration:

sensor:
- platform: ciscospa
host: 192.168.1.XX
monitored_variables:
- registration_state
- hook_state
- last_called_number
- last_caller_number
- call_state
- call_peer_name
- call_peer_phone
- call_type
- call_duration

In order to receive a push notification on my phone when the phone lines go down and come back up, I added the following automation to my setup.

automation:
- alias: "Notify when phone offline"
trigger
:
platform: state
entity_id: sensor.phone_1_registration_state
from: 'Registered'
to
: 'Failed'
action
:
service: notify.pushover
data_template:
title: "Home phone offline"
message
: "Line 1 is down right now."

- alias: "Notify when phone online"
trigger
:
platform: state
entity_id: sensor.phone_1_registration_state
from: 'Failed'
to
: 'Registered'
action
:
service: notify.pushover
data_template:
title: "Home phone is back online"
message
: "Line 1 is back online"

I’m now notified as soon as there is an issue with my VOIP system at home. Currently the custom component is not available as part of the Home Assistant project, but if you’re interested in using it let me know and I’m happy to share.

David Cameron

Written by

Product Manager, Experiments with Home automation, Arduino and gardening.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade