nfarina / homebridge-sonos

Sonos plugin for homebridge: https://github.com/nfarina/homebridge
153 stars 52 forks source link

Synchronous Device Discovery and Accessory Registration (promisifying?) required #14

Closed fwboettger closed 8 years ago

fwboettger commented 8 years ago

@nfarina - slightly struggling with my implementation of the enhancements of the 'coordinator device identification'. Due to the current asynchronous device discovery, dependent on the response times for device and their attributes discovery, sometimes not all available devices are identified when an accessory is being registered (need to be able to search all discovered devices irrespective of the current accessory being processed, such as to identify coordinator devices in paired and/or grouped scenarios).

Something like "discover all devices first and push them to a list/map, only then (after completion of the complete discovery) get into "this.search" for the accessory and search through that list/map to register the appropriate coordinator device with the respective discovery.

I'm new to node.js, hence need some advice here please. have been reading a bit about promises and available libraries such as Q or Bluebird, but i'm not really sure how to best approach this...

Thanks much for any advice/guidance you might be able to provide!

fwboettger commented 8 years ago

Found a less complicated solution, no promisification needed, thus closing the issue.