[APP][Pro] Spotify Connect (beta - ready for testers)

Note: for using this app you need a Spotify premium account and create your own Spotify app via their developer platform. Setting up the Spotify app is easy and eliminates any possible issues with the Spotify API rate limit.

Install the app (testversion)

What does this app get you?

This app adds the driver and device for Spotify Connect speakers. While it looks the same as the official Spotify app there’s a few benefits to using this one: it supports speaker capabilities. This means you can fully control the speaker from your devices tab or from a dashboard speaker widget :partying_face:


Features

  • Setup access to your Spotify account using OAuth2
  • Connect your Spotify Connect devices (they need to be online and connected to your account)
  • Sync player state (track info & art, volume, repeat, shuffle and playing) every second
  • Skip tracks (previous & next)
  • Control volume (increase, decrease, slide and mute)
  • Cycle repeat modes (off, track, placklist)
  • Set shuffle mode (on or off)

Installation instructions

As mentioned earlier, this app requires you to create a Spotify app to isolate the usage to just your account. This prevents hitting rate limits in the Spotify API. After you’ve created the Spotify app following the instructions below you can proceed by adding the app to your Homey.

Create a Spotify app

  1. Go to the Spotify developer dashboard and login if needed
  2. Click the create app button
  3. Name your app, for example Spotify Connect
  4. Enter a description, for example Spotify Connect driver for Homey
  5. As redirect URI add at least https://callback.athom.com/oauth2/callback
  6. For used APIs select Web API
  7. You can leave all other fields blank
  8. Save the app and on the following page you can view your Client ID and Client Secret. You can copy these now or go back here later
  9. Go to the User Management tab and add your own Spotify e-mailaddress as user that is allowed to access this app

Your app will be in “Development mode” which is fine as the rate limit in this mode provides enough flexibility for the usage of a single (active) speaker.

Install Spotify Connect app

  1. Go to the Spotify Connect app store page and install the app
  2. Use the Homey app or web interface to managed the installed apps, find Spotify Connect, go to settings and edit the app settings. You need to add the Client ID and secret codes here.
  3. Go back to your Homey devices and click the add button, use the Spotify Connect driver and follow the steps of accepting the OAuth request and allowing the app to access your Spotify data. As soon as the OAuth has succeeded, the driver will show the available devices to you.

After setting up your device the device card allows access to basic speaker capabilities and the media widgets of Homey dashboard (note: dashboard is currently a beta feature for Homey) allow you to control the speaker and see it’s active state!


Known limitations

  • You are only able to connect a Spotify Connect device as long as it’s actively connected to the Spotify account used to setup the app with on your Homey. If a speaker is shared by 2 different accounts (f.e. using the Spotify iOS app), it will be actively connected to the user that last used the device (see this post)
  • Sonos devices are not supported as these speakers can only be controlled using Sonos’ platform / api and this app is limited to the capabilities of the Spotify API
  • Google devices have the same limitation and are therefor not supported!

Source code

I’ve open-source the source code of this app. It can be found in the Github repository below. Feel free to contribute.

5 Likes

Known issues

  • The album art does not always show instantly, I’ve debugged this all the way back to the Image object which does update within the Developer Image portal. But for some reason it won’t always show in the widget. Might be a local testing thing for me… but please report if this happens when using the test version.

Roadmap

Feel free to request features, things I’m planning on doing will end up in the roadmap. A feature can have status not started or in progress. As soon as a feature is released it will be added to the feature list in the first post.

  • not started: Flow action to search and start various context (artist, song, album, playlist)
  • not started: Widget to search and start playback of various context (artist, song, album, playlist)
  • not started: Flow actions based on player state (song info & song progress)
  • in progress: Rename the device type to Spotify Connect to differentiate it from the official Spotify app
  • in progress: Change the device icon to differentiate it from the official Spotify app
  • in progress: Add info about Sonos and Google devices that are not supported

Changelog

  • v1.0.0 - 2024/10/22
    First release of Spotify Connect - it’s main focus has been including all speaker capabilities into a Spotify driver allowing more controls from within all tools that Homey provides for such devices. Meaning things like volume, playback state, skipping, shuffling and repeating should work.

