Skip to content

Stream sync: update sync_id only when the station is playing (fixes #835, regression from #819) - #836

Merged
AlexxIT merged 2 commits into
AlexxIT:masterfrom
saidibragimov90:fix/sync-id-only-when-playing
Oct 8, 2026
Merged

AlexxIT merged 2 commits into
AlexxIT:masterfrom
saidibragimov90:fix/sync-id-only-when-playing

Conversation

@saidibragimov90

Copy link
Copy Markdown
Contributor

Problem

v3.22.1 fixed #819 by checking data["state"]["playing"] before calling sync_play_media(). But sync_id is still updated unconditionally, even when the station is not playing.

At a track boundary the station first reports the new track id in paused state and only then playing. With the current code:

  1. paused, new id → sync_id is updated, no sync_play_media (correct so far)
  2. playing, same id → sync_id == player_state["id"] → only media_play is sent

So the external player resumes the previous track instead of starting the new one, and then goes silent. Reported in #819 (comment by @sghnsk, Станция Мини 2 → mpd/umpdcli) and in #835 (Станция Макс → Sonos Arc Ultra, HA 2026.9.4, v3.22.1).

Fix

Update sync_id only together with starting playback, i.e. only when the station is playing:

if self.sync_id != player_state["id"] and data["state"]["playing"]:
    self.sync_id = player_state["id"]
    self.hass.create_task(self.sync_play_media(data))

A new id received in paused state is ignored; when the station switches to playing the id still differs from sync_id, so the new track is sent. #819 stays fixed: an id change while paused does not restart the track; on resume with the same id media_play is sent, with a different id the new track is started.

Tested

@AlexxIT
AlexxIT merged commit 4529330 into AlexxIT:master Oct 8, 2026
2 checks passed
@AlexxIT

AlexxIT commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Спасибо!

@AlexxIT AlexxIT added this to the master milestone Oct 8, 2026
@AlexxIT

AlexxIT commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants