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

Hello Bill,

Today I am trying to do what is discussed here, and I have come to this topic. This is what I am trying to do but it does not work, command 3 is not activated. If I remove position 2 everything works but without the delay.

1 - DataAction (Binding TV)
2 - DelayAction (10000)
3 - DataAction (Binding Harmony Activity)

Domodial

I just tested those 3 commands & they worked for me. To help troubleshoot, add step after your DelayAction that shows a toast message saying it has “finished waiting”. That’ll at least tell you the DelayAction is working.

Hello Bill,

It actually works and I haven’t changed anything in what I’m doing.
I think Harmony Hub is stupid, already by the fact that there is no PowerOff and PowerOn but only a Stateless PowerToggle.

To turn off the activity is particular of real home automation.
As usual with Logitech it’s always a big chalange ^^

What I would do now is systematically a Toast Message to get feedback and have a good look if all goes well.

But I still specify that I did not change anything when I asked you and now it works.