Skip to content

Fix Play/Stop Sound: accept and forward the cache kwarg (TypeError on every press) - #215

Open
totol123 wants to merge 1 commit into
BSkando:mainfrom
totol123:fix/play-sound-cache-kwarg
Open

Fix Play/Stop Sound: accept and forward the cache kwarg (TypeError on every press)#215
totol123 wants to merge 1 commit into
BSkando:mainfrom
totol123:fix/play-sound-cache-kwarg

Conversation

@totol123

Copy link
Copy Markdown

Problem

Pressing any Play Sound (or Stop Sound) button does nothing. The log shows, on every press:

ERROR ... custom_components.googlefindmy.api: Failed to play sound (async) on <id>: async_submit_start_sound_request() got an unexpected keyword argument 'cache'
DEBUG ... custom_components.googlefindmy.coordinator: Entering push cooldown for 90s after transport failure

GoogleFindMyAPI.async_play_sound / async_stop_sound call the submitters with cache=self._cache:

  • async_submit_start_sound_request(device_id, token, session=self._session, cache=self._cache)
  • async_submit_stop_sound_request(device_id, token, request_uuid=..., session=self._session, cache=self._cache)

but async_submit_start_sound_request / async_submit_stop_sound_request do not accept a cache parameter → TypeError on every press. The resulting failure also enters a 90s push cooldown, which makes the buttons intermittently appear unavailable too.

Fix

Add cache: Optional[any] = None to both submitters and forward it to async_nova_request(...), which already accepts cache. This mirrors the existing device-list path (async_request_device_list(..., cache=...)).

Forwarding the entry-scoped cache also ensures the correct account's tokens are used in multi-account setups (reproduced with two Google accounts configured — without this, the sound action can resolve against the wrong cache).

Testing

With two config entries (two Google accounts), Play Sound now reliably rings the target Android phone. Verified via the device's Émettre un son button entity and via dashboard button.press actions; the unexpected keyword argument 'cache' error and the spurious 90s push cooldown are both gone.

Affected version: 1.6.2.3.

GoogleFindMyAPI.async_play_sound / async_stop_sound call
async_submit_start_sound_request(... cache=self._cache) and
async_submit_stop_sound_request(... cache=self._cache), but these
functions did not accept a cache parameter, raising
TypeError: ... got an unexpected keyword argument 'cache' on every
Play Sound button press and triggering a 90s push cooldown.

Add cache: Optional[any] = None to both submitters and forward it to
async_nova_request(...) (which already accepts it), matching the existing
device-list path. Forwarding the entry-scoped cache also ensures the
correct account tokens are used in multi-account setups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants