Sprinkler Object and API

Posted on
Mon May 13, 2013 7:22 am
dhughes offline
Posts: 33
Joined: Mar 13, 2009

Sprinkler Object and API

I am writing a Python sprinkler script for precise control of my sprinkler zones using some Koubachi moisture sensing.

I have two controllers as I have more than 8 zones.

What I would like to do is:
1. Calculate how much watering time I want for each of my 16 zones.
2. Invoke sprinkler scheduler on my first controller, using the API - "indigo.sprinkler.run(123, schedule=[10,15,8, 0, 0, 0, 0, 0])"
3. Invoke a sprinkler schedule on my second controller, but delay launch until the first has completed.

I see how to delay actions in an Action group in the UI, but am not clear how to do so in a script.

Any ideas?

Posted on
Mon May 13, 2013 9:42 am
jay (support) offline
Site Admin
User avatar
Posts: 18238
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sprinkler Object and API

The first thing you should know is that doing the indigo.sprinkler.run command will return immediately - not after the schedule finishes, so you're going to need to calculate that yourself.

To pause a Python script:

Code: Select all
import time
# do some stuff
time.sleep(N) # where N=number of seconds to sleep
# do some more stuff


You'll need to run the script as an external script file rather than an embedded script (we kill scripts that run longer than 10 seconds when running embedded).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon May 13, 2013 8:35 pm
dhughes offline
Posts: 33
Joined: Mar 13, 2009

Re: Sprinkler Object and API

Thanks for the quick response!

I planned on calculating the delay, but assumed I couldn't embed a multi-hour wait into the main line of the script, or at least assumed it was a bad idea.

Is there anyway to create the sprinkler run from the script as an activity that is scheduled to run at the right time in the future?

Or am I worried for no reason?

Posted on
Tue May 14, 2013 8:41 am
jay (support) offline
Site Admin
User avatar
Posts: 18238
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sprinkler Object and API

dhughes wrote:
Is there anyway to create the sprinkler run from the script as an activity that is scheduled to run at the right time in the future?

Or am I worried for no reason?


Sorry, I'm not following you...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 14, 2013 6:17 pm
dhughes offline
Posts: 33
Joined: Mar 13, 2009

Re: Sprinkler Object and API

Sorry - phone typing!

1. Is the hour+ sleep in the middle of the script a perfectly appropriate way to do this? It just seemed like a long time to have the script hanging out there. If it is fine, then I won't worry.

2. Is there any alternative method I can cook up in the script using the scheduler. eg. Perhaps create a disabled schedule item running an activity referencing an external script. Then in my script modify the contents of the external script, set the right scheduled time, and enable it. I thought I saw that some of the built in functionality created scheduled items on the fly.

Posted on
Wed May 15, 2013 8:44 am
jay (support) offline
Site Admin
User avatar
Posts: 18238
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sprinkler Object and API

dhughes wrote:
1. Is the hour+ sleep in the middle of the script a perfectly appropriate way to do this? It just seemed like a long time to have the script hanging out there. If it is fine, then I won't worry.


Running as a script file will be fine - we start a separate process for those so they wouldn't be holding anything else up.

dhughes wrote:
2. Is there any alternative method I can cook up in the script using the scheduler. eg. Perhaps create a disabled schedule item running an activity referencing an external script. Then in my script modify the contents of the external script, set the right scheduled time, and enable it. I thought I saw that some of the built in functionality created scheduled items on the fly.


Sorry - I'm apparently having a huge block when it comes to what you're trying to do. Maybe if you explain what exactly you're trying to accomplish (without any mention of how to do it) then I'll be able to follow you...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed May 15, 2013 10:56 am
dhughes offline
Posts: 33
Joined: Mar 13, 2009

Re: Sprinkler Object and API

Since 1 is fine, then I am all set.

I was trying to figure out a workaround to schedule my second sprinkler controller to run at a future time.

I didn't know if it was possible from within my python script to create an indigo date/time action that executes a sprinkler schedule.

Posted on
Wed May 15, 2013 11:27 am
jay (support) offline
Site Admin
User avatar
Posts: 18238
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sprinkler Object and API

AH HA!

The schedule parts of the IOM aren't completed yet (due to low demand thus far) so you can't create/modify schedules.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed May 15, 2013 11:36 am
berkinet offline
User avatar
Posts: 3297
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Sprinkler Object and API

jay (support) wrote:
AH HA!

The schedule parts of the IOM aren't completed yet (due to low demand thus far) so you can't create/modify schedules.

But, you can sort of roll your own... Take a look at the Multiple Sprinkler plugibpn (viewtopic.php?f=22&t=7739 ) for some ideas.

Posted on
Wed May 15, 2013 2:54 pm
dhughes offline
Posts: 33
Joined: Mar 13, 2009

Re: Sprinkler Object and API

Thanks Jay!

Sorry for the muddled questions.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests