Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use IP address to identify devices (prefer MAC as identity) #89

Open
troy216 opened this issue Apr 5, 2023 · 5 comments
Open

Comments

@troy216
Copy link

troy216 commented Apr 5, 2023

I use DHCP with my Tasmota devices, so their IP addresses will change over time. It looks like TasmotaBackup uses the IP address to identify devices. This results in two issues:

  1. After re-discovering devices, I will get duplicate records where the Name and MAC address are the same but IP address is different.
  2. When Iisting the backup files, often multiple device names will appear in the list.

I suggest that only the MAC address be used to identify devices so that there is never any confusion. Alternatively, either the device name or the MQTT topic could be used. The IP address should NEVER be used to determine identity.

@patrickdk77
Copy link
Collaborator

Nice thoughts on how tasmobackup works.

It doesn't use IP address to identify devices, and if your dhcp server is changing the ip address of your devices, you should fix your dhcp server, as this should only happen if you dont have enough ip addresses for all your devices, and that is a different problem.

We cannot use mqtt to identify devices, as that is not any more stable than ip address, and you might not even be using mqtt.

I will need more details about how it is messing up for you, to be able to fix it, cause I am not sure based on this limited description I will be able to reproduce the problem.

But again, if your DHCP changes your devices ip addresses over time, that is broken.

@troy216
Copy link
Author

troy216 commented Apr 5, 2023

Sorry if I came across blunt. I'm sure there are many design considerations I am not aware of. Also, I am generally very pleased with this addon and appreciate your contribution.

In the readme, it says, "No duplicates (based on IP, and MAC)". I'm not sure exactly what that means, but because I ended up with duplicates where only the IP was different (MAC and Name were the same), I assumed it was using the IP, in some way, to identify devices.

In my case, I replaced my wifi router, so that is why all my devices received different IP addresses. While many devices were correctly identified, a handful of duplicates were created.

If only the MAC were used to identify devices, then duplicates should never occur, and backup files should be correctly associated with the device. The only scenario where this would not work ideally is when replacing a device with an alternate device, say because it failed. That is why the device Name (I am using MQTT topic to populate name) might be a preferred identifier. However, I would vote to use the MAC address alone. I can always manually apply the backup to the new hardware if replacing a failed device.

@patrickdk77
Copy link
Collaborator

Yes, it attempts to do it by mac if it can figure out the mac address, then it should go by ip.
It might not have the mac address for many reasons, tasmoto version did not support fetching that information, the device is on a different network than tasmobackup. It attempts to fill in mac when it does find it. It is a best effort though.

I'll have to review the code and see if there are cases it should work, but isn't.

@heffneil
Copy link

heffneil commented Oct 23, 2024

I have this complaint as well. I repurposed some previously installed switches. When I went to re-add them they got an old IP for a device that also went away. When I went to back it up it said it existed. When I removed the device with the IP - it then let me add it so it wasn't hung up on mac address but IP. Ip isn't a reliable form of identifying devices.

@patrickdk77
Copy link
Collaborator

I just redid my network, and my iot network has whole new ip subnet, I had no issues, everything was mapped by mac correctly, as IP is only used if there is no mac address recorded in the database for the device.

I am not sure what else I can do to attempt to replicate this, but will see.
The mac address code has been in here awhile and maybe the ip code should be removed (except it will cause issues with older tasmota versions then), but if your having issues now from IP, if I removed IP nothing will work, since IP is only used if MAC does not exists.

If I go into my tasmobackup database (tasmobackupdb.sqlite3) it shows every single one of my devices has a mac address saved.
Since I have my HA install back up and running again and my iot network setup, I'll see if I can figure out what is going on, but I have been unable to replicate the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants