Spotify component no longer working

I am having huge issues with the spotify component which I’ve never had before. I’ve been using it since it was released, but about a month ago the integration disappeared and I can’t get it back. I’ve tried deleting the cache file which brings the configurator back, but every time I set it up, it appears to have worked but doesn’t, and I get two spotify related errors in the logs. The first being -

Log Details (ERROR)
Sun Aug 05 2018 17:31:31 GMT+1000 (Australian Eastern Standard Time)

Certificate did not match expected hostname: api.spotify.com. Certificate: {'subject': ((('countryName', 'US'),), 
(('stateOrProvinceName', 'Massachusetts'),), (('localityName', 'Cambridge'),), (('organizationName', 'Akamai 
Technologies, Inc.'),), (('commonName', 'a248.e.akamai.net'),)), 'issuer': ((('countryName', 'US'),), 
(('organizationName', 'DigiCert Inc'),), (('commonName', 'DigiCert ECC Secure Server CA'),)), 'version': 3, 
'serialNumber': '01D4D6D2115742D98553AE6417DD5712', 'notBefore': 'Jan 23 00:00:00 2018 GMT', 
'notAfter': 'Jan 19 12:00:00 2019 GMT', 'subjectAltName': (('DNS', 'a248.e.akamai.net'), ('DNS', '*.akamaihd- 
staging.net'), ('DNS', '*.akamaized.net'), ('DNS', '*.akamaihd.net'), ('DNS', '*.akamaized-staging.net')), 'OCSP': 
('http://ocsp.digicert.com',), 'caIssuers': ('http://cacerts.digicert.com/DigiCertECCSecureServerCA.crt',), 
'crlDistributionPoints': ('http://crl3.digicert.com/ssca-ecc-g1.crl', 'http://crl4.digicert.com/ssca-ecc-g1.crl')}

And the second being -

Log Details (ERROR)
Sun Aug 05 2018 17:31:32 GMT+1000 (Australian Eastern Standard Time)

spotify: Error on device update!
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 376, in connect
_match_hostname(cert, self.assert_hostname or hostname)
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 386, in _match_hostname
match_hostname(cert, asserted_hostname)
File "/usr/local/lib/python3.6/ssl.py", line 327, in match_hostname
% (hostname, ', '.join(map(repr, dnsnames))))
ssl.CertificateError: hostname 'api.spotify.com' doesn't match either of 'a248.e.akamai.net', '*.akamaihd- 
staging.net', '*.akamaized.net', '*.akamaihd.net', '*.akamaized-staging.net'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
 File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.spotify.com', port=443): Max retries 
exceeded with url: /v1/me/ (Caused by SSLError(CertificateError("hostname 'api.spotify.com' doesn't match 
either of 'a248.e.akamai.net', '*.akamaihd-staging.net', '*.akamaized.net', '*.akamaihd.net', '*.akamaized- 
staging.net'",),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/app/homeassistant/helpers/entity.py", line 319, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/media_player/spotify.py", line 162, in update
self.refresh_spotify_instance()
File "/usr/src/app/homeassistant/components/media_player/spotify.py", line 158, in refresh_spotify_instance
self._user = self._player.me()
File "/usr/local/lib/python3.6/site-packages/spotipy/client.py", line 568, in me
return self._get('me/')
File "/usr/local/lib/python3.6/site-packages/spotipy/client.py", line 148, in _get
return self._internal_call('GET', url, payload, kwargs)
File "/usr/local/lib/python3.6/site-packages/spotipy/client.py", line 110, in _internal_call
r = self._session.request(method, url, headers=headers, proxies=self.proxies, **args)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 511, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.spotify.com', port=443): Max retries 
exceeded with url: /v1/me/ (Caused by SSLError(CertificateError("hostname 'api.spotify.com' doesn't match 
either of 'a248.e.akamai.net', '*.akamaihd-staging.net', '*.akamaized.net', '*.akamaihd.net', '*.akamaized- 
staging.net'",),))

If anyone has had a similar issue or knows how to help it would be much appreciated.

Thanks.

Seems to be an issue with the SSL Certificate. Can you open https://spotify.com without getting an error/warning message in your browser?

1 Like

Yes I can open that fine, can login, and play music with no issues. I don’t use SSL on home assistant either, so I’m really struggling to see where the issue is.