Device tracking across an Asus AiMesh with asuswrt and Lyra mesh

I recently purchased an Asus Lyra mesh node to work with my existing Asus router running asuswrt. They connect to each other using the AiMesh feature of the Asus router. This has helped me provide much better WiFi coverage upstairs in the house.

Unfortunately it appears to break device tracking. The primary router running asuswrt does not provide DHCP lease information for devices connected upstairs to the mesh node.

I am trying to find a path forward that will ensure device tracking continues to work, some things I have looked at:

  • Stopping the phones from connecting to the mesh node. It looks like I am unable to control this from either the node or the phones. The block WiFi option in the Lyra app didn’t seem to do anything either.

  • I ssh’d into the mesh node to see if it was storing logs in the same place as the primary router, unfortunately it is not so the asuswrt component is most likely not compatible. The Lyra app does show a list of all devices across the network though so the data is in there… somewhere

Any tips or suggestions on how I could fix this would be hugely appreciated.

2 Likes

I have the same issue, anyone got a fix?

Exactly the same issue, I am interested to solve, I continue look for a method.

Same here. I think the issue is the dns file that device tracking relies on only list devices connected to that node. I was able to get it to pick up other devices by pointing to that mesh node. That doesn’t work because the Asus plugin in ha only supports 1 access point. I might try and write a shell script that collects the files and puts them on the master router. I will share if I end up getting that to work.

I have created a Flask Python app to do the tracking of devices per floor:

from flask import Flask
import json
app = Flask(__name__)
import os

routers = {'24:XX:XX:XX:XX': 'Bedroom', '24:XX:XX:XX:XX': 'Main', '24:XX:XX:XX:XX': 'Study', '24:XX:XX:XX:XX': 'Livingroom'}
map_to_floor = {'Bedroom': 'Second Floor', 'Study': 'First Floor', 'Main': 'Downstairs', 'Livingroom': 'Downstairs'}

types = ['2G', '5G']

def clients_by_identifier(identifier_fnc):
    with open(os.environ.get('CLIENTFILE')) as file:
        clients_by_id = {}
        data = json.load(file)
        for mac, location in routers.items():
            for t in types:
                if t in data[mac]:
                    if location in clients_by_id:
                        clients_by_id[location].extend(identifier_fnc(data[mac][t]))
                    else:
                        clients_by_id[location] = identifier_fnc(data[mac][t])
        return clients_by_id

def find_location_of_client(identifier_fnc, client):
    response = clients_by_identifier(identifier_fnc)
    for router in response:
        if client in response[router]:
            return map_to_floor[router]
    return 'Away'

@app.route('/')
def fetch_all():
    return clients_by_identifier(lambda dict: [v['ip'] for _,v in dict.items()])

@app.route('/<mac>')
def fetch_by_mac(mac):
    return find_location_of_client(lambda dict: list(dict.keys()), mac.replace('-', ':'))

@app.route('/ip/<ip>')
def fetch_by_ip(ip):
    return find_location_of_client(lambda dict: [v['ip'] for _,v in dict.items()], ip)

Im running it on the server through the services-start file in /jfss/scripts:

#!/bin/sh
CLIENTFILE=/tmp/clientlist.json FLASK_APP=/tmp/mnt/usbdrive/client-exporter/app.py nohup flask run --host=0.0.0.0 &

This gives me the option to create a restful sensor in HA:

sensor:
- platform: rest
    resource: http://192.168.2.1:5000/ip/192.168.2.69
    name: "GJ Location Wifi"

So I can track exactly where a certain device is in my house, on which floor. This is not your exact use case, but with some modifications you can create a device tracker as well I guess.

I’m using the AsusRouter integration and it is possible to track between AiMesh nodes, if I correctly understood what you are trying to achieve.