Script to control volume

Hi folks,

I’m after some help setting Sonos’ volume via lua code.
The below code runs successfully and changes the volume variable in Vera, but doesn’t change the actual volume of the speaker. The plugin is fully operational and I can change volume manually in ui7.
Any advice?

luup.variable_set ("urn:upnp-org:serviceId:RenderingControl", "Volume", "40", 520)

Usually on Vera, controlling a device is not done by setting its variables. If you attempted to set the “Target” state variable on a switch, it wouldn’t turn on or off, it would just change the value of the state variable.

If you want action, you need to call an “action” for the device and service that does what you want:

luup.call_action( "urn:upnp-org:serviceId:RenderingControl", "SetVolume", { DesiredVolume="40" }, 520 )

Legend! Thanks. I had tried call_action but clearly didn’t get the syntax right.
Works perfectly. Thank you!