Device_tracker is adding the same devices over and over again

device_tracker:
  - platform: nmap_tracker
    hosts: 192.168.0.1-255
    hidden: true
    track_new_devices: yes

I don’t know why, but the code above keeps adding all my already known devices to known_devices.yaml over and over again. Now I have multiple duplicates of all my devices in that file.

Any idea of what might be causing this?

are the names different? If so i’d fill in the MAC address fields if they aren’t already and then the device_tracker will update based on that versus hostname, thats hwat i did to stop it at least.

Do you have multiple trackers? The track_new_devices field only works to suppress things if it’s in the first one (no idea why - but that’s the way it works).

There was a bug several versions that was causing this but as far as I know was fixed. Are you using an older version of Home Assistant? This bug may have resurfaced.

Thanks a lot for all your replies.

I am currently using Home Assistant v 0.55

Yes, the same mac-adresses are found multiple times in known_devices.yaml

I don not fill in the names in known_devices.yaml by myself, the device tracker does it for me. :slight_smile:

Here’s one of the devices in duplicate formats.
I have only changed the name property:

00a0de96027e:
  hide_if_away: false
  icon:
  mac: 00:A0:DE:96:02:7E
  name: Yamaha receiver
  picture:
  track: true
  vendor: YAMAHA CORPORATION

And here’s that same device at least twice again:

00a0de96027e:
  hide_if_away: false
  icon:
  mac: 00:A0:DE:96:02:7E
  name: 00a0de96027e
  picture:
  track: true
  vendor: YAMAHA CORPORATION

00a0de96027e:
  hide_if_away: false
  icon:
  mac: 00:A0:DE:96:02:7E
  name: 00a0de96027e
  picture:
  track: true
  vendor: YAMAHA CORPORATION

There is this issue that may or may not have been fixed. Seems like there was some work but the last entry looks like it was closed without being resolved.

Which device tracker are you using?

https://github.com/home-assistant/home-assistant/issues/1606

1 Like

I had a similar if not the same issue, the known_devices.yaml is tricky, this is what I did to fix it.

  1. Stopped HA (not restart but stop)
  2. Deleted the known_devices.yaml file
  3. Started HA
  4. Checked that a new known_devices.yaml file was created
  5. Stopped HA again
  6. Edited the known_devices.yaml file to show what I want (setting items to hide)
  7. Started HA

The known_devices.yaml file does not seem to work well when edited while HA is running.

1 Like

The solution in my case was to edit the device descriptions in known_devices.yaml .

For instance, In “Apple, inc.” I removed the dots and comas so I instead got the string “Apple inc”.

Problem solved!

Was this ever fixed? I’m running .62 and finding the duplicate issue upon restart.

I’m running 0.62 and it’s also happening to me. Very frustrating. I have two device trackers in my configuration.yaml. I originally watched the youtube video from Ben at https://www.youtube.com/watch?v=EsBtyF5tZQ4 where he showed how to customize the dashboard.

  - platform: netgear
    host: 192.168.1.1
    username: !secret anna_usr
    password: !secret anna_pwd
    new_device_defaults:
      track_new_devices: True
      hide_if_away: False
  - platform: owntracks
    mqtt_topic: "owntracks/#"

I deleted my known_devices.yaml and restarted my home assistant. First scan found all my devices using the netgear (router) platform. The devices for the phones were duplicated as they were also found with owntracks. However, I modified the name: and icon: fields for several devices leaving the found device, and MAC addresses alone. I restarted the home assistant. The devices where I changed only the name: and icon: fields were were duplicated! When I changed the id:, name:, and icon: fields as the video showed, I had tripled the number of devices for the same device. So I went back and deleted the know_devices.yaml file and started over. First restart:

a1b2c3d4e5f6:
  hide_if_away: false
  icon:
  mac: A1:B2:C3:D4:E5:F6 [redacted but identical]
  name: --
  picture:
  track: true
  vendor: SHENZHEN BILIAN ELECTRONIC CO.,LTD

updated the icon: and name: fields to:

a1b2c3d4e5f6:
  hide_if_away: false
  icon: mdi:webcam
  mac: A1:B2:C3:D4:E5:F6 [redacted but identical]
  name: Cam Frontyard
  picture:
  track: true
  vendor: SHENZHEN BILIAN ELECTRONIC CO.,LTD

and after second restart, I had both entries for the same device with the icons not showing up on the dashboard for the device I modified.

I left the the MAC address alone in all cases. I started again only changing the name: and icon: fields. That didn’t work, either. I tried turning off the netgear discovery platform and used nmap platform and tried again from scratch. That didn’t work. I would sure think the find would key on the device MAC address because that will not change (except I changed if for this post). Is this a bug?

in the name: field or the vendor: field?

i found that following the suggestion by @jasondreher earlier, stopping HA before editing the known_devices file seems to stop the duplicates from being created.

was having the same issue on 0.62.0 finally i deleted the known_devices and rebooted the machine let the discovery happen and filled in the MAC address. Whatever I did fixed this.

sudo systemctl stop [email protected]

known_devices.yaml modify

sudo systemctl start [email protected]
your problem will be solved :wink:

2 Likes

It’s the best solutión…