mattlongman / Hassio-Access-Point

Hass.io addon to let you create a WiFi access point, perfect for using WiFi devices on off-grid installations.
MIT License
91 stars 64 forks source link

Feature Request: log DHCP lease assignments, or web ui showing table of assigned IPs #68

Open malkowski opened 6 months ago

malkowski commented 6 months ago

I have a handful of tasmota devices, which pull IP addresses. I'm using this HomeAssistant add-on to create a WAP which these devices can connect to without killing my main AP performance. Problem is, I can't see which IPs the devices are actually assigned.

MVP: log MAC+IP leases in e.g. /hassio/addon/30e576d0_hassio-access-point/logs

Ideal: add a view in the addon which displays a table of current leases, with MAC + IP.

Bonus: ability to assign IPs based on MAC

malkowski commented 6 months ago

if there's a way to do this already that i'm not aware of, please let me know. given that wlan0 doesn't even show as configured within the main HomeAssistant shell, I'm thinking this is probably something that needs to be done within the addon, but I'm still just getting my feet wet with HomeAssistant (finally migrated from homebridge and man, i do not know what took me so long).

ROBOT0-VT commented 6 months ago

Hiya,

AFAIK DNSMASQ can be configured to output leases to a file, I'd just have to figure out how to set that up and have that file be automatically logged. Will put this on the backlog =)

Ideal likely isn't gonna happen, I'm the only active maintainer and I'm really not up to write a UI at this stage :D

As for the bonus, that's already possible (although not intuitive) through the DNSMASQ config override by adding the highlighted line for every host to be bound. I'll look into making this more obvious/accessible in future.

malkowski commented 6 months ago

Thanks for the quick reply! I had been trying to use "dhcp-host:" rather than "dhcp-host=", not sure where that came from. Correct syntax helps things work correctly, go figure. 🤣

I got dnsmasq logs to show up in the addon logs, just needed log-dhcp and more importantly log-facility=- to send logs to stderr rather than syslog or whatever it's default is.

ROBOT0-VT commented 6 months ago

Schweet. I'm in the process of refactoring networking and logging, so thank you for the nice contribution =)

If you have time, an optional code/config sample or a PR would be appreciated (although I'll probably close any PR because the refactor is going to break merges)

Domigome commented 5 months ago

Maybe this feature can help us to link devices not found by the automatic discovery?

I'm really stuck because the only way I have to link devices is manually writing their IPs, but some devices that I do not know the IP all I have is their mac address by the log of Hassio-access-point.

@ROBOT0-VT could this help me? Maybe I can try your last commit if there is something to see IPs.

edit: I wonder if we could trigger the device discovery every time a new device does the handshake with the addon (and the addon detects it is not a registered entity).

ROBOT0-VT commented 5 months ago

Hiya, the fix for this is incoming, it's just in between a bunch of half-refactored code. If you'd like to try this fix yourself, you can add the lines @malkowski listed to the DNS config override

malkowski commented 5 months ago

@Domigome I've attached a screenshot of my DNSMASQ custom configuration if it helps.

Screenshot 2024-04-18 at 10 14 58

Domigome commented 3 months ago

@malkowski @ROBOT0-VT Has arrived the day I needed to add a new device, and even with those settings, device seems connected properly but cannot discover it:

wlan0: STA 28:87:ba:89:93:6a IEEE 802.11: associated wlan0: AP-STA-CONNECTED 28:87:ba:89:93:6a wlan0: STA 28:87:ba:89:93:6a RADIUS: starting accounting session E7D2F61A2FB342CD wlan0: STA 28:87:ba:89:93:6a WPA: pairwise key handshake completed (RSN) wlan0: EAPOL-4WAY-HS-COMPLETED 28:87:ba:89:93:6a

If I could see the IP somehow, that would be enough to discover the device in the discovery, but only seeing the mac address I am not sure how to proceed, any idea what could I try?

edit: A temporal solution though no ideal was to use https://github.com/angryip/ipscan to scan and list all IPs: power off the new device, scan and list all the IPs (screen-shoot the list). Power on the new device and scan again to find the new IP, use that IP on the discovery.