things file
Thing exec:command:playsound [
command="play /etc/openhab2/sounds/doorbell.mp3",
interval=0,
autorun=true]
items file
Switch TestButton1 "Test button"
Switch SwitchPlaySound "Play the text message sound" {channel="exec:command:playsound:run"}
String PlaySound_Args {channel="exec:command:playsound:input"}
String PlaySound_out {channel="exec:command:playsound:output"}
rules file
when
Item TestButton1 changed
then
logInfo("Sound rule", "rule is running")
setMasterVolume(new PercentType(80))
//playSound("doorbell.mp3")
//PlaySound_Args.sendCommand("/etc/openhab2/sounds/doorbell.mp3")
//while(SwitchPlaySound.state != OFF){
//Thread::sleep(500)
//}
SwitchPlaySound.sendCommand(ON)
// Logging of command line result
logInfo("PlaySound output", "Result:" + PlaySound_out.state )
//SwitchPlaySound.sendCommand(ON)
end
result
19:18:10.239 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'TestButton1' received command ON
19:18:10.240 [INFO ] [pse.smarthome.model.script.Sound rule] - rule is running
19:18:10.256 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestButton1 changed from OFF to ON
19:18:10.391 [INFO ] [arthome.model.script.PlaySound output] - Result:NULL
19:18:10.391 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'SwitchPlaySound' received command ON
19:18:10.392 [INFO ] [arthome.event.ItemStatePredictedEvent] - SwitchPlaySound predicted to become NULL
and obviously no sound plays
the sound plays on the command line
openhab owns file belongs to audio group file is 777 permissions