WAF went down recently as I cant find a way to set the Volume on a Music Device using Global Variables. The time to reconfigure all TTS rules using IF / ELSE-IF / ... blocks is quite time consuming, but could be done.
I was hoping to update a GV to a different setting for each mode, then set the Music Device volume to the GV. This would drastically reduce the number of IF / ELSE-IF / ELSE-IF / END IF clauses that are needed in each RULE to facilitate the same functionality.
I have not. Between a few hubs I have about 120+ rules that use TTS and I was hoping to set a volume by MODE (ie. time of day) and use a Global variable to set the Music Device Volume level. From what I remember the scope of a custom actions is / rule??? I will dig into custom actions a little further, perhaps I missed something.
I agree that a GV would far better!! After giving it a think, it might be better to create a couple custom commands and then create some simple If condition statements to assign the appropriate custom command to a mode (e.g. If mode is Day then custom command vol 20).
What music device are you trying to control? Some devices have implemented the dimmer capability in order to control the device like a dimmer. There may be a custom driver out there that does exactly that.
Or, you could create a virtual dimmer, have a rule to set the dimmer value into a global variable and then set the volume equal to that global variable.
Similar issue here. I'm trying to create a rule in rule machine that grabs the current volume of my Google Home mini, writes it to a variable, changes the volume, speaks text, then uses the variable to set the volume back to the way it was before the volume change. It won't let me use a variable in the set volume in rule machine and the custom action doesn't populate the Google Home mini.
This is all doable. To set a variable to the current volume of the Google Home mini, use the Set Variable action, with a Number variable, and choose Device Attribute, like this:
I will look into allowing a variable directly in the Set Volume action to avoid having to use a Custom Action. But for now, Custom Action works fine. Use Actuator to pull of the Google Mini device.
Sweet! That allowed me to build the rule the way I wanted. I never would have thought to use the actuator option to set volume. Thanks for the tip!
Good point. For me, it works for a while after I have played something. I was testing my rule actions after I had recently played test audio because I knew about that limitation within the device settings, but I didn't think about the fact that the same limitation applied to rules. Without it having played audio recently, the volume changes do not take effect. The only workaround I could think of is to write the current volume to a variable, speak some dummy text, delay a few seconds, change volume to desired level, delay a few seconds, speak desired text, delay 20 seconds, then change volume back to the original volume from the variable. Kind of annoying, but I tested it and it works. If anyone else has any more elegant solutions, I'm all ears.
@bravenel Can you also add the ability (if it isn't already there) to allow for a variable to be used on a delay? So, if I wanted to set a delay to 1 minute and then have that carry through to multiple actions, I'd love to be able to set a variable at the beginning of the rule and then use it in my delays:
IF(Contact Sensor is open) THEN
Set Variable ( delayTime ) to 00:01:00
// Perform some stuff
Off : Light 1 -> delayed %delayTime% (cancel)
Dim : Light 2, Light 3 50% -> delayed %delayTime% (cancel)
END-IF
It's already there. You can put a variable name, as in %my-variable%, in the seconds field of a delay. When you do that, leave the minutes and hours fields empty.
At this point I think every numeric input field in RM allows variables. It's very easy to tell, as one that doesn't allow it won't let you type the %. If you run across any, let me know and they will be fixed to allow a variable.
Note that for some inputs the value of the variable is tested to see if it is in the required range or not, and it won't allow an out-of-range value. For example, volume must be 0 to 100.