Volume setting groovy module

i am certainly not an internet coder, but im slowly and gradually muddling through setting up my home automations.

in another thread i was given the following advice

"Create an RM or groovy module that monitors the virtual device's volume setting, then sends an http get command (of your design with the volume percent) to EG when it changes."

i simply dont even know where to start trying to learn how to write code for a groovy module, so im here to ask for some help with this one. please :smiley: and maybe some pointers where i could at least research some basic info so i can begin to learn

You need a custom app in order to observe and react to events on devices. This is a pretty good and simple example: HubitatPublic/contactMotion.groovy at master 路 hubitat/HubitatPublic 路 GitHub

It subscribes to Contact events on a device that the user selects while configuring the app. This is important -- you can't just subscribe to events from any old device without selecting it in an app preferences page. You need to find the relevant capability from this page to filter on in the input.

For your use-case, you could handle the actual volume updating on the device a couple of ways:

  • If an existing driver exists that exposes a capability such as MusicPlayer, you can just execute commands on that device in the event handler of your custom app. In this case, you would want to create and configure a child device of the music player's type, as shown in the example I linked and using the interfaces further documented here.
  • If a driver doesn't exist or you prefer not to use one, you can just do the HTTP accesses directly in the handler method of your app. The typical HTTP methods are documented here, and a useful example of usage (in a driver, though it's basically the same in an app) is here: HubitatPublic/httpGetSwitch.groovy at master 路 hubitat/HubitatPublic 路 GitHub

OK, I kinda get what your saying. I think lol.

I'm going to do some reading etc on the links you've supplied me.

I've managed to get the 'send to event ghost' app working thru hubitat, so I can activate my pc from the dashboard within reason.

I've managed to create the virtual audio volume slider.

So fingers crossed I can piece something together with your links to control the volume on my pc from the dashboard :grin: