thlucas1 / homeassistantcomponent_spotifyplus

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

Integration "Not loaded" #7

Closed sulliwane closed 7 months ago

sulliwane commented 7 months ago

System Health details

System Information

version core-2024.4.2
installation_type Home Assistant Supervised
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 5.15.35-rockchip64
arch aarch64
timezone Europe/Paris
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4994 Installed Version | 1.34.0 Stage | running Available Repositories | 1401 Downloaded Repositories | 12
AccuWeather can_reach_server | ok -- | -- remaining_requests | 39
Aqara Gateway telnet_logged | 192.168.1.11 -- | -- mqtt_connected | 192.168.1.11
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 | Debian GNU/Linux 11 (bullseye) -- | -- update_channel | stable supervisor_version | supervisor-2024.04.0 agent_version | 1.5.1 docker_version | 24.0.2 disk_total | 28.4 GB disk_used | 6.1 GB healthy | true supported | true supervisor_api | ok version_api | ok installed_addons | Samba share (12.3.1), Mosquitto broker (6.4.0), Duck DNS (1.16.0), File editor (5.8.0), Node-RED (17.0.11), Zigbee2MQTT (1.36.1-1), eufy-security-ws (1.8.0-2)
Dashboards dashboards | 3 -- | -- resources | 4 views | 9 mode | storage
Recorder oldest_recorder_run | March 29, 2024 at 23:44 -- | -- current_recorder_run | April 8, 2024 at 23:32 estimated_db_size | 122.27 MiB database_engine | sqlite database_version | 3.44.2
Spotify api_endpoint_reachable | ok -- | --
Xiaomi Miot Auto component_version | 0.7.7 -- | -- can_reach_server | ok can_reach_spec | ok logged_accounts | 0 total_devices | 0

Checklist

Describe the issue

Screenshot from 2024-04-09 00-33-09 Screenshot from 2024-04-09 10-52-43 image

Reproduction steps

  1. add Spotify dev credentials (ID + secret)
  2. add spotifyPlus integration

Debug logs

Logger: homeassistant.helpers.config_entry_oauth2_flow
Source: helpers/config_entry_oauth2_flow.py:330
First occurred: 00:15:51 (3 occurrences)
Last logged: 00:36:25

Error resolving OAuth token: 400, message='Bad Request', url=URL('https://accounts.spotify.com/api/token')

Diagnostics dump

No response

sulliwane commented 7 months ago

The first time I setup the integration, it connected successfully. But after one day, the integration shows "Not loaded".

Any pointer?

Thanks 🙏

thlucas1 commented 7 months ago

it appears something is not right with the Authorization token that was created. I would suggest that you remove the SpotifyPlus integration and it’s application credentials, and try reinstalling.

Use the following steps from a desktop (or laptop) computer, making sure to carefully read and review the details of each step. Also make sure you are using the correct Spotify Developer Application client I’d and Secret values. Note that this also requires a Spotify Premium membership (free accounts will not work).

sulliwane commented 7 months ago

Thanks a lot @thlucas1 for the reply.

  1. I removed the past 7 days of cookies and cache data.
  2. I removed the integration and the application credentials.
  3. I reinstalled the integration and application credentials

Still same error "Not loaded" Screenshot from 2024-04-09 16-57-37 Screenshot from 2024-04-09 16-57-55

So I tried with another oAuth credentials that I used for another HA spotify integration, but still results in the same error: image

Quite strange

thlucas1 commented 7 months ago

What do you have for the following in your Spotify Developer Application settings?

image

sulliwane commented 7 months ago

image

sulliwane commented 7 months ago

Ok, I removed Spotify Plus from HACS. Then downloaded it again, restarted HA. Reinstalled integration. Now connection works.

Let's see for how long :)

thlucas1 commented 7 months ago

Those are correct values.

We will need to setup a detailed trace using SmartInspect. Please read and follow the instructions on the SmartInspect Trace wiki page to enable tracing for the integration.

If you do not wish to use the SmartInspect Viewer (requires extra install on Windows), then you can write the log to a file using the following setting in the /config/smartinspect.cfg file: Connections = file(filename="/config/smartinspect.sil", rotate=daily, maxparts=3, append=true)

