From 62b06c0f56f43e4eb941c50fc411c47489642020 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Mon, 26 Jan 2026 13:46:21 +0000 Subject: [PATCH] refactor(sonos): Move device/group filters before track type checks to enable easier user workarounds Device Name/GroupName is more likely to exist and less likely to cause issues than upnpclass and other things we are looking for to verify its a valid track. User can block the erroring device to "fix" bad behavior. --- src/backend/sources/SonosSource.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/backend/sources/SonosSource.ts b/src/backend/sources/SonosSource.ts index 40e89c13..4030b04a 100644 --- a/src/backend/sources/SonosSource.ts +++ b/src/backend/sources/SonosSource.ts @@ -127,17 +127,6 @@ export class SonosSource extends MemoryPositionalSource { } public isValidState = (data: DeviceState, play: PlayObject): string | undefined => { - if (typeof data.state.positionInfo?.TrackMetaData === 'string') { - // ??? - return; - } - if(data.state.positionInfo?.TrackMetaData?.UpnpClass === undefined) { - return `UpnpClass does not exist, likely not a valid play`; - } - if (!data.state.positionInfo.TrackMetaData.UpnpClass.toLocaleLowerCase().includes('musictrack')) { - return `UpnpClass does include 'musictrack', found '${data.state.positionInfo.TrackMetaData.UpnpClass}'`; - } - if(this.devicesAllow.length > 0 && !this.devicesAllow.some(x => data.device.Name.toLocaleLowerCase().includes(x))) { return `'devicesAllow does not include a phrase found in ${data.device.Name}`; } @@ -150,6 +139,16 @@ export class SonosSource extends MemoryPositionalSource { if(this.groupsBlock.length > 0 && this.groupsBlock.some(x => data.device.GroupName.toLocaleLowerCase().includes(x))) { return `'groupsBlock includes a phrase found in ${data.device.GroupName}`; } + if (typeof data.state.positionInfo?.TrackMetaData === 'string') { + // ??? + return; + } + if(data.state.positionInfo?.TrackMetaData?.UpnpClass === undefined) { + return `UpnpClass does not exist, likely not a valid play`; + } + if (!data.state.positionInfo.TrackMetaData.UpnpClass.toLocaleLowerCase().includes('musictrack')) { + return `UpnpClass does include 'musictrack', found '${data.state.positionInfo.TrackMetaData.UpnpClass}'`; + } return; } -- 2.51.2