Apple Airport Router integrated into hass

Do you have an apple airport wireless router? Do you want to integrate it into your hass?
Here is my effort on this. It’s just fine for me:

  • An binary sensor for the state of internet connection
  • Device tracker, tracking my wireless devices such as iphone and android
    It’s totally event-driven, btw.
5 Likes

You should make an official component for this!

1 Like

thanks for your comment.
to be honest, I just don’t know how to make contribution onto the official code-tree or document-tree.

1 Like

Al or most information is available on the developer portal.

And/or you could ask in the Discord dev channel.

@metbril Thanks to your advice, I had make a pull request on home-assistant.github.io, would you please help to review my request?
This is the 1st time for me to participate such a big open source project, please let me know if there’re something more I need to improve.

Sorry, I am no developer so no reviewer too. But I would be willing to test your component if needed.

Hi,

i would like to know how i can integrate it into my hassio ?
i have a airport extreme, and would like to use it for tracking when i’m connected in my wifi

Hey Vincent, did you figure out how to integrate it easily?

Hello,

No didn’t try it because this router will not be renewed by Apple so one day or an other i will need to buy an other router from an other brand.

I’ve made something different but for me do the same thing,
in place of using wifi tracking, i’ve made tracking based on enter/exit home zone with a radius 20m, so basically when i enter/exit my home.

Is it possible to use this with hass.io?
don’t seem to have access to rsyslog…

Great work, after some editing I have it running, HA in Docker container had to make some editing but finally :slight_smile:

Hi @XCray It seems like no matter what I do, I cannot seem to get the apple_airport process to show up when I send messages to the network syslog… I’m pretty sure I configured everything correctly. For some time in my /var/log/syslog, it was showing me a permission denied error for the script that was in my homeassistant config directory, but I changed the group and owner to syslog and now I get no feedback whatsoever about the script in the log… All I have in the log is the following:

Mar 31 20:37:29 myhost systemd[1]: Started System Logging Service.
Mar 31 20:37:29 myhost rsyslogd: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd. [v8.32.0]
Mar 31 20:37:29 myhost rsyslogd: rsyslogd's groupid changed to 106
Mar 31 20:37:29 myhost rsyslogd: rsyslogd's userid changed to 102
Mar 31 20:37:29 myhost rsyslogd: [origin software="rsyslogd" swVersion="8.32.0" x-pid="30962" x-info="http://www.rsyslog.com"] start
Mar 31 20:38:51 myhost systemd-resolved[870]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Mar 31 20:38:58 myhost rsyslogd: Child 31443 has terminated, reaped by main-loop. [v8.32.0 try http://www.rsyslog.com/e/0 ]
Mar 31 20:53:25 myhost hassio-supervisor[2460]: #033[32m19-03-31 20:53:24 INFO (MainThread) [hassio.homeassistant] Updated Home Assistant API token#033[0m

Is there any way to get some more debug information about what’s going on with the script or even getting executed?

I had to open up internal firewall to make it work, with command:

$ sudo ufw allow 514/udp

Read more about UFW

And also deleted ‘http_password’ in script and added (in HA config):
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1

1 Like

Is this the firewall locally on the server where you are running rsyslogd? If so, what OS are you on? I’m quite sure nothing could be blocking ports internally on my network, unless this service is blocked by default on Ubuntu itself.

Yes, it’s a built in Ubuntu firewall function. I found the information here: https://computingforgeeks.com/how-to-configure-rsyslog-centralized-log-server-on-ubuntu-18-04-lts/

1 Like

Ah, that would explain a lot. I’ll give it a go, thanks for the tip!

So, tried that… Rule seemed to take, it gave me

Rules updated
Rules updated (v6)

So I tried sending another

echo '<54> <133>Feb 11 22:32:00 timecapsuleu pppoe: Disconnected.' >/dev/udp/myhost/514

and what I got in the syslog was:

Apr  2 20:45:31 myhost kernel: [762417.081926] ip6_tables: (C) 2000-2006 Netfilter Core Team
Apr  2 20:45:56 myhost systemd-resolved[870]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr  2 20:45:58 myhost rsyslogd:  [origin software="rsyslogd" swVersion="8.32.0" x-pid="6180" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Apr  2 20:45:58 myhost rsyslogd: Child 30037 has terminated, reaped by main-loop. [v8.32.0 try http://www.rsyslog.com/e/0 ]

Restarted syslogd, but future messages sent didn’t produce new log output other than

Apr  2 20:55:36 myhost rsyslogd: Child 31539 has terminated, reaped by main-loop. [v8.32.0 try http://www.rsyslog.com/e/0 ]

The script is never showing up in ps.

It must be auth problems, I struggled with this from beginning but after added this in my HA conf it works perfekt, no need for http_password in py file just leave as it is

homeassistant:
auth_providers:
- type: trusted_networks
trusted_networks:
- 192.168.0.0/24

My config on github:
https://github.com/Banditen01/Home-AssistantConfig?files=1

1 Like

Okay, so it turns out to be SSL that’s messing everything up… I turned off SSL and authentication on local subnet and everything and I could get it going. But I’m not willing to run without SSL. With everything exactly the same and SSL on, it doesn’t work. The following command works to access the API:

curl -X GET -H "Content-Type: application/json"  https://MYHOST:8123/api/config?api_password=MYPASS --insecure

the --insecure option seems to be the key but I can’t figure out how to do something similar in the script. I have the URLs defined as https:// but the script doesn’t work with https turned on.

Does anyone know how to do something like the --insecure option in CURL with python’s POST() method?

In new versions of HA, you need to create a long-term access token for the script. And fix the script.

headers = {
    'Authorization': 'Bearer your_token',
    'content-type': 'application/json',
}

postData = '{"mac":"'+mac+'","dev_id":"router","location_name":"not_home"}'

postData = '{"mac":"'+mac+'","dev_id":"router","location_name":"home"}'

3 Likes