Parsing BT Home Hub 5 statistics

In an earlier post, I experimented with retrieving date usage and uptime stats from a BT Home Hub 5A, and cobbled together a PHP class to automatically load a privileged page. With access to the data, I need to parse it before committing the results to a persistent database. Step in regex…

Parsing results

I want uptime and data usage, and the ‘helpdesk’ page – ID 9140 – is the most useful. According to BT’s own page description:

When contacting the BT Broadband helpdesk, the agent might ask you for details about your BT Home Hub. This page contains all of the information they are likely to request.

There are 2 entries of interest which we’ll extract with regex as I don’t want to install a DOM parser and I’m not sure if the page itself is valid HTML anyway.

I ended up with:

// Looks for the wait variable and extracts digits before a semi colon
preg_match(‘/wait = (?<uptime>\d*?);/si’, $body, $matches);

// Looks for the data sent/received row and gets the text before the end of the cell tag
preg_match(‘%11. Data sent/received:</td>.*?>(?<data>.*?)<%si’, $body, $matches);

I then process the data usage further so the units always return in MB’s. While researching this topic, I noticed that several people said that the data counters reset when a certain quantity is reached – around 5GB I believe. As my usage is around 500GB a month, I’ll be dealing with lots of a roll-over’s. I’ll have to monitor the data and optimise the collection process when I know the exact roll-over point.

I found while monitoring a download – hitting refresh to get the latest usage figures – that the HH would eventually run out of sessions to hand out, and you get an error telling you to wait for them to expire. I’ve updated my original approach of logging in to try and reuse an existing connection rather than starting a new one.

For the time being, I’ll just save the data collected and it can be analysed at a later date. The complete code is available at the bottom of this page.


GitHub –

One thought on “Parsing BT Home Hub 5 statistics”

  1. Hi,
    After update ( had to adjust login page in HomeHub5.php to
    const LOGIN = 9146;

    To allow it to work again.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.