Transport API and volume

So I have a working baseline of what I want to do, where a Node Express site controls Roon via URLs. (Thanks FunkBrother!). Pause, Play, Next etc work perfectly by passing the commands as URL parms, but I would also like to be able to control volume. I see that there is a change_volume method in the transport API, and I have set up my site JS code to handle that command, but I am having a couple problems:

  1. Even though I am passing the zone to the method, I get an error saying that it (output_id) is missing. Here is the code:

    transport.change_volume(zone, "absolute", 20);

"zone" above is a variable set earlier in the code, and I know it is correct because the variable works correctly for Play/Pause etc.

  1. Here is what I see in the console log:

-> REQUEST 3 com.roonlabs.transport:1/change_volume {"how":"absolute","value":20}
<- COMPLETE 3 InvalidRequest {"message":"JSON: missing required string field: output_id"}

If I hard to code the zone id (which I can see in the logging so I can grab it), I don’t get that error, BUT, it does not change the volume.

FYI, the zone I am testing with is a RaspberryPi --> AQ Dragonfly Red.

I also see a separate volume API, but I don’t understand why this exists if the transport api has volume control. Also I didn’t see any examples for the volume API. and I am new at this, so I need some examples!

Thanks in advance fellow Roon tinkerers!

Your change_volume line will work if you have the correct zone object type. There appear to be 2 variants of it, a big one containing all required info to create a UI and a small one containing just a name and an output_id. It’s the second one that has to be used to change volume.

I got the correct object type via a zone selection pulldown in my settings dialog, I don’t know if there are other ways to obtain it.

You need an output, not a zone as 1st parameter.

transport.change_volume(zone.outputs[0], "absolute", 20);

This should work.

Btw. you have to use the latest version of node-roon-api-transport, since there was a bug in volume control fixed 2 days ago.

A bit misleading that it is called zone in the interface description.

I just got the pieces and parts last night, so I should be good on the version of the transport api…and THANKS SO MUCH for the info on the zone.outputs[0]

I will give that a try tonight.

I would definitely RTFM is there was one :wink: Meanwhile, FunkBrother / All, where can I find details like “zone.outputs[0]” without having to post here? Where are you finding these answers? Thanks Again!

Try and error. The error message stated, that there’s an output_id required. So i looked at the zone data structure and found the outputs array. Since i only have 1 output per zone, i’m using the first element of the array.

-> REQUEST 3 com.roonlabs.transport:1/change_volume {"how":"absolute","value":20}
<- COMPLETE 3 InvalidRequest {"message":"JSON: missing required string field: output_id"}
1 Like

can you not pass zone there instead of zone.outputs[0]? you should be able to, since volume can be changed on a grouped zone as well…if you cant… give me an “issue” on github and ill resolve

Issue has been created.

Makes total sense, thanks. I thought output_id was the zone id, rather than an output in the zone.

ive started to document this service, and ive created a github pages thing to host those docs…

i have lower level protocol docs that need to be converted into jsdoc – if anyone is up to the challenge of helping me out here… :slight_smile: just let me know…

1 Like