[ST Edge] Sonos LAN based Control

Radio stations are through BBC Sounds and TuneIn but I cant get it to work with Sonos playlists either. Previous driver % was working with playlists only as at that time the radio stations did not appear in your favourites list…

Cant get you any logs this evening but I will check all remains the same after the driver updates to the more recent version and grab some for you.

Oh and… The currently playing info is not updating for me outside of playlists either. Not really a problem but just comparing to stock…

The use case is below except only your device was required. Play and stop can not be seen on a routine action together but ‘on and stop’ or ‘play and off’ could previously (I think). As it is the mix-n-match with stock and yours below works…

So the ‘then’ would be play with a delayed off… actually you know, I’m not 100% sure this did work previously I may have been using both devices but with on instead of play originally - it was late last night and the routines deleted with your driver update :thinking:

Although on/off definitely allowed control from smart lighting as well as routines which was another bonus…

@schwark I owe you an apology the inclusion of on/off does not allow a doubling up on one device. My bad - put it down to a lot of late night fiddling and resultant brain fog :slight_smile: It does though expose the device to smart lighting allowing on/off control there so that is a definate +ve as it allows reduction in routines freeing up the 200 limit for other things, thankyou for that :+1:

I have further PM’d you with logs for the favourite issue, thank you again for your efforts :beers:

Hi @schwark I was just going to discard the ST stock in favour of your driver and noticed that selecting the LAN driver to play a message from a routine on does not seem to work when compared to stock?

1 Like

@schwark First, thanks for all the great work to get this going!

Will it be on the roadmap to fix the ability to play a message from a routine? I use this feature a lot and would love to switch over to the your driver for the additional functionality.

As a side note, do you know if a similar type of driver could be developed for the Roku soundbars?

Can this driver toggle the night mode for Sonos speakers?

@Robert_Singh This one can’t but @rym002 has one here:

Installs against play bar/arc ect:

Hi @schwark - Another feature request should you be so inclined :blush:

Would it be possible to expose Sonos groups to ST to allow direct group control:

Would be a really useful feature :+1:

I’m wondering if something has changed recently. For several weeks now I’ve had this Routine working where I open the liquor cabinet and a Favorite plays (and a notification gets sent). Suddenly it doesn’t do that anymore - I only get the notification. I logged the activity in the CLI and see the following results:

