My end goal was to control my Sonos speakers with Alexa. In this case, very rudimentary controls like volume +/-, play, pause, next track, etc.
Alexa has an integration with Sonos directly, but it doesn't appear this sort of control is what the integration is meant for. It's more for playing music services on command via the Sonos speaker or speakers.
I have the Sonos speaker in question connected to Hubitat. I tried simply giving Alexa control of that Hubitat device via the Alexa integration, but it seems Alexa cannot recognize the speaker device. I next tried creating a virtual volume control, and giving Alexa control of that with the skill. However, that likewise wasn't recognized by Alexa.
Finally, I decided to go with one attribute, volume. I created a virtual dimmer in Hubitat, naming is "Speaker", and using the Alexa skill to give Alexa control of it. Alexa of course recognizes it as a dimmer switch. I then created a rule using rule machine. When the level of the virtual dimmer changes, it's written to a variable. A secondary action then sets the Sonos volume level to equal that variable. The end result is I can say "Alexa, set speaker to X percent." and it will set the Sonos's volume to that level.
I assume similar sets of virtual devices (mostly switches and bulbs) can be used to create rules to accomplish my other goals (play, pause, next track, etc.). However, it just seems so messy and convoluted.
Is there a better way to accomplish this? I'm OK with the virtual equivalent of a Rube Goldberg device if that's the only option. It just seems to messy and prone to failures I'm likely not foreseeing.