Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to go about writing an If Then Script

If you have a question or need help, this is the place to be.
Post Reply
aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

How to go about writing an If Then Script

Post by aldi13 »

Scenario:

I have a Macro setup that my 3 year old can activate by saying "I want to watch Micky Mouse."

The macro goes through the process of powering on TV > Receiver > Setting correct inputs > Opening Windows Media Center > Starting most recently recorded Micky Mouse TV show.

I want to build in some logic to the equation so that If the receiver is already powered on then a different macro runs that only starts the appropriate show instead of running all the beginning power on tasks.

My Onkyo receiver uses ISCP so I can run PWRQSTN via ISCP and determine the Powered On state. How can I build this into a variable of sorts and then execute the appropriate Macro based in the results of PWRQSTN?

If anyone could help me with the starting points of a script it would be most helpful as my programming experience is pretty limited.
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: How to go about writing an If Then Script

Post by kkl »

I'm sure there are much better examples, but here is a post of how I figured it out.
aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

Re: How to go about writing an If Then Script

Post by aldi13 »

Ok this is helpful. I am still a bit confused how I would call the ISCP command "PWRQSTN" and then set the variable via script. I can call the PWRQSTN now using the ISCP plugin but not sure how I write out the result to a variable.
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: How to go about writing an If Then Script

Post by kkl »

I'm not familiar with Onkyo. I assume that you would use the OnkyoISCP plugin.
blaher
Experienced User
Posts: 487
Joined: Thu Nov 17, 2011 1:27 am

Re: How to go about writing an If Then Script

Post by blaher »

This sort of thing should do the trick:
Attachments
Mickey.xml
(1.76 KiB) Downloaded 117 times
Capture.PNG
aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

Re: How to go about writing an If Then Script

Post by aldi13 »

Thanks so much for taking the time to put that together. I understand what I need to do now. Thanks for your help. :D
blaher
Experienced User
Posts: 487
Joined: Thu Nov 17, 2011 1:27 am

Re: How to go about writing an If Then Script

Post by blaher »

You're welcome. I was intrigued by kkl's method, so here's another way. I thought I may as well share my fiddling. :)
I'm not sure which is the cleanest, but both seem to work.
Attachments
Capture.PNG
Mickey2.xml
(1.74 KiB) Downloaded 124 times
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: How to go about writing an If Then Script

Post by kkl »

blaher:
REALLY good stuff. Thanks for sharing.
aldi13
Posts: 25
Joined: Wed Jan 01, 2014 3:35 pm

Re: How to go about writing an If Then Script

Post by aldi13 »

Thanks a million to you both. You have really helped boost my knowledge on how I can work with a variable. I will be using this across many different scenarios. Much thanks. :D :D
Post Reply