For those wondering what’s keeping me busy: I noticed that I’m not always able to connect to the speakers. I get that for my laptop, but the soundbar speaker seems to go offline after a period of inactivity. My spotify app does have the ability to turn it on but I believe that is due to it’s ability to see the speaker within my home network.

So… I’m trying to figure out when the device goes offline and whether or not I’m still able to see the device via the users available devices (Web API Reference | Spotify for Developers) or if I can force turning it on by transfering the playback to that device (Web API Reference | Spotify for Developers).

I’m having mixed feelings about if this will work or not. Last tuesday I’ve been playing around with the official app and had set up a few flows to start playlists on my soundbar. This worked all day, even hours after my initial test when I showed some friends that came over. However,… that wasn’t working anymore when I tried to do the same yesterday.

If anyone has any idea’s on how to tackle this, feel free to speak :wink: Besides looking into the API options I’m also going to check out the speakers settings. Maybe there are options to prevent it from turning of the wi-fi connection.

// edit [a few hours later]

Test results

  • Device, if used by another Spotify account, is not available in the users available devices (Web API Reference | Spotify for Developers)
  • If device is absent in the users available devices it’s not possible to play on that device nor is it possible to transfer anything to it
  • After claiming back the device (using my iphone) it appears in my active device list and is controlable
  • After turning off the device using the power button, the device stays available in my current devices and I am able to resume playing or to start a song / playlist.

Ladies and gentleman, let me introduce the issue: speaker takeover
I believe to have found what causes the issues on my end. Whenever somebody else at home uses Spotify and activates the speaker using the Spotify app, the speaker gets connected to their account and disappears from my list of active devices. Unless I use the app on either my phone, tablet or computer I cannot force Spotify to connect the speaker back to my account.

Is this a problem?
Well… yes. At least in my situation where multiple Spotify users connect to the device. If that’s the case in your home… expect this to be a problem from time to time.

Solution (now)
Use the app (phone, tablet, computer) to start playing via the same account that is connected to the Homey app. The devices gets active again and we’re back in business.

The native Spotify app on my iphone/macbook supports a “party” mode (jam or listening party I blieve) in which multiple accounts can control the player. This perhaps might be something that can be used to workaround this issue in the future. But that would still involve all people in your home, that can use the speaker, to select joining a party instead of taking over.

2 Likes

I’ll try to test it this weekend. Thanks for the updates

1 Like

@Harwin: I’ve named the driver “Spotify”, will this operate side-by-side with the official driver or should I renamed it?

I just spotted the app-to-app communication where f.e. the driver id is used as parameter in getting data from another app/driver. For now my idea is to build this one as an addition to the official opposed to it being an alternative. (But I wouldn’t mind adding the flow actions from the official one as well).

Thanks.

@pendojoshua I would just try it. The team which manage the apps will guide you in the process. Just make sure you describe why this app is different then the ‘official’ Spotify app.

1 Like

I’ve updated the source code at Github to include the client_id and client_secret app settings. This eliminates the need to use homey cli to get this up and running yourself by simply entering the details under the application settings tab. You still do need to create a Spotify app yourself in order to stay within safe limits of Spotify’s API rate limiting!

