thlucas1 / homeassistantcomponent_spotifyplus

Home Assistant integration for Spotify Player control, services, and soundtouchplus integration support.
MIT License
45 stars 3 forks source link

Error: No `application_credentials` platform for spotifyplus #31

Closed frittsy closed 2 months ago

frittsy commented 2 months ago

System Health details

System Information

version core-2024.7.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.33-haos
arch x86_64
timezone America/New_York
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4728 Installed Version | 1.33.0 Stage | running Available Repositories | 1386 Downloaded Repositories | 14
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.4 -- | -- update_channel | stable supervisor_version | supervisor-2024.06.2 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 30.8 GB disk_used | 5.5 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | kvm board | ova supervisor_api | ok version_api | ok installed_addons | Mosquitto broker (6.4.1), Zigbee2MQTT (1.38.0-1), Studio Code Server (5.15.0), Advanced SSH & Web Terminal (18.0.0), Duck DNS (1.18.0)
Dashboards dashboards | 2 -- | -- resources | 8 views | 7 mode | storage
Recorder oldest_recorder_run | July 7, 2024 at 12:30 PM -- | -- current_recorder_run | July 12, 2024 at 2:53 PM estimated_db_size | 13.58 MiB database_engine | sqlite database_version | 3.45.3

Checklist

Describe the issue

During initial configuration when adding client ID + secret to HA application credentials, I receive an error stating:

No `application_credentials` platform for spotifyplus
Screenshot 2024-07-12 at 2 48 12 PM

Reproduction steps

  1. Install SpotifyPlus
  2. Restart HA
  3. Add application credentials

Debug logs

They're 19mb from start to error, can try to parse through them if needed

Diagnostics dump

No response

thlucas1 commented 2 months ago

@frittsy To be honest, I have not seen this error before.

The first thing I would do after the HA reboot would be to clear your browser cache. With the way HA cache's web-pages, it could simply be a caching issue (not likely, but want to rule it out).

With that said, can you confirm the following for me:

Questions:

Please let me know. Thanks

frittsy commented 2 months ago

Thanks for the quick reply ❤️

thlucas1 commented 2 months ago

The following log entry indicates the application credentials are using the underlying api in some way: No module named 'spotifywebapipython'

At that point, the SpotifyPlus integration has not been installed yet.

Can you try adding the SpotifyPlus integration prior to adding Application Credentials. It should then initiate the Application Credentials setup as part of that process. Also note that you can use the same Application Credentials that you setup for the Spotify integration if you still have them defined.

If that works, then it means I probably added something to the config flow that uses the underlying API. I will need to revise the install docs to account for that.

please let me know if it works or not. Thanks

frittsy commented 2 months ago

Wouldn't the fact that SpotifyPlus shows up in the list of integrations when adding application credentials indicate that it is "added" already? I can see the source under custom_components/spotifyplus as well.

It seems to be in this state where SpotifyPlus is downloaded but not installed (i.e. it hasn't pulled dependencies)

thlucas1 commented 2 months ago

Ya, I though that was odd as well. I would think that SpotifyPlus would not be shown in the dropdown list when adding the credentials, but it is which indicates that it is installed. And if it is installed, and the spotifywebapiPython is a dependency, then why can't it find it?

Also, the fact that you have had Spotify registered before would indicate that OAuth is setup properly.

Can you verify the manifest.json file contents? It should look something like the following; looking to ensure that the spotifywebapiPython>=1.0.73 requirement is in there.

{
  "domain": "spotifyplus",
  "name": "SpotifyPlus",
  "codeowners": [ "@thlucas1" ],
  "config_flow": true,
  "dependencies": [
    "application_credentials",
    "zeroconf"
  ],
  "documentation": "https://github.com/thlucas1/homeassistantcomponent_spotifyplus/wiki/Device-Configuration-Options#integration-options",
  "integration_type": "service",
  "iot_class": "cloud_polling",
  "issue_tracker": "https://github.com/thlucas1/homeassistantcomponent_spotifyplus/issues",
  "requirements": [
    "oauthlib>=3.2.2",
    "platformdirs>=4.1.0",
    "requests>=2.31.0",
    "requests_oauthlib>=1.3.1",
    "smartinspectPython>=3.0.33",
    "spotifywebapiPython>=1.0.73",
    "urllib3>=1.21.1,<1.27",
    "zeroconf>=0.132.2"
  ],
  "version": "1.0.40",
  "zeroconf": [ "_spotify-connect._tcp.local." ]
}

I am going to remove SpotifyPlus on my test image, and reinstall from scratch to ensure that I have not added anything over the past few months that would prohibit the install (from scratch).

thlucas1 commented 2 months ago

I removed all references to SpotifyPlus and Spotify integrations, and removed both from HACS as well as removed all OAuth Application Credntials. After a reboot, I also ensured that SpotifyPlus does not show up in the integration list when trying to add a new OAuth Application Credential; note that Spotify does still show up in the integration list, as the Spotify integration is a base component of HA (SpotifyPlus is not a base component).

All well and good thus far.

I then install SpotifyPlus via HACS (using the SpotifyPlus Installation Instructions wiki document) and reboot HA. I verified that the /config/custom_components/spotifyplus directory exists on the file system, and that it contains the latest version (v1.0.40).

I then proceed to Home Assistant Application Credentials - Step 3 in the Device Configuration Options wiki document.

I tried all of the following, and it successfully added application credentials to the list:

image

I then added the SpotifyPlus integration, choosing the Todd L Premium OAuth credential. A couple of clicks later I was playing the Spotify DJ playlist on my Bose SoundTouch.

Other Things I Tried

I also deleted the SpotifyPlus integration using the Todd L Premium OAuth credential, and tried re-adding it using the Spotify frittsy OAuth credentials. It failed (as it should) with a oauth_failed dialog, as well as the following System Log entries:

2024-07-13 10:57:06.746 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request for spotifyplus_45895c797e0a4b18a9167c80c2c42022 failed (invalid_client): Invalid client secret
2024-07-13 10:57:06.746 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Error resolving OAuth token: 400, message='Bad Request', url=URL('https://accounts.spotify.com/api/token')

Again, the failure was expected behavior, as I do not know your the secret for your OAuth Application ClientId.

Next Steps

At this point I would suggest the following (basically uninstall / reinstall SpotifyPlus integration):

frittsy commented 2 months ago

I did manage to get this working, after several reinstallations and the first few not working.

It will be impossible to isolate/diagnose what the true problem was here, but on my successful attempt I did reconfigure HACS and enable that debug flag, in an attempt to get more logs from HACS. And on this same attempt, I had downgraded to SpotifyPlus 1.0.39. I was also doing a hard refresh on every page I navigated to. But since my successful attempt, I upgraded back to 1.0.40 and ran through the steps again with no issues.

I should also note that before installing SpotifyPlus for the very first time, I did upgrade HACS from 1.33.0 to 1.34.0. I can't recall if I rebooted HA before installing SpotifyPlus, but perhaps I screwed that up and only by reconfiguring HACS did it sort itself out? I'm grasping at straws obviously but I just want to leave some notes in case this ever happens to someone else.

Anyway, I really appreciate your support and I'm looking forward to giving SpotifyPlus a whirl now 😊

thlucas1 commented 2 months ago

Glad you got it figure out, as I was running out of ideas. :-) Thanks for the coffee as well, you didn't have to do that. I appreciate it.