parvez/network_scanner
Sobre
This Home Assistant integration provides a network scanner that identifies all devices on your local network. Utilizing the provided IP range and MAC address mappings, it gives each identified device a user-friendly name and manufacturer information.
Sistemas e infraestruturaO que você pode fazer
- Scans one or more IPv4 ranges, in the background, as soon as Home Assistant starts, then on a schedule (every 15 minutes by default).
- A Scan now button for an immediate scan.
- A device list that names devices by MAC address.
- Everything is set up and changed in the UI, with no restarts.
Crescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- 0
- em 15 dias
- 0
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalHome Assistant Network Scanner Integration
Network Scanner finds the devices on your local network with an nmap ping scan. It counts them, lists each one with its IP address, MAC address, vendor and hostname, and gives the devices you know a friendly name.
Upgrading from 1.x? Version 2.0 is configured entirely in the Home Assistant UI;
configuration.yamlis no longer read. Your existing IP range and MAC mappings are moved over automatically, andsensor.network_scannerkeeps its entity ID. Don't add the integration again: just delete thenetwork_scanner:block fromconfiguration.yamland restart. See Upgrading to 2.0.
Features
- Scans one or more IPv4 ranges, in the background, as soon as Home Assistant starts, then on a schedule (every 15 minutes by default).
- A Scan now button for an immediate scan.
- A device list that names devices by MAC address.
- Everything is set up and changed in the UI, with no restarts.
- A repair notice when nmap can't see MAC addresses, instead of silently showing 0 devices.
- Diagnostics download for bug reports, with names and MAC addresses removed.
Requirements
- Home Assistant 2025.10 or later.
- The
nmapprogram. Home Assistant OS and the official container image include it. nmap only reports MAC addresses when it runs as root on the same local network as the devices, which is the case on Home Assistant OS.
Installation
HACS
- In Home Assistant, open HACS, search for Network Scanner and download it.
- Restart Home Assistant.
- Go to Settings > Devices & services > Add integration and choose Network Scanner.
Manual
- Copy
custom_components/network_scannerinto thecustom_componentsfolder of your Home Assistant configuration. - Restart Home Assistant.
- Go to Settings > Devices & services > Add integration and choose Network Scanner.
Configuration
Adding a network
When you add the integration, enter:
- IP range: one or more IPv4 ranges separated by spaces, up to 65,536 addresses in total. For example
192.168.1.0/24,192.168.1.1-254, or10.100.1.0/24 10.1.1.0/24. Your Home Assistant's own subnet is suggested. - Known devices (optional): see below.
Add the integration again to scan another range separately. If the new range includes addresses another entry already scans, you're asked to confirm first, since those devices would be scanned twice and counted by both entries.
Known devices
One device per line, as MAC;name;type. The type is optional, and lines starting with # are ignored. MAC addresses can be written with colons, dashes or no separators, in any case.
# Printers
bc:14:14:f1:81:1b;Brother Printer;Printer
B1-81-11-31-A1-B1;My iPhone;Phone
Devices that aren't in the list show as Unknown Device.
Changing settings
On the integration's entry under Settings > Devices & services > Network Scanner:
- Configure changes the known devices, the scan interval (60 seconds to 1 day) and extra nmap arguments. Saving applies the change and starts a new scan.
- Reconfigure (in the ⋮ menu) changes the IP range.
Extra nmap arguments are added after -sn (ping scan), for example -T4 --host-timeout 5s to speed up scans of large ranges. Options that read or write files or run scripts aren't allowed.
Entities
| Entity | Description |
|---|---|
sensor.network_scanner_devices |
Number of devices found in the last scan. The devices attribute lists each device's ip, mac, name, type, vendor and hostname. |
sensor.network_scanner_last_scan |
When the last successful scan finished (diagnostic). |
button.network_scanner_scan_now |
Starts a scan immediately. Use the button.press action to scan from an automation. |
Only devices whose MAC address nmap can see are counted; that usually excludes the machine Home Assistant runs on.
The devices attribute isn't saved to the history database, because on larger networks it exceeds the 16 KB Home Assistant stores per state. Dashboards and templates still see it.
Displaying devices
Entity IDs below are for a new install. If you upgraded from 1.x, your sensor is still sensor.network_scanner.
Markdown card
type: markdown
content: >
## Devices
| IP Address | MAC Address | Name | Type | Hostname | Vendor |
|------------|-------------|------|------|----------|--------|
{% for device in state_attr('sensor.network_scanner_devices', 'devices') %}
| {{ device.ip }} | {{ device.mac }} | {{ device.name }} | {{ device.type }} | {{ device.hostname }} | {{ device.vendor }} |
{% endfor %}
Flex Table card
Thanks to @gridlockjoe, you can also use the Flex Table card:
type: custom:flex-table-card
title: Devices
entities:
include: sensor.network_scanner_devices
sort_by: x.ip+
columns:
- name: IP Address
data: devices
modify: x.ip
- name: MAC Address
data: devices
modify: x.mac
- name: Name
data: devices
modify: x.name
- name: Type
data: devices
modify: x.type
- name: Hostname
data: devices
modify: x.hostname
- name: Vendor
data: devices
modify: x.vendor
Upgrading to 2.0
- Take a backup (Settings → System → Backups) before updating. 2.0 converts the integration's saved settings on first start, so going back to 1.x means restoring that backup.
- Update through HACS.
- Delete the whole
network_scanner:block (includingip_range:and anymac_mapping_N:lines under it) fromconfiguration.yaml, then restart Home Assistant. configuration.yaml is no longer read, and your settings were already stored by the integration, so nothing is lost.
Until you remove the block, Home Assistant shows a notice titled "The network_scanner integration does not support YAML". Its first step says to set up the integration "if you've not already done so". Skip that step: your setup was upgraded in place. It's the existing entry named Network Scanner under Settings → Devices & services. Setting it up again creates a second entry that scans the same network twice.
What carries over:
- Your settings move over automatically: the IP range, and every
mac_mapping_Nvalue combined into the new device list, including mappings after a gap in the numbering, which 1.x ignored. sensor.network_scannerkeeps its entity ID and history. Its display name becomes "Network Scanner Devices".- The first scan no longer delays startup. It runs in the background, so the sensor is
unknownfor a few seconds after a restart. - If a scan fails, the device count is
unavailableuntil the next successful scan (1.x kept the old count).
Troubleshooting
- Two Network Scanner entries after upgrading: one was added again by following the YAML notice. Keep the entry named Network Scanner (it has your device names and the original
sensor.network_scanner) and delete the one named after an IP range, from its ⋮ menu. - 0 devices and a "can't see MAC addresses" repair: nmap isn't running as root, or the range isn't on Home Assistant's local network. See Requirements.
- The integration fails to set up with "nmap isn't installed": install nmap on the Home Assistant host.
- Scans take a long time: scan a smaller range, or add
-T4 --host-timeout 5sunder Configure > Extra nmap arguments. - For anything else, download diagnostics from the integration's entry and attach them to an issue.
Development
python -m venv .venv && . .venv/bin/activate
pip install -r requirements_test.txt
pytest
Contributing
Contributions are welcome. Please open an issue or pull request on GitHub.
Explore projetos relacionados
Carregando…