Skip to content

Commit

Permalink
[ 1.0.30 ] * Updated config_flow to utilize the HA shared Zeroconf …
Browse files Browse the repository at this point in the history
…instance.

  * Updated underlying `spotifywebapiPython` package requirement to version 1.0.62.
  * The underlying `spotifywebapiPython` update fixes a potential memory leak with the Zeroconf discovery process.
  • Loading branch information
thlucas1 committed Jun 22, 2024
1 parent 15a67a0 commit f2f363c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ Change are listed in reverse chronological order (newest to oldest).

<span class="changelog">

###### [ 1.0.30 ] - 2024/06/22

* Updated `config_flow` to utilize the HA shared Zeroconf instance.
* Updated underlying `spotifywebapiPython` package requirement to version 1.0.62.
* The underlying `spotifywebapiPython` update fixes a potential memory leak with the Zeroconf discovery process.

###### [ 1.0.29 ] - 2024/06/21

* Fixed a bug due to `SpotifyConnect` addon not properly returning a "Content-Type: application/json" header in it's Spotify Zeroconf API responses. This was causing an error when trying to retrieve the Spotify Connect device list, and returning errors in the configuration options form.
* Fixed a bug due to `SpotifyConnect` addon not properly returning a "Content-Type: application/json" header in it's Spotify Zeroconf API responses. This was causing an error in the SpotifyPlus integration when trying to retrieve the Spotify Connect device list, and returning errors in the configuration options form.
* Updated underlying `spotifywebapiPython` package requirement to version 1.0.61.

###### [ 1.0.28 ] - 2024/06/19
Expand Down
15 changes: 11 additions & 4 deletions custom_components/spotifyplus/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from spotifywebapipython import SpotifyClient
from spotifywebapipython.models import Device, SpotifyConnectDevices

from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntry, OptionsFlow
from homeassistant.const import CONF_DESCRIPTION, CONF_ID, CONF_NAME, Platform
from homeassistant.core import callback
Expand Down Expand Up @@ -108,14 +109,19 @@ async def async_oauth_create_entry(self, data:dict[str,Any]) -> FlowResult:

try:

# get shared zeroconf instance.
_logsi.LogVerbose("Retrieving the HA shared Zeroconf instance")
zeroconf_instance = await zeroconf.async_get_instance(self.hass)

# create new spotify web api python client instance - "SpotifyClient()".
_logsi.LogVerbose("Creating SpotifyClient instance")
tokenStorageDir:str = "%s/custom_components/%s/data" % (self.hass.config.config_dir, DOMAIN)
spotifyClient:SpotifyClient = await self.hass.async_add_executor_job(
SpotifyClient,
None, # manager:PoolManager=None,
tokenStorageDir, # tokenStorageDir:str=None,
None # tokenUpdater:Callable=None,
None, # manager:PoolManager=None,
tokenStorageDir, # tokenStorageDir:str=None,
None, # tokenUpdater:Callable=None,
zeroconf_instance # zeroconfClient:Zeroconf=None,
)

_logsi.LogObject(SILevel.Verbose, "SpotifyClient instance created - object", spotifyClient)
Expand All @@ -132,8 +138,9 @@ async def async_oauth_create_entry(self, data:dict[str,Any]) -> FlowResult:
_logsi.LogObject(SILevel.Verbose, "SpotifyClient token authorization was set - object (with AuthToken)", spotifyClient)
_logsi.LogObject(SILevel.Verbose, "SpotifyClient UserProfile - object", spotifyClient.UserProfile)

except Exception:
except Exception as ex:

_logsi.LogException(None, ex, logToSystemLogger=False)
return self.async_abort(reason="connection_error")

# is this a reauthentication request?
Expand Down
4 changes: 2 additions & 2 deletions custom_components/spotifyplus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"requests>=2.31.0",
"requests_oauthlib>=1.3.1",
"smartinspectPython>=3.0.33",
"spotifywebapiPython>=1.0.61",
"spotifywebapiPython>=1.0.62",
"urllib3>=1.21.1,<1.27",
"zeroconf>=0.132.2"
],
"version": "1.0.29",
"version": "1.0.30",
"zeroconf": [ "_spotify-connect._tcp.local." ]
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ colorlog==6.7.0
homeassistant==2024.5.0
ruff==0.1.3
smartinspectPython>=3.0.33
spotifywebapiPython>=1.0.61
spotifywebapiPython>=1.0.62

0 comments on commit f2f363c

Please sign in to comment.