lukasroegner / homebridge-sonos-multiroom

Plugin for real Sonos multiroom experience in homebridge.
MIT License
35 stars 3 forks source link

Bug: HomeKit sees existing zones as completely new devices if they are re-discovered by multi-room plugin, clearing all automation #16

Closed rfiorentino1 closed 2 years ago

rfiorentino1 commented 2 years ago

Thank you so much for creating this plugin. I actually use this in conjunction with Homebridge ZP to deal with grouping/ungrouping, as I find it easier to set zone priorities with this plugin than using the coordinators within ZP. However, if for some reason a Sonos device goes offline, the multi-room plugin doesn't remember it when it's re-discovered, causing HomeKit to disassociate any previous automations, scenes, etc that were linked to that device. A similar thing happened with ZP a little while ago, and was fixed in This Issue. If you could look into doing something similar, I'd greatly appreciate it. Thanks so much! This plugin has been awesome!

rfiorentino1 commented 2 years ago

Update: This issue now consistently keeps re-discovering a specific zone, my "master bathroom" randomly, causing it to appear as a new device and loose previous automation/scenes associated with it. It's only that zone though, and this has only started happening within the last 2 weeks or so. That zone happens to be a Sonos 1, while everything else is an amp, so not sure if that matters, but still strange. Sometimes it's re-discovered, and sometimes it's not discovered at all, even though the player is completely functional and appears just fine in Sonos and other Homebridge plugins, like ZP. I've also tried deleting that zone, saving config and restarting Homebridge, then re-adding that zone and it's priorities, with the same results. I'd try uninstalling and reinstalling the plugin, but I'm afraid to do that and loose all automations for all of the zones.

lukasroegner commented 2 years ago

Fixed in 0.6.0: If there are any issues during discovery, the accessories will NOT be removed from HomeKit if they have an entry in the configuration.

Moreover, I would suggest that you increase the timeout for discovery (which you can set via the config.json file).

rfiorentino1 commented 2 years ago

Awesome, thank you so much!

rfiorentino1 commented 2 years ago

After updating to 0.6.0, multi-room can't find any Sonos devices at all now. Do I need to change something? Luckily the devices still show up in HomeKit, thankfully because of the change made to restore accessories still in config, so automation etc is not lost. :) but turning them on/off doesn't actually do anything because multi-room hasn't discovered the actual zones. I also set my discovery time out to 10,000. Should that effect this? If anything I'd think it would just give more time to discover the zones. Homebridge also takes much longer to start after this plugin update, just fyi. Here is the relevant log info:

[1/29/2022, 9:43:30 PM] Loaded plugin: homebridge-sonos-multiroom@0.6.0 [1/29/2022, 9:43:30 PM] Registering platform 'homebridge-sonos-multiroom.SonosMultiroomPlatform' [1/29/2022, 9:43:30 PM] [SonosMultiroomPlatform] Initializing SonosMultiroomPlatform platform... [1/29/2022, 9:43:30 PM] [SonosMultiroomPlatform] Homebridge API available. [1/29/2022, 9:43:30 PM] [SonosMultiroomPlatform] Cached accessories loaded. [1/29/2022, 9:44:11 PM] [SonosMultiroomPlatform] Discovery completed, 0 device(s) found.

lukasroegner commented 2 years ago

You don't need to change anything after the update.

Increasing the discovery timeout should increase the probability that the devices are found during the homebridge startup. As the discovery is a blocking process, startup time of homebridge will increase (by the additional time out that you configured).

I would suggest that you try out different time out values and find the value that works best for you. Nevertheless, the default time out of 5 seconds should be more than enough, even on WiFi (I have 9 devices in a wireless network, the discovery of all of them takes around 1-2 seconds).

rfiorentino1 commented 2 years ago

Interesting. Is there a reason why discovery has to be a blocking process, or can that change? Last night, I restarted homebridge and everything was fine. But I had restarted five or six times previously, and no devices were found at all every time. So it seems to be a little inconsistent now. Would it help if I enabled the API, or if you implemented some kind of auto discovery of zones, instead of manually putting in the zone names? I love the ability to set priorities, I'm just kind of thinking out loud of other potential solutions. For now, everything is working great again but I have no idea when the plug-in will stop discovering devices again

lukasroegner commented 2 years ago

The main reason is keeping it simple. Adding accessories dynamically would require a different architecture for the plugin, which would increase the complexity.

rfiorentino1 commented 2 years ago

I completely understand that, just trying to think of ways that would illuminate the issue I was having, where accessories still show up in HomeKit but weren't linked to the actual speakers. Like I said everything has been perfect for a little while now, but not sure what changed to make it work again. Have you looked at the architecture of ZP, and how devices are discovered there? Maybe that would be helpful so you don't have to completely reinvent the wheel?

lukasroegner commented 2 years ago

Have you looked at the architecture of ZP, and how devices are discovered there? Maybe that would be helpful so you don't have to completely reinvent the wheel?

Yes, I've used homebridge-zp in the past. One of the reasons to develop this plugin has actually been to provide a niche functionality, while keeping complexity low. homebridge-zp provides a huge feature set, maintained by one of the most brilliant developers for Homebridge.

As you might have noticed, I haven't really worked on any of my plugins in the last year, due to limited time. That's why I would like to keep all of the plugins as simple as possible (from a technical perspective), which sometimes means that edge cases cannot be covered.

rfiorentino1 commented 2 years ago

And the primary reason I use this plug-in is because ZP does not allow me too set coordinators/priorities for zones the way that I want to, so thank you. This, along with ZP and homebridge pico, allows me to use the pico audio remotes in the way that they were meant to be with Sonos