apwelsh / hubitat

MIT License
26 stars 12 forks source link

Advanced hue bridge integration unlink does not work #19

Closed xxKeoxx closed 2 years ago

xxKeoxx commented 2 years ago

Recently I had to replace my router so my hue bridge IP changed. When I logged into hubitat to update the hue bridge IP the bridge would not unlink. It still showed my bridge name and old IP. The only way I could get the app to work was to remove the app and install it again. I would love to supply you logs from that time, but it was like this app stopped working because nothing was logging in hubitat.

I will also add that all of my IPs changed including the ones in hubitat, but I don’t see how that would have impacted this app.

apwelsh commented 2 years ago

Just to be clear, you tried using the unlink button on the Advance Hue Bridge Integration app, and it did not re-enter into the linking mode?

xxKeoxx commented 2 years ago

Yes that is correct.

apwelsh commented 2 years ago

In the application, if you select the gear icon to go to settings, do you have values for client key, and username under Application State, and selectedDevice under Settings? Also, if the button for the bridge is still on the page, it should not be lit up on the left side (the blue vertical bar). If the bar is not set, the hub is unlinked. Simply select the hub button to re-enter into the linking operation.

Was this done too?

xxKeoxx commented 2 years ago

The bar was still blue and clicking on the button to re-enter linking mode resulted in the screen asking me to push the button on my hue bridge. Clicking on the button on my hue bridge never resulted in a linked bridge. I was also monitoring the hubitat hub and there was nothing being logged at all when I pushed the link button in the Advanced Hue App. It was like the Advanced Hue app just stopped working.

apwelsh commented 2 years ago

Interesting. I think I see the issue there. You have the same bridge ID but it has a different IP. I can play with this. The easy fix on your end is to use dhcp reservations to put the bridge back in the old ip address. It is possible to re-detect the hub, and update the IP address, which I will add code for. Apparently this is a miss in my end. This app used to do that automatically, because you could start the search, and deselect the same hu, so if the SSDP auto discovery was running, it would update the IP. Now that there is a one hub to one app relation, that screen went away so the logic went dormant. So, maybe I will update it so that when you select the hub, it detects if it is offline, and if so, it will send out the SSDP packets to locate it again. Then it would t matter if you unlink it or not, it can still pick up the new IP address.

xxKeoxx commented 2 years ago

I just removed the app and installed it again. Luckily it wasn't too much to fix after.

apwelsh commented 2 years ago

Ok. I am in the middle of the fix. It isn't extensive.

apwelsh commented 2 years ago

I have had a lot of interruptions. I am almost done with the fix, which did involve a bit more revamping than I intended, but as I have been busy with other issues, I will need to refresh myself on the status to finish this up. I will push it out later this week if things settle down. Essentially, I have added some logic and a toggle on the main page to find the hub. Anytime the toggle is turned on, it will immediately start searching for the hub until it find it. Once it is found, the toggle is turned back off automatically. When the hub is found, the hub's new IP address will be updated to the hub details in the application, so everything will point to the new hub. In addition, if you unpair the hub, then the application will resort back to the searching mode, and if found, it will ask you to pair the hub. This last piece is the logic I am working on now.
What broke for you wasn't that it needed to be paired again, but that the application needed to know about the new IP address. The first option I added solves that. The second option I am adding will solve the re-pair issue, even when the IP changes on it.

budjik-tech commented 2 years ago

Just adding a comment. I recently had a similar issue with the IP address of the Hue Hub being re-allocated dynamically on a router restart after a long power failure. Will not go thorough the debug process or frustrations but in the end I could see the original IP address in the logs and was able to use the router to re-assign the IP address permanently by MAC address back to what this application expected.
I chose this path rather than uninstall-reinstall the app and risk having the imported the devices removed and affecting dashboards and automation rules. I thought being able to assign the IP address manually would be helpful, however this solution you are working on should work at a less technical level for users.
Thank you, hope I don't need to use it though :)