2022-12-22T18:28:54.883859687+00:00 INFO Sonos LAN found media Heavenly Choir for Heavenly Choir
2022-12-22T18:28:54.886919187+00:00 INFO Sonos LAN adding to queue on RINCON_B8E937F8B6CE01400 uri x-sonos-http:ALkSOiHpYKDhqX_Abi7x3M0hl41_O9Gt9qnHILFUb4jdDYw2.mp4?sid=284&flags=0&sn=13
2022-12-22T18:28:54.891210687+00:00 DEBUG Sonos LAN executing on Kitchen + 1 command AddURIToQueue with params {DesiredFirstTrackNumberEnqueued=1, EnqueuedURI=“x-sonos-http:ALkSOiHpYKDhqX_Abi7x3M0hl41_O9Gt9qnHILFUb4jdDYw2.mp4?sid=284&flags=0&sn=13”, EnqueuedURIMetaData=“dc:titleHeavenly Choir</dc:title>upnp:classobject.item.audioItem.musicTrack.#TRACK</upnp:class>SA_RINCON72711_X_#Svc72711-0-Token”}
2022-12-22T18:28:55.005794229+00:00 ERROR Sonos LAN Kitchen + 1 : AddURIToQueue error code 800 Command not supported or not a coordinator
2022-12-22T18:28:55.009985395+00:00 ERROR Sonos LAN Kitchen + 1 thread encountered error: [string “st/dispatcher.lua”]:233: Error encountered while processing event for <Device: 4ae52f21-e41a-4731-94ed-050d48567ab2 (Liquor Chime)>:
arg1: table: 0x2a361e8
[string “sonos/soap.lua”]:669: assertion failed!

Not sure why this “command not supported” error suddenly started popping up. Any help would be appreciated.
BD

have you tried recreating the Routine?

I have tried changing the favorite, but I haven’t tried recreating the routine. I can do that and post back.

BD

Same results with the new routine.

Great driver, just switched to this after the end of webcore. Feature request - can you add a volume up/down option, ie take current value and add or deduct a value, rather than simply being able to apply a fixed value? Thanks!

2 Likes

There is this GitHub - toddaustin07/edge_roku: SmartThings Edge Driver for Roku devices from @TAustin (disclaimer: I don’t have any Roku products - I have no idea if this covers your use case).

Hello @schwark , Thanks for the great work !
I just installed your driver and, on the iOS app, FR language, there are no “Settings” sub menu in the device menu. The favorite selection section is also greyed out.
My use case being playing a door bell sound, I’m stuck.

I also have the same problem. I can’t pick a favourite. It is greyed out. I can type a favourite in a routine or scene but it ignores it and simply plays whatever is already in the queue.

It seems to work for me now after deleting and re-adding all Sonos devices.

Next issue is that playing a favourite doesn’t replace the queue.

Looks like this may be relevant: Is there a way to clear the sonos queue via the API? - Stack Overflow

1 Like

The official Sonos Edge Driver (Beta) has an preference setting to replace the queue.

Just posting my solution for this by going outside the app and creating a new rule via the smartthings CLI, which allows level-based volume control on the speaker group - hopefully others find useful… (replace button-id and sonos-dth-id with the appropriate IDs which you can find by listing your devices)

{
   "name": "Sonos Button 1 volume increase",
   "actions": [
      {
         "if": {
            "equals": {
               "left": {
                  "string": "pushed"
               },
               "right": {
                  "device": {
                     "devices": [
                        "button-id"
                     ],
                     "component": "button1",
                     "capability": "button",
                     "attribute": "button"
                  }
               }
            },
            "then": [
               {
                  "if": {
                     "lessThan": {
                        "left": {
                           "device": {
                              "devices": [
                                 "sonos-dth-id"
                              ],
                              "component": "main",
                              "capability": "mediaGroup",
                              "attribute": "groupVolume"
                           }
                        },
                        "right": {
                           "integer": 9
                        }
                     },
                     "then": [
                        {
                           "command": {
                              "devices": [
                                 "sonos-dth-id"
                              ],
                              "commands": [
                                 {
                                    "component": "main",
                                    "capability": "mediaGroup",
                                    "command": "setGroupVolume",
                                    "arguments": [{"integer":9}]
                                 }
                              ]
                           }
                        }
                     ],
                     "else": [
                        {
                           "if": {
                              "lessThan": {
                                 "left": {
                                    "device": {
                                       "devices": [
                                          "sonos-dth-id"
                                       ],
                                       "component": "main",
                                       "capability": "mediaGroup",
                                       "attribute": "groupVolume"
                                    }
                                 },
                                 "right": {
                                    "integer": 13
                                 }
                              },
                              "then": [
                                 {
                                    "command": {
                                       "devices": [
                                          "sonos-dth-id"
                                       ],
                                       "commands": [
                                          {
                                             "component": "main",
                                             "capability": "mediaGroup",
                                             "command": "setGroupVolume",
                                             "arguments": [{"integer":13}]
                                          }
                                       ]
                                    }
                                 }
                              ],
                              "else": [
                                 {
                                    "if": {
                                       "lessThan": {
                                          "left": {
                                             "device": {
                                                "devices": [
                                                   "sonos-dth-id"
                                                ],
                                                "component": "main",
                                                "capability": "mediaGroup",
                                                "attribute": "groupVolume"
                                             }
                                          },
                                          "right": {
                                             "integer": 19
                                          }
                                       },
                                       "then": [
                                          {
                                             "command": {
                                                "devices": [
                                                   "sonos-dth-id"
                                                ],
                                                "commands": [
                                                   {
                                                      "component": "main",
                                                      "capability": "mediaGroup",
                                                      "command": "setGroupVolume",
                                                      "arguments": [{"integer":19}]
                                                   }
                                                ]
                                             }
                                          }
                                       ],
                                       "else": [
                                          {
                                             "command": {
                                                "devices": [
                                                   "sonos-dth-id"
                                                ],
                                                "commands": [
                                                   {
                                                      "component": "main",
                                                      "capability": "mediaGroup",
                                                      "command": "setGroupVolume",
                                                      "arguments": [{"integer":25}]
                                                   }
                                                ]
                                             }
                                          }
                                       ]
                                    }
                                 }
                              ]
                           }
                        }
                     ]
                  }
               }
            ]
         }
      }
   ]
}

3 Likes

I’m hoping for some help removing this driver. I try to remove the driver from the drivers menu in the hub, but I get “This driver can’t be deleted because it’s currently being used.” I assume that’s because the devices that got created when I scanned, are still in Smartthings.

But I can’t delete the devices. I mean I can, but they immediately reappear on their own. How can I get rid of these and the driver?

Thanks
BD

This means that you have a device using the driver. Delete the devices and you can remove the driver…