Python Error Help

Posted on
Sat Jun 05, 2021 1:13 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Python Error Help

Hey,

Can’t get this to compile:
Code: Select all
DTOD = indigo.variables[202906811] #DisplayTimeOfDay
DB = indigo.variables[1934444056] #display_bac
if DTOD == "morning" and DB == "Summer"
   indigo.variable.updateValue(1934444056, value="summer_morning") #display_bac
  elif DTOD == "afternoon" and DB == "Summer"
   indigo.variable.updateValue(1934444056, value="summer_afternoon") #display_bac
  elif DTOD == "evening" and DB == "Summer"
   indigo.variable.updateValue(1934444056, value="summer_evening") #display_bac
  elif DTOD == "night" and DB == "Summer"
   indigo.variable.updateValue(1934444056, value="summer_night") #display_bac


“invalid syntax”
Any idea why?

Thanks,

Carl

Posted on
Sat Jun 05, 2021 2:22 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python Error Help

Because the indentation of the 'if' and 'elif' lines doesn't match. The 'elif' should be indented the same as the 'if' (in this case, not at all).

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Jun 05, 2021 2:30 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python Error Help

Also, you need colons at the end of the conditional (if, elif) lines.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Jun 05, 2021 2:49 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Python Error Help

Bingo on the missing colon.
Works great, thanks!

Carl

Posted on
Sat Jun 05, 2021 2:50 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python Error Help

Spending a few hours doing an on-line intro to Python course would get you past these simple errors on your own...

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Jun 06, 2021 4:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python Error Help

Hey Carl, I don't think the script is working since you're comparing a variable instance against a string (rather than the value of the variable instance). I think you're looking for this, which I've cleaned up to make somewhat simpler:

Code: Select all
DTOD = indigo.variables[202906811] #DisplayTimeOfDay
DB = indigo.variables[1934444056] #display_bac
if DB.value == "Summer":
   if DTOD.value == "morning":
      indigo.variable.updateValue(1934444056, value="summer_morning") #display_bac
   elif DTOD.value == "afternoon":
      indigo.variable.updateValue(1934444056, value="summer_afternoon") #display_bac
   elif DTOD.value == "evening":
      indigo.variable.updateValue(1934444056, value="summer_evening") #display_bac
   elif DTOD.value == "night":
      indigo.variable.updateValue(1934444056, value="summer_night") #display_bac


Also note that you are updating the variable that you're initially checking for "Summer" - so after this script runs it may no longer be "Summer". Not sure if that's your intent or not.

And, I know we've recommended this before, but +1 to @FlyingDiver's recommendation to take an online python tutorial. It will really help you out.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jun 06, 2021 8:53 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Python Error Help

Thanks Jay. Yes, I realized the mistake and corrected.
Also yes, I’m pretty hopeless at scripting. Always trying but I’m a graphics guy,..always struggled with any type of coding.

Carl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests