neon.ninja

Sharing enlightening moments of home automation

All Green Lights on Cable Modem Connection Status

While I am still waiting to be connected to the NBN I have had quite a few shorter outages on my existing cable Internet connection, and wanted to improve the way Home Assistant recognises and deals with the loss of connectivity.

Connection Setup

I have a Netgear CM500V cable modem from Optus which in bridge mode simply connects to the cable network on one side, and has an Ethernet port on the other side for the connection to a router. I then use an Ubiquiti EdgeRouter X that manages traffic between my local network and the cable modem.

Alternatives considered

In this article I am particularly focusing on recognising the loss of connectivity into my Internet provider’s cable network. I looked at some alternatives but have discarded them for different reasons:

  • Ping a server on the Internet and report if the ping does not come through. The disadvantage of this approach is that I would really just check if that server is available including the network path to it.
  • Check the status of the WAN interface on my router. The EdgeRouter X provides a lot of details via SNMP, but I could not find anything suitable that would reliably determine the Internet connection status.

Approach chosen

The Netgear modem does not appear to really have any suitable APIs to interrogate and check the modem’s connection status. Then I looked at the web-based dashboard that you can access via http://192.168.100.1/ even when in bridge mode. The HTML and JavaScript code there looks like a dog’s breakfast, and Home Assistant’s standard scrape sensor would certainly not work in this scenario (I tried).

Netgear CM500V Dashboard

So I decided to implement a simple scrape binary sensor myself which fetches the HTML page and looks for a certain JavaScript code snippet that indicates if the modem is currently connected to the ISP’s network or not.

Netgear CM500V Dashboard JavaScript

Installation

You can find this custom component’s code in my GitHub repository.

In your configuration folder create subfolder <config>/custom_components and copy the folder netgear_cm500v from GitHub into the new custom_components folder.

Please note that there have been several changes in recent Home Assistant versions that affected the component structure, and the custom component file and folder structure in particular. Make sure that you run version 0.91 or later, and that you have the following folder structure underneath your configuration folder:

  • custom_components/
    • netgear_cm500v/
      • __init__.py
      • binary_sensor.py
      • manifest.json

I am assuming that you have set a password for accessing the modem’s dashboard, and this password is now required when configuring this custom component. The username is hard-coded to admin.

binary_sensor:
  - platform: netgear_cm500v
    password: !secret netgear_cm500v_password

Just in case your modem is available under a different IP address you can specify that as an optional parameter. Example:

binary_sensor:
  - platform: netgear_cm500v
    password: !secret netgear_cm500v_password
    ip_address: 10.0.100.1

The above configuration will generate a sensor with entity id
binary_sensor.internet_connection_status. I implemented this binary sensor with device class connectivity so that its state will be Connected or
Disconnected, and it will have a few extra device attributes:

AttributeDescription
device“Netgear CM500V”
ip_addressInternal IP address (default: 192.168.100.1)
internet_commentDescriptive state of the Internet connection, e.g. “In Progress” or “Good”

Because this custom component has been implemented as a binary sensor you can now use the sensor’s state for example as an automation trigger to switch over (and switch back later) to your backup Internet connection, or as a condition in an automation to prevent updating a sensor from a web service that would not be available as long as the Internet connection is down.

Connection Status – more info dialogue

Outlook

I am expecting that NBN will be available at my home from around July this year, and as many others I will be one of the many that will be connected via HFC (Hybrid Fibre Coaxial) and will have to share the cable connection with all of my neighbours in the future. I am pretty sure that I will get a new cable modem as part of the NBN rollout, and I will have a look at its capability to determine the Internet connection status to integrate that into Home Assistant as soon as possible.

Compatibility

At the time of writing this post, I used:

  • Home Assistant 0.91.3 with Python 3.6.7
  • Netgear CM500V (Hardware Version: V02 and Firmware Version: V1.01.08)

Comments

2 responses to “All Green Lights on Cable Modem Connection Status”

    1. malte Avatar
      malte

      Thanks, mate.

Leave a Reply

Your email address will not be published. Required fields are marked *