I am running Openhabian (Openhab version 2.2 snapshot) on a Raspberry Pi 3. I have a plugable USB audio card, seen here
I was wondering if it is possible to differentiate between the on-board 3.5mm audio output and the USB audio output while making rules. I found some info on audio sinks and from what I can gather it’s pretty close to what I’m looking for. I just see the three basic sinks enhancedjavasound, javasound, and webaudio. I have the enhancedjavasound working and it sends audio to the on board 3.5mm jack.
Based on research I did before I started this thread I think this info might be relevant. The command aplay -l gives me to following
I’m not exactly sure which binding would be considered as being used to play the audio file itself. I guess the z-wave binding, although I’m using the GPIO binding as well to activate a relay. In this example a z-wave shock sensor turns on a relay (channel2) and then uses the playSound command to play the audio file in question.
rule "Dining Room Shock"
when
Item DiningRoomShock_ShockAlarm changed from OFF to ON or
Item DiningRoomShock_ShockAlarm changed from NULL to ON
then
channel2.sendCommand(ON)
playSound("drw.mp3")
end
Ok, so not a binding, then. This isn’t something I’ve seen before, but I think from a quick search, this would be calling on the code from the Audio script action.
The code looks like it has a method that would allow for passing the name of the audio sink you want to use:
@ActionDoc(text = "plays a sound from the sounds folder to the given sink(s)")
public static void playSound(@ParamDoc(name = "sink", text = "the id of the sink") String sink,
@ParamDoc(name = "filename", text = "the filename with extension") String filename) {
[...]
}
Hmmm, I’ll have to take a closer look at this later but at this point I think it might be more worth while for me to dive into pulseaudio and it’s binding. Coding isn’t my strong suit, my strengths are more with hardware/wireing related stuff. It’s not that I can’t figure it out, it just takes me some time. Pulseaudio seems to be better documented and more flexable so if I’m going to spend the time learning something new it may as well be pulseaudio.
Would I be on the right track by pursuing pulseaudio? From what I gather you can put in what hardware sink you want the audio to play through with that binding. At first glance that much seems to be documented, at least with the legacy binding.