Device tracker for Arcadyan VGV7519 router (Experia Box V8)

A device tracker which I created with the custom_components option.

Update by @mrgoldy for 0.116.x: Device tracker for Arcadyan VGV7519 router (Experia Box V8)

Usage:
Create a file named experiaboxv8.py in /config/custom_components/device_tracker/

in configuration.yaml use:

device_tracker:
  - platform: experiaboxv8
    host: <IP OF ROUTER>
    username: Admin
    password: <PASSWORD>
    track_new_devices: no

Copy past this code in experiaboxv8.py:`

"""
Support for Arcadyan V7519 router.
"""
import base64
import hashlib
import logging
import re
from datetime import datetime

import requests
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and return a Arcadyan AP scanner."""
    try:
        return ArcadyanDeviceScanner(config[DOMAIN])
    except ConnectionError:
        return None


class ArcadyanDeviceScanner(DeviceScanner):
    """This class queries a wireless router running Arcadyan firmware."""

    def __init__(self, config):
        """Initialize the scanner."""
        host = config[CONF_HOST]
        username, password = config[CONF_USERNAME], config[CONF_PASSWORD]

        self.parse_macs = re.compile('[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}')

        self.host = host
        self.username = username
        self.password = password

        self.last_results = {}
        self.success_init = self._update_info()

    def scan_devices(self):
        """Scan for new devices and return a list with found device IDs."""
        self._update_info()
        return self.last_results

    # pylint: disable=no-self-use
    def get_device_name(self, device):
        """Get firmware doesn't save the name of the wireless device."""
        return None

    def _update_info(self):
        """Ensure the information from the Arcadyan router is up to date.
        Return boolean if scanning successful.
        """
        _LOGGER.info("Loading wireless clients...")

        login_url_initial = 'http://{}/login.stm'.format(self.host)
        page_initial = requests.get(login_url_initial)

        httoken_search = re.search("var _httoken = '(.*)';", page_initial.text)
        authenticity_token = httoken_search.group(1)

        login_payload = {
            "user": self.username, 
            "pws": self.password, 
            "httoken": authenticity_token
        }

        clear_payload = {
            "securityclear.y": "8",
            "securityclear.x": "57",
            "httoken": authenticity_token
        }

        login_url = 'http://{}/cgi-bin/login.exe'.format(self.host)
        start_page = requests.post(login_url, data = login_payload)

        clear_url = 'http://{}/cgi-bin/statusprocess.exe'.format(self.host)
        clear_log = requests.post(clear_url, data = clear_payload)

        data_url = 'http://{}/status_main.stm'.format(self.host)
        data_page = requests.get(data_url)

        result = self.parse_macs.findall(data_page.text)

        logout_url = 'http://{}/cgi-bin/logout.exe?_tn='.format(self.host) + authenticity_token
        log_out_page = requests.get(logout_url)

        if result:
            self.last_results = [mac.replace("-", ":") for mac in result]
            return True

        return False
2 Likes

Seems like a great component! Exactly what I was looking for, since I have a telfort Experiabox. I’m going to give it a try. Thanks for sharing!

MvdB,
Thanks for this post, was just what I was looking for, have added the Device tracker in the configuration.
and created the experiaboxv8.py, there was no directory path /config/custom_components/device_tracker/
under my .homeassistant directory so created that and placed the py file in there but when I do a config_check it gives me an error:
General Errors:
- Platform not found: device_tracker.experiaboxv8
Did I place the file in the wrong position, or am I over looking anything.

Thanks CJ

I have the same error. I also created the path because it wasn’t there in /home/homeassistant/.homeassistant.

Did you figure out?
Any help appreciated

I’m using the Hass.io image, which has a share called config. There I created the directory custom_components and subdirectory device_tracker. In that directory I created the .py file.

It works and is detecting my devices in known_devices.yaml.
Did you add this file to a fork of https://github.com/home-assistant/home-assistant?
I would like to help to get a pull request accepted.

Thanks Tiemco

Hi Tiemco,

No, I have not added this file into Github. If you want u can :slight_smile:

Mark

Is there a way to prevent overpolling the router?

The server has temporarily run out of resources for your request. Please try again at a later time.

I have set interval_seconds to a higher number but maybe there are other options as well?

Hi All,
Just signed up because i started using Home Assistant a week or so ago. I really like the idea of the device tracker but cant get it to work.
I think i did all i need to do, but the Home Assistant configuration is telling me the platform is not found.

After tripple checking the folders and filename i did some googling but i could not find anything.

Is there anybody that has a tip to get this working?
I’m running the last stable version on a RPI3.

Thanks!
Geert

In a release a while ago the path should be diffrent: /config/custom_components/device_tracker/
This should be changed to /config/custom_components/ experiaboxv8/device_tracker.py

Thank you Timo,
Just tried this. I created a new folder and file with the path you stated but still get the notification:
“Integration experiaboxv8 not found when trying to verify its device_tracker platform.”

Do i need to change anything more?

quick update: I just changed to pinging the deviced and abandoned this path…

Just not get it working, latest version with Hass.io. Trying to change folder locations, naming reversed like remark above but every time getting an error:
2019-10-23 12:35:04 ERROR (MainThread) [homeassistant.config] Platform error: device_tracker - Integration ‘experiaboxv8’ not found.
Any suggestions? My guess is that it has to do with Hassio, wrong location of files?

No, like @GeertH I also moved to pinging the device for now.

@MvdB
Hi Mark,

This tracker looks good. I am trying to port it to Domoticz,not much success so far.
The first problem is how to login to the VGV7519. Can you give me the syntax what to send to the VGV7519

Thanks in advance.
McMelloW

I’ve made this integration work in the latest version(s).

You have to create the following file structure:

custom_components/
  experiaboxv8/
    __init__.py
    device_tracker.py
    manifest.json

The __init__.py file can be left empty.
The device_tracker.py file should contain the aforementioned script.
The manifest.json should contain the following:

{
  "domain": "experiaboxv8",
  "name": "experiaboxv8",
  "documentation": "https://community.home-assistant.io/t/device-tracker-for-arcadyan-vgv7519-router-experia-box-v8/29362",
  "dependencies": [],
  "codeowners": ["Mark van den Berg (@MvdB)"],
  "requirements": []
}

Then you’ll have to restart your HA (required for new integrations to show up).
Then you can add the aforementioned device_tracker platform to your configuration.yaml.
If you then do a Check configuration you should receive no errors, so you can restart HA again.

1 Like

Nice, will test it this week.

Does this script also handles the amount of log ins?

Hi Timo, This can be handeld with the interval setting, see also the documentation on Device tracker.

interval_seconds: 10
1 Like

Added the component today, by reading the home-assistant.log and rebooting several times, the following manifest.json adds the component:

{
    "domain": "experiaboxv8",
    "name": "experiaboxv8",
    "documentation": "https://community.home-assistant.io/t/device-tracker-for-arcadyan-vgv7519-router-experia-box-v8/29362",
    "requirements": [],
    "dependencies": [],
    "codeowners": ["Mark van den Berg (@MvdB)"],
    "iot_class": "local_polling",
	"version": "1.0.0"
}

I vond op dit forum o.a. van jou detail kennis van de firmware voor de [Arcadyan VGV7519 router (Experia Box V8)]. En op andere sites heb ik niet gevonden wat ik ik wilde weten.

Het heeft weinig of geen relatie met Home assistant, maar over de firmware en configuratie van deze router. Zoals bekend wil KPN geen technische kennis delen of alternatieve configuraties openbaren. Ik ben vooral op zoek naar de mogelijkheid om de POTS poorten van de VGV7519 te gebruiken. Ik heb tot vorige week zo eentje gebruikt en verbonden met een SIP centrale, tot deze het begaf. En ik kom tot het inzicht dat KPN helemaal geen enkele mogelijkheid meer openstelt om met externe SIP diensten te koppelen, andere dan hun eigen. En dus heb ik een andere VGV7519 aangekocht, maar die blijkt nu ook te zijn voorzien van nieuwere firmware (Firmware Version:02.00.138) waarmee ik nog steeds de VOICE poorten niet aan pbxes.org kan koppelen. Heb je hints of koppelingen waar ik de oplossing kan vinden ?
Ik heb nog te weinig kennis van de manier waarop KPN de firmware manipuleert, hoe de “verborgen” configuratiepagina’s in elkaar zitten, wat de RESET knop nu precies doet, en hoe ik de oorpronkelijke firmware van Telfort weer kan activeren.

Willem