Embedded scripts in a schedule not running.

Posted on
Sat Feb 18, 2017 3:16 pm
aldera offline
User avatar
Posts: 188
Joined: Aug 30, 2016
Location: Michigan, USA

Embedded scripts in a schedule not running.

I just bought a ZWave thermostat (Trane XR524) and I'm trying to keep track of my furnace's runtime. I have a trigger that fires whenever the furnace turns on and that trigger enables another trigger that runs every minute and increments the daily runtime variable by 1. I have variables to keep track of the daily, weekly, monthly, yearly and overall runtime. When the furnace turns off, the incrementing trigger is disabled. At midnight, I have a schedule that runs and adds the daily runtime to each variable (weekly, monthly, yearly, overall). If I manually run the script in the schedule by clicking the "Run" button, the script updates all the variables. However, whenever the schedule itself is run, the script never updates the variables. The only action that runs is the last item that zeros out the daily runtime variable. I included a picture of the actual schedule window with the 2 actions. Assuming the actions are run from top to bottom, the variables should all update before the daily variable is reset to 0.

Below is the embedded script.

#Add daily total to all totals

#Add daily total to weekly total
dailytime = indigo.variables[1504762459]
weektime = indigo.variables[773236496]
total = int(dailytime.value) + int(weektime.value)
indigo.variable.updateValue(773236496, value=unicode(total))

#Add daily total to monthly total
monthtime = indigo.variables[520397369]
total = int(dailytime.value) + int(monthtime.value)
indigo.variable.updateValue(520397369, value=unicode(total))

#Add daily total to yearly total
yeartime = indigo.variables[819142009]
total = int(dailytime.value) + int(yeartime.value)
indigo.variable.updateValue(819142009, value=unicode(total))

#Add daily total to overall total
overalltime = indigo.variables[41669363]
total = int(dailytime.value) + int(overalltime.value)
indigo.variable.updateValue(41669363, value=unicode(total))


This is my first attempt at programming in Python but the script is working okay when it's run individually. Is there something simple that I'm missing? Going a little crazy trying to figure this out. Any help would be greatly appreciated.
Attachments
pix.jpg
pix.jpg (43.09 KiB) Viewed 1797 times

Posted on
Sat Feb 18, 2017 4:11 pm
FlyingDiver offline
User avatar
Posts: 7184
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Embedded scripts in a schedule not running.

Put a delay on the action that resets the daily time variable. Indigo will attempt to run multiple actions in parallel, so it's probably getting zeroed out before the script actually runs.

Even better, reset it to zero as the last step in the script.

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

Posted on
Sat Feb 18, 2017 4:47 pm
aldera offline
User avatar
Posts: 188
Joined: Aug 30, 2016
Location: Michigan, USA

Re: Embedded scripts in a schedule not running.

FlyingDiver wrote:
Put a delay on the action that resets the daily time variable. Indigo will attempt to run multiple actions in parallel, so it's probably getting zeroed out before the script actually runs.

Even better, reset it to zero as the last step in the script.


That was it. I assumed that the actions were run sequentially. Lesson learned. Thanks!!!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests