List all HA devices with mac address

Hi!

There is any way to list all the devices or entities with their mac addresses?
I try to identify a device from my network.
If I could know a list similar to this:
Sonoff Device - MAC xx:xx:xx:xx:xx:xx

At least I could know what type of deice is what I search for, then I can search deeper from the specific integration…

Thanks

If someone needs this

{% set devices = states | map(attribute='entity_id') %}
{% for device in devices %}
{% set bun = device_attr(device, 'connections') %}
{% if bun is not none and 'mac' in bun | map(attribute='0') | list %}
{% for connection in bun %}
{% if connection[0] == 'mac' %}
{{ device }} - {{ connection[0] }} - {{ connection[1] }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}

Or, for specific device only

{{ (device_attr(device_id('media_player.computer_tablet'),'connections') | list)[0][1] }}

3 Likes

Thank you for this. Works like a charm

Thanks. That helped me :slight_smile:

Just a small addition, putting a hyphen after each of the {% openings suppresses the new line that would otherwise be output.

{%- set devices = states | map(attribute='entity_id') %}
{%- for device in devices %}
{%- set bun = device_attr(device, 'connections') %}
{%- if bun is not none and 'mac' in bun | map(attribute='0') | list %}
{%- for connection in bun %}
{%- if connection[0] == 'mac' %}
{{ device }}, {{ connection[0] }}, {{ connection[1] }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}

When I first ran the script I thought it had only found 1 device before I realised I needed to scroll past all the blank lines.

Hi, I found that if you use the below URL it will list all the MAC addresses and provide you the ability to sort and and search for specific MAC addresses registered within Home Assistant. Hope this helps.

http://homeassistant.local:8123/config/dhcp?mac_address=

Hmm, that’s kinda cool. But for some reason it only lists 10 devices from my HA instance that talks to well over 100 IP devices.

How should I use it?
not sure I understood how to do it

If you copy the code from Post #4 above into → Developer Tools → Template, it will produce a list of all devices with a mac address.

You can then build templates are probably use it in a card.

Amazing, thank you!

If it’s just for “An Overview” you could use HA’s buildin Discovery

Goto Settings/System/Network … Scroll down Network Discovery / DHCP Browser
Should have every devices it ever “had it’s fingers at” :slight_smile:

wow even better and simplier!

1 Like

Link

Anywhere, you want it(almost) … Im Lazy by Nature :smile: