Skip to main content

wifi-ap-associations

Ask a Wi-Fi access point which clients are associated to it right now: their MAC, signal, band, SSID and how long they have been connected, plus what the access point reports about itself (model, firmware, uptime, CPU and memory).

An associated client is one that has joined the access point's wireless network, as the access point lists it. That is a better sign of a device being there than an ARP or switch table entry: a phone stays associated while it sleeps and sends nothing for minutes.

This is the library behind the Home Assistant integration Wi-Fi Association Presence, but it has no Home Assistant imports and works in any asyncio program: a network inventory, an exporter for Prometheus, your own scripts.

Supported access points

TYPE Access point How it reads Signal
dlink_dap_ssh D-Link DAP (e.g. DAP-2610) SSH console %
openwrt_ssh OpenWrt 22.03 and newer SSH, ubus (hostapd) dBm
unifi_network UniFi through a UniFi Network controller connection you pass in (see below) dBm

More can be added as drivers; see Help add your access point.

Install

pip install wifi-ap-associations

Python 3.12 or newer. The SSH drivers use asyncssh.

Use

import asyncio

from wifi_ap_associations import DRIVERS, AccessPointAuthError, AccessPointError


async def main() -> None:
    driver = DRIVERS["openwrt_ssh"](
        {"host": "192.168.1.2", "port": 22, "username": "root", "password": "secret"}
    )
    try:
        result = await driver.async_poll()
    except AccessPointAuthError:
        print("wrong username or password")
        return
    except AccessPointError as err:
        print(f"could not read the access point: {err}")
        return

    for client in result.clients:
        print(client.mac, client.band, client.ssid, client.signal, driver.SIGNAL_UNIT)
    if result.info:
        print(result.info.model, result.info.firmware, result.info.uptime_seconds)


asyncio.run(main())
  • async_poll() returns a PollResult: clients (a list of AssociatedClient) and info (an AccessPointInfo, or None). async_get_associated_clients() returns the clients only.
  • Every driver lists its settings in FIELDS (key, whether it is secret, default), its display name in NAME, and the scale of signal in SIGNAL_UNIT ("%" or "dBm").
  • MAC addresses are upper case with colons; normalize_mac() converts other spellings.
  • Errors: AccessPointAuthError for rejected credentials, AccessPointError for everything else (unreachable, timeout, unexpected output).

UniFi

The UniFi driver does not log in by itself. It reads from an object you pass as the second argument, which implements UnifiSource (async_get_device(mac) and async_get_clients(mac), returning the controller's device and client records). In Home Assistant that is the UniFi Network integration's connection; elsewhere, wrap your own controller client.

Security

The SSH drivers log in with a password and do not verify the access point's host key (it changes when the access point is reset or reinstalled). Use them on a trusted network and keep the access points' management access limited to the host that polls them. Each poll is a new login, which the access point may log.

Development

pip install -e . pytest ruff
ruff check --select E9,F src tests
python -m pytest

Releases: set __version__ in src/wifi_ap_associations/__init__.py, add a section to CHANGELOG.md, run the publish workflow by hand to upload to TestPyPI and check it, then push a tag v<version> to upload to PyPI and create the GitHub release.

License

GPL-3.0, like the integration.

Metadata

Release files for wifi-ap-associations 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wifi-ap-associations 0.1.0
File Size Uploaded
wifi_ap_associations-0.1.0.tar.gz 33.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wifi-ap-associations 0.1.0
File Interpreter ABI Platform
wifi_ap_associations-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.9 kB

Release files / wifi_ap_associations-0.1.0.tar.gz

Download URL wifi_ap_associations-0.1.0.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
52e6d791f980c18cfcd7a013c5b44af9762d8b719018157dd57ec09c0c7451d1
BLAKE2b-256 checksum
How to use checksums
4f85ccfad01ec81f895b8918793f76d4c96df0d160c68eb1779dbca6f7df80bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / wifi_ap_associations-0.1.0-py3-none-any.whl

Download URL wifi_ap_associations-0.1.0-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d87c110b57b56118d4fc48caf45888e3079fc58c838ae6d4b899b94b3c68e27
BLAKE2b-256 checksum
How to use checksums
3e12de8b431ef3eea4e1590b343f874f786ee7d0775c0c5e4bb423e3de4cf420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page