@@ -175,7 +175,6 @@ async def _handle_sonos_queue_itemwindow(
175175 https://docs.sonos.com/reference/itemwindow
176176 """
177177 context_version = request .query .get ("contextVersion" , "1" )
178- queue_version = request .query .get ("queueVersion" , str (int (player .sonos_queue .last_updated )))
179178 # because Sonos does not show our queue in the app anyways,
180179 # we just return the previous, current and next item in the queue.
181180 # the beginning/end flags must be honest though: signalling end-of-queue
@@ -187,7 +186,10 @@ async def _handle_sonos_queue_itemwindow(
187186 "includesBeginningOfQueue" : player .sonos_queue .includes_beginning ,
188187 "includesEndOfQueue" : player .sonos_queue .includes_end ,
189188 "contextVersion" : context_version ,
190- "queueVersion" : queue_version ,
189+ # report the version of the items we actually serve (the current window) instead of
190+ # echoing the player's requested version, otherwise a refreshed window keeps a stale
191+ # version label and Sonos never realises it changed.
192+ "queueVersion" : str (player .sonos_queue .last_updated ),
191193 "items" : [self ._parse_sonos_queue_item (x ) for x in items ],
192194 }
193195 return web .json_response (result )
@@ -201,9 +203,11 @@ async def _handle_sonos_queue_version(
201203 https://docs.sonos.com/reference/version
202204 """
203205 context_version = request .query .get ("contextVersion" ) or "1"
206+ # keep sub-second resolution: the window can be rebuilt several times within the same
207+ # second and Sonos treats an unchanged queueVersion as "nothing changed" (stale window).
204208 result = {
205209 "contextVersion" : context_version ,
206- "queueVersion" : str (int ( player .sonos_queue .last_updated ) ),
210+ "queueVersion" : str (player .sonos_queue .last_updated ),
207211 }
208212 return web .json_response (result )
209213
@@ -217,7 +221,7 @@ async def _handle_sonos_queue_context(
217221 """
218222 result = {
219223 "contextVersion" : "1" ,
220- "queueVersion" : str (int ( player .sonos_queue .last_updated ) ),
224+ "queueVersion" : str (player .sonos_queue .last_updated ),
221225 "container" : {
222226 "type" : "trackList" ,
223227 "name" : "Music Assistant" ,
0 commit comments