If then Conditions

Hi fantastic software. really enjoying using it. im having great difficulty trying to make If Then Conditons with an eventAction though. i know this is possible with MultiDataTrigger however the end result of the setter is only being able to change a property not like the actions available with eventAction and binding.

To put into context i would like to do the following with the LG plugin and Yamaha plugin. Both i have working correctly.

On click of a button. Check LG.Switch . if =
off =
lg.Switch = on
delay = 5000
lg.inputsource = hdmi2
yamaha.switch = on
yamaha.inputsource=av2

on=
lg.inputsource = hdmi2
yamaha.inputsource=av2

i would love to be able to make a script. im unsure how to do so and cant find any examples on local commands.

Currently it is not possible to add Conditions to an EventTrigger like you can with a MultiDataTrigger, but funny you mention it. The next release, 3.5.0, will have support for this. There will be a new Conditions property added to each EventTrigger Action. DataAction, DelayAction, MethodAction, PropertyAction, & ScriptAction will all have a Conditions property similar to that of the MultiDataTrigger.

For the time being you can use a script. I’ve wrote one for you that should do as you’ve sketched out. I recommend replacing this script with individual actions once 3.5.0 is released. It’s generally best to only using scripting inside XAML pages when absolutely necessary. Use the other Actions when possible.

var lgSwitch = App.GetDeviceAttribute("LG.Switch");

if(lgSwitch == "Off")
{
	App.SetDeviceAttribute("LG.Switch", "On");
	sleep(5000);
	App.SetDeviceAttribute("LG.InputSource", "HDMI2");
	App.SetDeviceAttribute("Yamaha.Switch", "On");
	App.SetDeviceAttribute("Yamaha.InputSource", "AV2");
}
else
{
	App.SetDeviceAttribute("LG.InputSource", "HDMI2");
	App.SetDeviceAttribute("Yamaha.InputSource", "AV2");
}

Thank you so much Bill. I appreciate the speedy response and solution. Look forward to trying today. Keep up the good work!

1 Like