My sprinkler control page is attached.
What I want to do:
1) The larger sprinkler button in the top left represents the on state of the sprinklers. Orange for on, blue for off.
- Tapping in the off state begins the sprinkler schedule.
- Tapping in the on state stops all sprinklers.
2) I can run individual sprinklers by tapping their corresponding icon. Their colour changes. A second tap switches that sprinkler off again.
3) Provide a control page to adjust individual sprinkler durations.
It's more complex than I thought...
Here's what I have written out so far.
For the individual sprinklers:
1) I have an action group for each sprinkler. They each run a different python script that runs that sprinkler for a time that is stored in a series of variables.
Code: Select all
indigo.sprinkler.run(1875748152, schedule=[indigo.variable(138167704),0,0, 0, 0, 0, 0, 0])2) On the control page I have two image files named avon_sprinkler.png and avon_sprinkler+On.png. These are set to reflect device state of that particular zone. This works fine.
3) Tapping a sprinkler icon executes a python script:
Code: Select all
# If that sprinkler isn't running, activate the corresponding action group that will run it. If it is running, stop it.
if indigo.devices[1875748152].activeZone!=4:
indigo.actionGroup.execute(624487976)
else:
indigo.sprinkler.stop(1875748152)
Now for the master sprinkler control:
1) I have a trigger set-up that runs the following python script should an Active Zone Name have any change in any sprinkler:
Code: Select all
#If all sprinklers are off, update the variable "sprinklers_On" to false, else set to true.
if indigo.devices[1875748152].activeZone==-1:
indigo.variable.updateValue(736137373, "false")
else:
indigo.variable.updateValue(736137373, "true")2) On the control page I have two image files named avon_sprinkler_large.png and avon_sprinkler_large+true.png. These are set to reflect the variable value of sprinklers_On. This works fine.
3) Tapping this button executes a script:
Code: Select all
#If all sprinklers are off, then commence the schedule, else switch everything off.
if indigo.variable[736137373]=="false":
indigo.sprinkler.run(1875748152, schedule=[indigo.variable(138167704),indigo.variable(xxxxx),etc.])
else:
indigo.sprinkler.stop(1875748152)Phew. Any hints to get my python in order? And is there an easier way to do this?
Thanks!