hklages / node-red-contrib-sonos-plus

A set of Node-RED nodes to control SONOS player in your local network.
MIT License
76 stars 14 forks source link

"group.previous track" dont't start from 0 the first track #281

Closed evazzoler closed 5 months ago

evazzoler commented 7 months ago

When I go back in queue and I play the first song, the command "group.previous track" don't start from zero the current (first) song of the queue, but gives an error.

The sonos controller app, instead acts this way (as all player physical or software do).

When I send this command while playing the first track, I get this error: group.previous.track:Sonos error on Previous UPnPError 711 (Illegal seek target) :: Details: {"stack":"SonosError: Sonos error on Previous UPnPError 711 (Illegal seek target)\n at AVTransportService.handleErrorResponse (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/base-service.js:243:23)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async AVTransportService.handleRequest (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/base-service.js:200:16)\n at async AVTransportService.SoapRequestWithBodyNoResponse (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/base-service.js:134:16)\n at async AVTransportService.Previous (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/services/av-transport.service.js:183:56)\n at async SonosDevice.Previous (/home/pi/.node-red/node_modules/@svrooij/sonos/lib/sonos-device.js:1070:31)\n at async Object.groupPreviousTrack [as group.previous.track] (/home/pi/.node-r...

It should be catched and a "play first track from zero" command should be sent. Please, consider that I could have a queue with a single song and need it to restart from zero a lot of times (music study, dance gym, psychopathic user, etc.).

hklages commented 7 months ago

Hi. As a mathematician I think that it is right to throw an error in this case: At the beginning of a queue the "group.previous.track" command is not a "valid". There does not exist a previous track at the beginning of a queue. In one of the next releases I will implement a better error message something like "invalid command as queueu is positioned at the beginning".

I leave it to the user to handle that error in a way they prefer. For you I suggest: a) use the catch node and do what you want - alternatively b) import the following flow (you can also create a subflow) - nodered is a good in handle these evens :

Does that work for you?

[
    {
        "id": "172071b517eb2990",
        "type": "sonos-universal",
        "z": "e81a72e30162d398",
        "confignode": "88e9fa70.4a53e8",
        "command": "group.get.trackplus",
        "state": "",
        "stateType": "str",
        "avoidCheckPlayerAvailability": false,
        "name": "",
        "x": 345,
        "y": 560,
        "wires": [
            [
                "23ad597e636c91dc"
            ]
        ]
    },
    {
        "id": "9d197d1d2433040c",
        "type": "switch",
        "z": "e81a72e30162d398",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            },
            {
                "t": "gt",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 647,
        "y": 560,
        "wires": [
            [
                "d930bf02868c3dda"
            ],
            [
                "66e60180f8205e89"
            ]
        ]
    },
    {
        "id": "66e60180f8205e89",
        "type": "sonos-universal",
        "z": "e81a72e30162d398",
        "confignode": "88e9fa70.4a53e8",
        "command": "group.previous.track",
        "state": "",
        "stateType": "str",
        "avoidCheckPlayerAvailability": false,
        "name": "",
        "x": 827,
        "y": 566,
        "wires": [
            []
        ]
    },
    {
        "id": "d930bf02868c3dda",
        "type": "sonos-universal",
        "z": "e81a72e30162d398",
        "confignode": "88e9fa70.4a53e8",
        "command": "group.play.track",
        "state": "",
        "stateType": "num",
        "avoidCheckPlayerAvailability": false,
        "name": "",
        "x": 847,
        "y": 517,
        "wires": [
            []
        ]
    },
    {
        "id": "23ad597e636c91dc",
        "type": "change",
        "z": "e81a72e30162d398",
        "name": "set track",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.positionData.Track",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 514,
        "y": 560,
        "wires": [
            [
                "9d197d1d2433040c"
            ]
        ]
    },
    {
        "id": "7bd447144a8d0d97",
        "type": "comment",
        "z": "e81a72e30162d398",
        "name": "↑modify",
        "info": "Select your config-node or modify it and use your ip address.",
        "x": 390,
        "y": 591,
        "wires": [],
        "icon": "font-awesome/fa-edit"
    },
    {
        "id": "a07556209c521278",
        "type": "comment",
        "z": "e81a72e30162d398",
        "name": "↑modify",
        "info": "Select your config-node or modify it and use your ip address.",
        "x": 878,
        "y": 597,
        "wires": [],
        "icon": "font-awesome/fa-edit"
    },
    {
        "id": "8f0f7994bbb4384f",
        "type": "comment",
        "z": "e81a72e30162d398",
        "name": "modify",
        "info": "Select your config-node or modify it and use your ip address.",
        "x": 877,
        "y": 485,
        "wires": [],
        "icon": "font-awesome/fa-edit"
    },
    {
        "id": "88e9fa70.4a53e8",
        "type": "sonos-config",
        "name": "your_player_dns",
        "serialnum": "",
        "ipaddress": "sonoskitchen.fritz.box"
    }
]
evazzoler commented 7 months ago

