[Component] Experiabox V10A device tracker (KPN)

After reading sjaakiejj’s topic about a custom component to use an experiabox V10 as a device_tracker, I tried to use it on my Experia Box V10A, which didn’t work.

Because of that I’ve decided to create a custom component which is heavily inspired by
MvdB’s device_tracker for the V8
sjaakiejj’s device_tracker component for the V10
and the nmap device_tracker component

(Since I’m a new user, I cannot put more than 2 links in a post, if you want to see the V8 and/or V10 posts you have to search in these forums yourself)

Anyways, here’s the GitHub project:

Let me know what you think about it, oh and I welcome PR’s!

Happy device_tracking!

3 Likes

This wasn’t working at first, but I found that I put http:// before the IP. It is working now but it slowed the startup and the Hassio way down - is this normal for the first times?

What I’ve observed is that sometimes the Experiabox starts giving timeouts on the GET /cgi/cgi_clients.js call (This call is used to fetch the actual devices that are online).

This can be worked around by rebooting the Experiabox. Not sure what is the root cause.

If this cgi_clients call is troublesome I can rewrite the component to scrape the wifi_log.htm page. However, this will not report the clients associated with the Experia Wifi device (they show up as LAN device in cgi_clients.js or the “Connected Devices” page)

As to slowing down startup: I’ve updated the component so it will not wait for a response infinitely, it will time out after 5 seconds. This will probably solve your “slow startup”, please let me know

1 Like

Does this component also work on the V8?

This component is built to use with the V10A.
There’s also a component for the V8:

1 Like

Hi, I’m trying this tracker but can’t get it to work.
I’ve uploades the files to custom_componentent/experiaboxv10a

# Device Tracker
device_tracker:
  - platform: experiaboxv10a
    host: 192.168.2.254
    username: admin
    password: !secret KPN
    interval_seconds: 10
    consider_home: 180
    new_device_defaults: 
      track_new_devices: true

This is in my configuration.yaml

I get an “bad handshake error” certificate verify failed

Can you try host: mijnmodem.kpn ?

Thanks. This tracking method works better than any other tracking events I have used. Cheers.

Hi FrankZZ, thanks for this script! I was looking for this. Got it installed but get an error in HA. Tried both the IP adres and “mijnmodem.kpn”

any idea what goes wrong? I run HA in docker on a synology NAS ds218+. Below is my configuration and the error code.

device_tracker:
  - platform: experiaboxv10a
    host: mijnmodem.kpn
    username: admin
    password: ********
    interval_seconds: 10
    consider_home: 180
    new_device_defaults: 
      track_new_devices: true
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 485, in wrap_socket
    cnx.do_handshake()
  File "/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1934, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1671, in _raise_ssl_error
    _raise_current_error()
  File "/usr/local/lib/python3.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
` ` `

Hi FrankZZ,

In this script for the V10a I noticed device tracking is also possible on the Experia WiFi devices.
I see your script is based on the Experiabox V10 and I was wondering if it would be possible to change the script so that device tracking is also possible on WiFi versterkers connected to a V10?

Thanks,
Erik

Hi Chronos,

I had the same error. I managed to solve it by adding “verify=False” to the session initialisation in the device_tracker.py
I also changed all “http” to “https” for good measure at the same time, so it might be that both are needed.

This is my first dabble at python and the only development experience I have is light scripting, so don’t pin me on this be the end all solution for this, but I hope it might steer you in the right direction.

Cheers

It’s cool to see people using my component. I will update it probably tomorrow or Friday to fix the issues you are having, please stay tuned!

Hi Erik, this component is specific for the V10A. There is a device_tracker already for the V10:

Hi FrankZZ, I know about and installed the device_tracker for the V10. :+1:
The problem is that it doesn’t track the 3 (witte) WiFi versterkers (configured as Accesspoint) connected to my V10. Once it connected to only 1 of the 3 but also no device connected to the WiFi versterker were tracked.

Update: I’ve pushed and released version 0.2.1 of this component which includes the fixes for HTTPS verification.
It’s also a tad quicker because I could shave off one request every time it updates devices.

Tested it and worked for me, please let me know!

Hi Erik,

Are you talking about this particular device?
https://gathering.tweakers.net/forum/list_messages/1882915

if so, I can try to spend some time later to scrape it, which will probably be a separate component

Hi FrankZZ,

No I’m talking about the old ones:
https://tweakers.net/pricewatch/457255/kpn-wifi-versterker-dualband-arcadyan/specificaties/

Ah, I see. I don’t own such a device, which makes it very hard to support it.

I gave this component another try, but I can’t get it to work. This is my config (the # is the ones I tried to turn on and off, but no luck). Can anyone see what I am doing wrong?

device_tracker:

#device tracker experia
  - platform: experiaboxv10a
    host: mijnmodem.kpn
#    host:  
    username: admin
    password: !secret routerwachtwoord
#    new_device_defaults:
#      track_new_devices: true
#      hide_if_away: False
Log Details (ERROR)
Wed Apr 22 2020 20:58:28 GMT+0200 (Midden-Europese zomertijd)
Error setting up platform legacy
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 334, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x703d78f0>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mijnmodem.kpn', port=443): Max retries exceeded with url: /login.htm (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x703d78f0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 65, in async_setup_legacy
    self.platform.get_scanner, hass, {DOMAIN: self.config}
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/experiaboxv10a/device_tracker.py", line 32, in get_scanner
    return ExperiaBoxV10ADeviceScanner(config[DOMAIN])
  File "/config/custom_components/experiaboxv10a/device_tracker.py", line 58, in __init__
    self.success_init = self._update_info()
  File "/config/custom_components/experiaboxv10a/device_tracker.py", line 96, in _update_info
    page_initial = session.get(login_url_initial, timeout = 10, verify = self.ca_cert_bundle)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='mijnmodem.kpn', port=443): Max retries exceeded with url: /login.htm (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x703d78f0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

I have the same issue, i also run HASS from a syno DS218+, can’t get it working.

I programmed it like this:

device_tracker:

  • platform: experiaboxv10a
    host: mijnmodem.kpn
    username: admin
    password: mysecret!
    interval_seconds: 10
    consider_home: 180
    new_device_defaults:
    track_new_devices: true