Only thing that’s left before I can release the beta to the app store is to check if I meet all requirements (https://apps.developer.homey.app/app-store/publishing). I hope to find the time to do so tonight or later this week.

As soon as I checked the requirement I’ll apply the app to the store and complete the first post with installation instructions!

I’ve checked the requirements and added the needed info and images to the source. Also went ahead and published the app to Homey. Are there any users that are willing to test the application (about 3-5 people would be sufficient for now).

There’s just this brick wall I’m running into. The documentation says the following about a test version. I might however be blind to this particular link. Did I miss it (or anything)?

You can then choose to release a Test version of the app, only available for users who visit your app via the Test link (available in your dashboard)

Do you mean the test link in de Homey app store? If yes, than it is the url of the Homey app extended with /test

1 Like

I would be happy to test it but unfortunately not before Friday. I could not test your previous version with CLI because of being away from home in the last couple of days.

As far as i know this is only valid once the App has already been published at least once and then further test version can be accessed that way.

In this case it has never been published so I think @pendojoshua you are the only one who will receive this link and then you can share it with us to test. Maybe @1400 can help as he recently went through that same process for his great Dyson fans app

1 Like

Hi,

The first time the order is reversed and you first have to submit your app for review. After its accepted you’ll be able to publish a test version and then publish it.

After that first time you’ll be able to release test versions before Athom reviews.

Hope that helps.

Cheers, Mark

2 Likes

Thanks for all replies! I’ve submitted the app for review, so now the waiting game begins! In case the review takes longer, you can still build from the Github source @Amersfoort. I’ll be here in case you need any help.

Meanwhile I’ll be looking into what flow actions I can add and perhaps give a go at a basic “control center” widget for Spotify that allows to search songs and playlists without leaving the dashboard. I’m curious to see how widgets work with variable widget heights and scrollable divs in particular, as those are things I have in mind to get a useful UI.

// Edit:

Already got a reply - the app has been submitted for review (without publishing it after review). As soon as it’s approved I will be able to share the test installation link here!

2 Likes

They’ve approved the test version, would be cool to see a few people set this up and share their experiences. I’ve create a known issues list next to the roadmap and changelog.

2 Likes

After adding and allowing connection from homey to my spotify app it says no devices found? I have 3 sonos speakers in my network. Do i need to do anything else?

Sonos is not supported, because this brand does not support Spotify Connect. It is only possible to send GET Spotify api messages to Sonos, reading some information, but not setting messages like goto next or previous song.
I think that is the reason why there is a separate Sonos app.

@pendojoshua Could you tell us what the differences are between your app and the longer existing Sonos and Spotify apps? I which cases should we use your app?

@lnnrd: I’ll add the Sonos restriction to the information of the app in the next release. You’re better off using the Sonos app instead if you are looking for ways to integrate Sonos speakers. They can only be controlled via the Sonos API and won’t even show up as controlable devices using the Spotify API which this app uses.


@Amersfoort: the difference is that my app uses your own Spotify API account and therefor the rate limit applies to just your usage. All users of the official Spotify app utilize the same Spotify API account, which basically means if you get 1000 calls to the API per month you have all 1000 to yourself if you use my app and you have to share it with X others when using the official app.

Although the setup is not as straight forward and it requires a bit more work, it does provide far more options to integrate your speaker in your smart home setup because my app unlocks all speaker abilities (volume changes, previous/next, play/pause, shuffle and repeat). Another benefit of this is having fully working media widgets including album art when using my app.

I’m also planning on adding some more flow actions that can be useful in automations as well as widgets that offer a bit more flexibility into controlling your speaker from a dashboard (like searching songs and playlists and start playing those). But that’s still work in progress and all comes down to the amount of spare time I can miss.

2 Likes

One of my most wished for features, thank you @pendojoshua. I have started using it and it works like a charm. Some hick-ups, but I suspect that is caused by my old IPad Air 2. Good work and keep up the effort!

Is it feasible to integrate the Sonos API into your app? Because Sonos is a major player in the smart speaker market, you increase the possibility of using your app.
This would allow the best of 3 apps (Sonos, the existing Spotify and your new app) to be combined into one.

Cool to see the first real-world use of the app @Bjursten! Just let me know what issues you face, who knows there’s something I can do about it.

@Amersfoort: just thinking out loud - I should be able to add two drivers into a single app but since the official Sonos app does allow all capabilities already there is no real benefits for me in doing so. It wouldn’t allow us to do anything more with a Sonos speaker compared to what we can now with the official app. And besides that, I’m ditching my Sonos speaker in favor of Spotify Connect supported devices so it would be hard for me to provide proper support or even test the Sonos part of my app…

1 Like

You are right. The only thing not working well in the Sonos app is the playing time and/or the refresh frequency.
I think I’m in the minority who consider this a disadvantage of the Sonos app.

As an alternative: the Sonos app could be called from your app (both apps should be installed without making an extra api call to Sonos), to combine both with not that much effort.

If needed: I could test an integration with Sonos. I understand that there are more important matters to deal with.