Ok, I'll try this node. I simply think that mathematics is alwais right, but the Sonos app has a behaviour, and that behaviour shold be the same of every plugin I could use for managing sonos externally. Different behaviour may confuse my wife (and I suppose your, too), and that would be a fail for me, you and mathematics... ;-) ( I'm obviuosly the first of the chain to take the blame :-b )

hklages commented 7 months ago

... Good arguments :-) I like consistency. .. will think about it.

On Sun, Feb 25, 2024, 18:50 Enrico Vazzoler @.***> wrote:

Ok, I'll try this node. I simply think that mathematics is alwais right, but the Sonos app has a behaviour, and that behaviour shold be the same of every plugin I could use for managing sonos externally. Different behaviuora may confuse my wife (and I suppose your, too), and that would be a fail for me, you and mathematics... ;-) ( I'm obviuosly the first of the chain to take the blame :-b )

— Reply to this email directly, view it on GitHub https://github.com/hklages/node-red-contrib-sonos-plus/issues/281#issuecomment-1963012186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDZCHYSIRXSEE3DUBQTWBDYVN2XNAVCNFSM6AAAAABDTOM3O6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGAYTEMJYGY . You are receiving this because you were assigned.Message ID: @.***>

hklages commented 5 months ago

Hi. Please check the new release 6.8.0 - queue mode normal, shuffle no repeat will ignore a next.track at the end and previous.track will replay the song at the beginning.

Should be the same as in the desktop app / android app

Your feedback?

evazzoler commented 5 months ago

Hi. Please check the new release 6.8.0 - queue mode normal, shuffle no repeat will ignore a next.track at the end and previous.track will replay the song at the beginning.

Should be the same as in the desktop app / android app

Your feedback?

Works like a charm! Sorry for the delay, I was far from home. Thank you so much!

(it cuts some seconds at the start of the song, but I can survive with that!)

hklages commented 5 months ago

Thanks for the Feedback. :-)

On Mon, Apr 15, 2024, 17:48 Enrico Vazzoler @.***> wrote:

Hi. Please check the new release 6.8.0 - queue mode normal, shuffle no repeat will ignore a next.track at the end and previous.track will replay the song at the beginning.

Should be the same as in the desktop app / android app

Your feedback?

Works like a charm! Sorry for the delay, I was far from home. Thank you so much!

(it cuts some seconds at the start of the song, but I can survive with that!)

— Reply to this email directly, view it on GitHub https://github.com/hklages/node-red-contrib-sonos-plus/issues/281#issuecomment-2057181055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDZCH23IPNAEIAH2BLAH4TY5PZGBAVCNFSM6AAAAABDTOM3O6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJXGE4DCMBVGU . You are receiving this because you modified the open/close state.Message ID: @.***>