Once you have tracing configured, run through the Spotify connect process again and send me the /config/smartinspect_x.sil file for analysis.

I will be unavailable the rest of the day, but will get back to you by tomorrow.

Thanks

thlucas1 commented 7 months ago

Glad to hear you got it working. It seems like most of the cases that report issues like yours are due to the browser caching that HA uses for the UI. The clearing of the browser cache as well as a reboot after uninstall never hurt. 😁

You will probably be good after the initial setup. Any more issues please let me know.

Also, may I ask what type of speaker hardware you will be using the integration with (e.g. ChromeCast, Sonos, etc)? I’m slowly building up configuration wiki documentation for various vendors (Bose SoundTouch, etc). If you don’t mind sharing after you get everything working; if not, no problem.

Thanks.

sulliwane commented 7 months ago

ofc, it's a Devialet Phantom II 95 dB.

So far so good, didn't loose the connection.

thlucas1 commented 7 months ago

Thank you! Please let me know if you have any supporting scripts that you use to play content with. For example, if you have a script that powers on the Devialet, switches to input1, issues a command to "wake up" the Spotify Connect Device ID for the Devialet, etc).

I get a lot of questions like "How can I make this work with my XX speaker / gear?", where XX is a brand (Devialet, Bose, Sonos, ChromeCast, etc). I have only tested this with Bose, which is the brand that I personally use to play content. Hence the buildup of a "Vendor Database" wiki document that I can direct the user to for help in configuring their environment for other vendors.

I appreciate your help - thank you!

sulliwane commented 7 months ago

I don't have any specific script for my speaker. I'm using this Devialet integration and the custom features I found so far are:

Switch off the speaker button: The HA Devialet integration offers a "switch off" button. But once I click on it, then I would have to physically press the Devialet button to switch it on image Hence I never mess up with that button (see what the button looks like in both HA and native Devialet APP below)

image Screenshot_2024-04-10-10-12-25-19_745ff76fae8a1e65f73eed4a06a569cc

Select Input/source The UI looks like this (but I don't know what is the yaml code to change the programatically) Screenshot from 2024-04-10 09-49-50

Select the sound mode The UI looks like this (but I don't know what is the yaml code to change the programatically) Screenshot from 2024-04-10 09-49-33

That's my current understanding of hardware specific features related to the Devialet.

I personnally only use it through Spotify. Was previously using this Spotify integration. Now using Spotify Plus as it's superior 💯

thlucas1 commented 7 months ago

Thank you for the information.

Regarding the power off option, I have the same thing on my Bose SoundTouch devices. I leave the power on, but it actually shows as STANDBY instead of completely powering down. If I completely power down, then it takes a physical press of the power button on the device to get it to power back on. It consumes minimal power in STANDBY mode.

Regarding the Source options ... You can use the following service call to select a different source for the Devialet. This can be used in automations, scripts, or a simple call using the Developer Tools \ Services utility. For example, let's say your Devialet was currently set on Bluetooth and you wanted it to switch to Spotify Connect. Just change the YOUR_DEVIALET_ENTITY_ID to your media player entity id.

service: media_player.select_source
data:
  entity_id: media_player.YOUR_DEVIALET_ENTITY_ID
  source: "Spotify Connect"

Regarding the Sound Mode options ... You can use the following service call to select a different sound mode for the Devialet. This can be used in automations, scripts, or a simple call using the Developer Tools \ Services utility. For example, let's say your Devialet was currently set on Voice and you wanted it to switch to night mode. Just change the YOUR_DEVIALET_ENTITY_ID to your media player entity id.

service: media_player.select_sound_mode
data:
  entity_id: media_player.YOUR_DEVIALET_ENTITY_ID
  sound_mode: "night mode"

Here are the available options for the sound_mode value:

SOUND_MODES = {
    "Custom": "custom",
    "Flat": "flat",
    "Night mode": "night mode",
    "Voice": "voice",
}

Hope it helps!

thlucas1 commented 7 months ago

Closing the issue, as it looks like it has been resolved. We can re-open if you have further issues. Thanks