Closed 8none1 closed 6 months ago
Meh, it was a 3 minute job, so I did it :) I should have just made a branch to start with.
Thanks again for this, feel free to bump the version on the manifest.json and merge!
Oh! I forgot the manifest last time, thanks for the pointer :+1:
New release published.
Background
I got a bug report from a user of the BJ_LED integration that I've seen with this one too so I spent some time investigating. The bad news is that the same bug is present here. The good news is that I know how to fix it (I think).
The bug happens when you try to add a device that you might have already added and then removed:
When you click this button:
and choose the device:
You get this error:
The error in the logs is:
Why
This happens because the device name is not being set correctly. If you add the device from the main integration screen some additional information about the device is passed in to
config_flow.py
which includes the device name. When you add the device as above the only information that is passed in is the MAC address and a list of discovered devices.I don't know if this is because we are supposed to pass in more information somehow, or if that's just how it is.
How to fix
I fixed this in another integration like this:
So it itterates the list of devices looking for a MAC address match. Then uses that match to pull out the name and set it.
This seems to work, and probably fixes other latent bugs which would have cropped up when people have multiple devices.
This should more or less copy & paste over.
Creating this bug to remind me to do something about it some time, unless anyone else picks it up first. ;)