Getting Network MAC addresses

Simple, but frustrating one. I want to capture a list of currently active devices, including their mac addresses. It’s very similar to what the nmap tracker does, unfortunately that either doesn’t make the info i need available, or absolutely spams the entity list with junk entities.

Is there an easy way, from within app daemon, to do the equivalent of a privileged nmap scan? I need a list of active IPs and associated MAC within an IP range.

Nmap will give me the IPs, but not the MAC.

ARP only gives me the IP of the app daemon docker. (I am running the HACS add-on version).

Thanks in advance.

nmap -n -sP 192.168.86.0/24 | awk '/Nmap scan report/{printf $5;printf " ";getline;getline;print $3;}'

This could be put into a command service and called from an automation or from within appdaemon
The assumption with command above is that your gateway is 192.168.86.1

Unfortunately, that command needs to be run at sudo level to get the MAC addresses. appdaemon doesn’t seem to escalate it, and I can seem to make it work with an automation.

If you need to run nmap with elevated privileges, write a separate app and feed the data to an MQTT broker or create a custom service in AD, expose it to the API and make a API call from the app that collects the data from nmap. If you do decide to use the python nmap module and run directly in AD, make sure you use run_in_executor() method so it doesn’t tie up the app’s thread.