setMasterVolume

Hello I’m a beginner, in my project I use the voice messages using the say command.

I would like to set the message volume using the setMasterVolume command at 8:00 am at 80 and at 20:30 at 20
How can I implement the rule?

OpenHab Version 1.8
hardware platform Raspberry pi

  1. Create a rule using cron
  2. Using exec binding, use these commands in your rule
amixer scontrols && amixer sset 'Master' < the volume >

example

amixer scontrols && amixer sset 'Master' 20%

Try this :slight_smile:

rule "Set Volume to 80 at 8 am"
when
  Time cron "0 0 8 ? * * *"
then
  executeCommandLine("amixer set PCM -- 80%")
end

rule "Set Volume to 20 at 8:30 pm"
when
  Time cron "0 30 20 ? * * *"
then
  executeCommandLine("amixer set PCM -- 20%")
end

ok, thank you, I try

but if OpenHab should reboot how the volume behaves?

amixer set PCM -- 20%

. is no Openhab Control … this is a controll of the Raspberry …

@omar1971

In a rule, you can use

    logInfo ("test-rule", "Master volume is " + getMasterVolume())
    setMasterVolume(new PercentType(10))
    logInfo ("test-rule, "New master volume is " + getMasterVolume())

Which will produce something like

2018-01-27 12:00:03.022 [INFO ] [se.smarthome.model.script.test.rules] - Master volume is 0.2
2018-01-27 12:00:03.022 [INFO ] [se.smarthome.model.script.test.rules] - New master volume is 0.1

This seems to apply the volume to the default audio sink defined in Paper UI. I think this will work for notifications played through Sonos and Squeezebox. I’m not sure about other bindings that support audio sink, or System Speaker.