Embedded python condition script not running

Posted on
Tue Oct 08, 2019 6:40 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Embedded python condition script not running

I cut from a running python script and embedded the following in a Time/Date action Condition window, where it won't run (error: the first 'indigo' is highlighted, followed by 'a unknown token can't go after this identifier'). The first line is copied from the running python script file. Are there different rules for embedded condition scripts?

Code: Select all
season = indigo.variables[325456157].value
trigLrm = indigo.variables[1086851778].getValue(int) #livingRm
dev = indigo.devices[883519697] #living room
lrC = int(dev.states["temperature"])
if season == "winter":
   if lrC < trigLrm:

Posted on
Tue Oct 08, 2019 7:47 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Embedded python condition script not running

I think there's a couple things going on.

If I'm not mistaken, the "unknown token" error is an AppleScript error. Are you using Indigo 7.4 or an earlier version? When I enter your script into a Python condition on Indigo 7.4, it errors on line 7 -- which brings me to....

The script you posted is incomplete--it has an incomplete 'if' statement at the end.

Lastly, for Python condition scripts you need to return True for Indigo to execute the rest of the stuff. So something like this (I'm just making something up as an example):

Code: Select all
season = indigo.variables[325456157].value
trigLrm = indigo.variables[1086851778].getValue(int) #livingRm
dev = indigo.devices[883519697] #living room
lrC = int(dev.states["temperature"])
if season == "winter":
    if lrC < trigLrm:
        return True
else:
    return False
I think the 'return False' bit might be optional, because Indigo will only honor the condition if it returns True.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Oct 09, 2019 8:59 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Embedded python condition script not running

DaveL17 wrote:
I think the 'return False' bit might be optional, because Indigo will only honor the condition if it returns True.

Best to return False. Indigo will default to a False evaluation, but it will log a complaint if it doesn't get a True or False returned from the script, so to keep the Event Log tidy return False.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 14 guests

cron