External Device Volume Control

I am starting to do some coding of extensions for my own use. One I’m starting to consider is volume control of an external device.

Right now, I have Event Ghost running on my main endpoint. The endpoint is a Windows box running RoonBridge as a service. Event Ghost responds to various inputs and sends correct IR codes to my Peachtree Pre/Dac to control volume, among other things.

My plan for the extension is rather kludgy. Presently, the endpoint has fixed volume in Roon. I plan on switching that to DSP volume. The DSP volume would be pegged at 99% (or -1db, I guess). When the extension saw a change of volume for that endpoint, it would determine if it was up or down and then send a message to the Event Ghost instance on the endpoint to do its thing. The DSP volume would be reset to 99%.

This is really kludgy. Anyone have any thoughts on a different, viable approach?

A couple of things to consider.

I use home assistant to integrate roon with other devices. One of the things I do is to send IR codes to turn on and select inputs when I see a roon zone start playing. This means that you can just use a roon remote - and the devices turn on and off correctly ( I pause and restart roon after the device is turned on). I also use zwave switches to power on devices too.

I maintain the HA roon automation - but the real power of HA are the huge range of other integrations, You can do a lot of things with the built in automation tools.

So that might help.

Depending on your preferred language I also maintain a python wrapper to the roon api. There is a demo that shows you how to subscribe to events.

I’m actually using pyRoon now. I see that the Roon API has a volume control services that the extension can publish, but I’m not seeing if/how it’s implemented in pyRoon. I may need to figure this all out in Node.

BTW, my goal is to control volume in the Roon remote app, which I don’t think you described your setup doing.

Pyroon doesn’t currently support the volume service. Partly because I wasn’t sure how people would use it, but perhaps you’ve found an example!

The subscription example does get notifications if an endpoint volume is changed. Not sure if that’s what you need.

Ah! I didn’t realize that was your project. It’s great!

The approach I described uses the endpoint volume change notification.

How would I go about implementing the volume control service in Python? Should I just bite the bullet and dig into Node?

It’s likely to be a bit of work.

Pyoon uses the undocumented roon socket interface and duplicates the node wrapper of the official api.

So yes you’d need to look at the node source code.

When I took over the library there was some code, which I couldn’t work out how it was used.

A while back there was a PR from a developer interesting in bringing it back, but there wasn’t much follow up, so I closed it without merging.

But it’s likely a good starting point

Well, I’m a jack of all trades, master of none. I think the websocket work might be above my pay grade.

There’s some code on GitHub for a different volume controller. If I can get up and running on Node, I’ll be able to leverage that work for .mine

1 Like

A quick update. I took a look at the SebuZet code and manually imported it. It works. I am at the point where I am registering a volume controller and receiving control_volume messages from the core. I’ll need to figure out what update to send back to the core after controlling the volume, but some reasonable steps forward have been accomplished.

1 Like

I think that code was mostly from the original author of pyroon.

When I was tidying up I removed a few things that I couldn’t work out. That PR mostly put it back!

Would be really nice to have some example code if you’d be up for adding that.

I have the last main puzzle piece done, namely, the proper update back to the core (it was trivial, actually).

I 100% would like to share my code. Right now it’s just stub code, that is, it just sets everything up and sends/receives updates. Where/how should I post?

1 Like

Are you up for submitting a GitHub PR?

That’s the best mechanism if it’s not too cub hassle.

How do pull requests work? I know jack ■■■■ about version control other than grabbing files off of GitHub.

The basics are here:

But if it’s too hard you can email me the code.

@GregD, I sent a PR. Not sure if I did everything (or anything, for that matter) correctly, but at the very least you will be able to see my code.

Will take a look. Thanks very much.