Apple Airport Router integrated into hass

I have an idea I’d love some advice on. As I have about 12 airports in my house serving up audio in each room, I was thinking to try using this as the foundation of a room tracker, so that it would have a device tracker that would say which airport the device was connected to rather than just saying “home”…

Do you think such a thing would be possible? To read the name/mac/IP of the airport which is reporting connection to the tracked device and then put that as the state of the device tracker?

This would be pretty cool, because I could potentially have my music follow me around the house.

I am running home assistant container with docker-compose, how can i add the rsyslog in the container?

I run it on the host itself. It’s much easier that way. You can even run it on a different host.

pls check my GitHub repo. without syslog server, we can use another python script to handle the syslog messages directly. This script is running on the host.
if u want to all-in-one in the docker container, maybe u can modify the docker image manually.

only if u modify the code by yourself. from technical point, it’s possible, and not a difficult issue.

I’ve been working on trying to get this to run with hass.io as a local add-on.
Small steps so far, as I really don’t have much python or docker knowledge, but hey I’m trying. Fixed a few errors here and there, and so far I’ve managed to get the add-on to run using the airconn.py script, and I believe it is receiving the syslogs from the airport router, as I only see logs in the add-on once I connect or disconnect a device from the wi-fi, so it would appear to be triggering the script. The current traceback begins at either line 37 or 42, depending on whether i have connected or disconnected a device to the router.

Traceback (most recent call last):
  File "/airconn.py", line 37, in <module>
    post('http://127.0.0.1:8123/api/services/device_tracker/see',data=postData,headers=headers)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8123): Max retries exceeded with url: /api/services/device_tracker/see (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x764b9dd0>: Failed to establish a new connection: [Errno 111] Connection refused',))

It appears to be an issue connecting to the hass API.
I have tried setting "homeassistant_api": true in the add-on config.
Would anyone on the thread more knowledgable than me have any ideas as to where to begin with with fixing this? I’m not sure whether I need to be looking at the add-on docker environment, or if i need to open up additional ports. I.e. if it is the hass API refusing the connection, or if the add-on container itself isnt letting the request through.
I’d appreciate any pointers or info that might help me figure it out.

1 Like

Thanks a million @XCray for sharing your work. Been stuck with n-map device tracking for so long!

I think I tried everything for days now, still hasn’t got it.

Can somebody explain step by step and share the complete script I would be glad.

Tx in advance!

$ sudo service rsyslog restart
$ sudo systemctl restart rsyslog

Was the secret, now it works, stupid :slight_smile:

Don’t put token as a !secret xxx_xxx will not work, at least not for me.

1 Like

Hey, I am trying to set this up as well. I followed the guide on github as is.
I get this error:
Platform error device_tracker.apple_airport - Integration ‘apple_airport’ not found.

I modified the configuration as suggested by Sevift.
The “netstat -tulpn | grep rsyslog” output is as expected.

Another error when testing from another device:
echo ‘<54> <133>Feb 11 22:32:00 timecapsuleu pppoe: Disconnected.’ >/dev/udp/10.0.1.23/514
outputs:
no such file or directory: /dev/udp/10.0.1.23/514
However, on same device, I don’t get any output.

MY DEVICES DOES SHOW UP on the known_devices.yaml file.
Any recommendations on how to start debugging this issue?

OK, I am not getting anywhere, is there someone who can halp me with a “for retards” how-to? Not getting anywhere here…