scholtzan / homebridge-rusty-spotify

Spotify plugin for Homebridge written in Rust
MIT License
14 stars 5 forks source link

possible to have an accessory per spotify device? #2

Closed pponce closed 3 years ago

pponce commented 4 years ago

Awesome plugin! Wanted to know if i could create an accessory per spotify device. Also noticed that the generate_config file i believe uses the wrong accessory name for the config. I got an error about the there not being a plugin for the accessory when i first ran it. After i changed the accessory value to Spotify in the config things worked fine. edited output "accessory": "Spotify", "name": "SpotifyAccessory", generate_config output "accessory": "SpotifyAccessory", "name": "SpotifyAccessory",

scholtzan commented 4 years ago

Thanks, I fixed the script.

That's definitely an interesting idea! One issue I noticed is that devices go into an inactive state and disconnect from the Spotify API if music is paused on them for a while. So, if it can happen that in order to start playing music on a device, some devices need to be manually activated again (e.g. by opening Spotify on them).

I'll keep the issue open and will pick it up when I have some more time to work on that.

mrkita commented 3 years ago

This would be awesome, I was hoping to just have one accessory per device, and call out which one I want to turn on. Doesn't seem to work as the accessory name is hard coded. How hard would this be?

EDIT:

I started hacking, and was able to create two accessories (just in the index.json)... I kept both accessory descriptions identical, except for the device id. I can see it switch in the backend when toggled: the previously playing device says "Now playing on ... <2nd device>", but no sound plays on the 2nd device, and the play controls are greyed out on the 2nd device, as if it's stuck/bugged (opening a new song then works).

So something is missing... is it not ok to share the same client ids?

scholtzan commented 3 years ago

I just pushed a new version (0.4.0) of the plugin that will automatically discover available Spotify devices and add them as accessories.

The configuration for the plugin has changed slightly.

Now it's:

{
    "platform": "Spotify",   // before this was "accessory": "Spotify"
    "name": "Spotify",
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "refresh_token": "<refresh_token>"
  }
moshed commented 3 years ago

@scholtzan is this still supposed to go under the accessories value in the JSON?

when I put it in there my entire homebridge server hangs when starting

scholtzan commented 3 years ago

It needs to go under platforms now. I'll update the README.