Monitor Telstra Arcadyan LH1000 monitor link type

Just want to share something that might help another Australian user.

I have a fibre to the premises broadband connection with a telstra provided Arcadyan LH1000 “smartmodem”. The modem fails over to 4G if the fibre drops. I wanted to know when this happens to investigate. No known api for the modem and I couldn’t find another technique, so I’m scraping the modem’s logon page to get the status of the link. I used phantomJS since I need to press a button before the status gets displayed properly.

phantomJS script:

var page = require('webpage').create();
page.viewportSize = {width: 1280, height: 1024};
page.open('http://192.168.0.1/login.htm', function(status) {
    this.evaluate(function() {
        document.getElementsByClassName("button-info")[0].click();
        });
     window.setTimeout(function () {
          var connecttype = page.evaluate(function() {
                return  document.getElementsByName("broadbandConnectionType")[0].innerText;
                });
          console.log( connecttype);
          phantom.exit();
    }, 3000);
});

I then used a command line sensor in my home assistant configuration.yaml

1 Like

Exactly what Im looking for.
Where do you run this from? (Sorry bit new to the script side of things)

This probably isn’t the most elegant solution.

First you need to install phantomJS somewhere on the Home assistant server.
I have:

  1. the phantomJS script (above),
  2. a shell script to run it and
  3. a “command line” sensor defined in my configuration.yaml

yaml: [ change the directory and script name as needed]

sensor:
  - platform: command_line
    name: Internet Status
    command: '/home/homeassistant/.homeassistant/phantomJS/monitor_telstra'

This shell script I introduced as I was occasionally having a null string returned (maybe when the router was slow in responding or timing out), It just reruns the scraping code if it gets nothing back. :

monitor_telstra shell script:

result=`/home/homeassistant/.homeassistant/phantomJS/bin/phantomjs /home/homeassistant/.homeassistant/phantomJS/monitor_telstra.js`
trimmed=`echo $result`
# if empty retry it 
if [ -z "$trimmed" ]; then 
   #retry
   echo `date` >> /tmp/monitor_telstra.log
   sleep 3
   result=`/home/homeassistant/.homeassistant/phantomJS/bin/phantomjs /home/homeassistant/.homeassistant/phantomJS/monitor_telstra.js`
   trimmed=`echo $result`
   echo $trimmed >> /tmp/monitor_telstra.log
fi
echo $trimmed

probably could do the “redo” logic inside the single phantomJS script to simplify.

The value of my sensor is “PPPoE routed mode” when the fibre is up.
I then have an automation that alerts me if this changes.

Here is a screen print of the modem’s login page: https://imagebin.ca/v/5LCNP0fBknFX
and this is data I’m getting: https://imagebin.ca/v/5LCNuEPnyfvb

This is what I ended up doing to keep it really simple.
Added ‘requests’ to python and then was able to do this.

- platform: command_line
  command: python3 -c "import requests; print(requests.get('http://192.168.0.1/login.htm').text.split('name=\"ledMobile\"',1)[1][12:16])"
  name: NBN Mobile Mode
  scan_interval: 300

It returns ‘off’ or ‘on’