playSound(“barking.mp3”) in a rule script plays a sound through the server’s speakers, as intended, but at the maximum volume, which is too loud. In contrast with the documentation, playSound() doesn’t accept a second PercentType argument to control sound, e.g.,
playSound(“barking.mp3”, new PercentType(5))
results in the logs showing “The name ‘playSound’ cannot be resolved to an item or type”.
Preceding the playSound() command with setMasterVolume(0.1) still plays the sound at the maximum volume. The log file indicates that ‘test.rules’ was refreshed, and there are no warnings in this case; it silently fails to change the volume.
Did you get something working reliably with PulseAudio? I don’t have it running at system-level, but a particular user will always be logged in and running it. But then I somehow need to give the (different) openhab user access through module-cli-protocol-tcp, right? Do I also need to mess around with the JVM sound configuration file to tell it to use PusleAudio? Then do I need yet another binding to PulseAudio to send volume change commands to it? There must be other people who want to have the computer talk and make sound in response to sensed events. What’s the typical way of doing that?
I set up the PulseAudio bindings, created a Thing for the PulseAudio Server and another Thing for the appropriate sink. I also created a dimmer item for the sink. I can set its volume dimmer, and read back the set value. However, I don’t know how to get it to send sound to the desired (PulseAudio) sink.
the logs indicate “Failed playing audio stream ‘org.eclipse.smarthome.core.audio.FileAudioStream@5d3463e’ as no audio sink was found.”
Calling it pulseaudio:sink:208d0fe0:alsa_output_usb_Focusrite_Scarlett_2i2_USB_00_analog_stereo results in the same failure.
To find the correct name for the sink, I logged into the CLI
openhab> smarthome:audio sinks
System Speaker (enhancedjavasound)
Web Audio (webaudio)
That seems to indicate that there are no new sinks.
How to I get it to play to the PulseAudio sink for which I can (apparently) set volume?
I’d like to add that for those using Windows, I found that using foobar2000 available at foobar2000.org with theUpNP renderer, server and control point component as a UpNP renderer controlled by the UpNP binding at the end of thread: DLNA / UPNP binding works great for me.