Irrigation Trigger + Variable

Posted on
Sat Jul 06, 2013 2:43 pm
CraigM offline
Posts: 589
Joined: Oct 28, 2007

Irrigation Trigger + Variable

Is there a way to simplify setting a variable whenever ANY ZONE becomes ON, and then becomes OFF.

Right now I'm using the following for each zone

Type: Device State Changed
Device: EZFLORA 1
Zone 1
Becomes On

Type: Device State Changed
Device: EZFLORA 1
Zone 1
Becomes Off


It does exactly what I need, but with 2 EZFLORA's x 16 zones x 2 triggers each, that's a lot of triggers just to let the system know if any irrigation is currently running.

Posted on
Sat Jul 06, 2013 3:45 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Irrigation Trigger + Variable

You can trigger using a Device State Changed for the sprinkler, Active Zone Name Has Any Change. That will fire whenever a zone changes or when it's finished with a schedule.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jul 06, 2013 4:18 pm
CraigM offline
Posts: 589
Joined: Oct 28, 2007

Re: Irrigation Trigger + Variable

jay (support) wrote:
You can trigger using a Device State Changed for the sprinkler, Active Zone Name Has Any Change. That will fire whenever a zone changes or when it's finished with a schedule.


I looked at that option before, but couldn't wrap my head around it working.

I need 2 variables modified, so ideally I'm looking for just 2 triggers [if it's possible instead of 32]:

When ANY zone starts - MODIFY VARIABLE/Set to: "Irrigation Zone Running"
When ANY zone ends - MODIFY VARIABLE/Set to: " "

If I use HAS ANY CHANGE, how is it getting the correct variable set, or know if the change is an ON or OFF?

Posted on
Sun Jul 07, 2013 8:44 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Irrigation Trigger + Variable

I think we need a little more context and description about what you're trying to do to be able to help with the solution. Can you fully describe what it is these two variables are and what you're going to use them for?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jul 07, 2013 2:20 pm
CraigM offline
Posts: 589
Joined: Oct 28, 2007

Re: Irrigation Trigger + Variable

jay (support) wrote:
I think we need a little more context and description about what you're trying to do to be able to help with the solution. Can you fully describe what it is these two variables are and what you're going to use them for?


I need the statement "Irrigation Zone Running" to display in iTouch CP [iPad] when any zone is running, and " " [blank] when no zones are running.

I will also use conditions to only allow any zone to run if the variable is " "

Like I said, the way I have it now works perfect, It just uses a LOT of triggers. This is just a way to expand my knowledge base of Indigo, and streamline my HA app if another way is possible.

Posted on
Sun Jul 07, 2013 2:59 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Irrigation Trigger + Variable

Use the trigger specified above, and use the following script as the action (untested but should be close):

Code: Select all
# Get the sprinkler instance
sprinkler = indigo.devices[SPRINKLERID]
if sprinkler.states["activeZone"] > 0:
    #if the active zone is greater than 0 then it's running
    indigo.variable.updateValue(VARID, value="Irrigation Zone Running")
else:
    # if the active zone is 0 then it's not running
    indigo.variable.updateValue(VARID, value="")


However, you might want to consider just putting the active zone name on your control page which will show the zone name or "all zones off" if the sprinkler is not active (or, alternatively, add an icon for each zone so you can visually represent each zone's state). You can also use it in your conditions (active zone name is not equal to "all zones off") then you don't need variables for anything. This is why I was asking for details - sometimes there are alternatives that are worth considering even though you've decided on a different course of action.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jul 12, 2013 4:32 pm
CraigM offline
Posts: 589
Joined: Oct 28, 2007

Re: Irrigation Trigger + Variable

jay (support) wrote:
Use the trigger specified above, and use the following script as the action (untested but should be close):

Code: Select all
# Get the sprinkler instance
sprinkler = indigo.devices[SPRINKLERID]
if sprinkler.states["activeZone"] > 0:
    #if the active zone is greater than 0 then it's running
    indigo.variable.updateValue(VARID, value="Irrigation Zone Running")
else:
    # if the active zone is 0 then it's not running
    indigo.variable.updateValue(VARID, value="")


Tested and seems to function perfectly. :D Thanks for the assist.

Posted on
Sat Aug 17, 2013 2:58 pm
CraigM offline
Posts: 589
Joined: Oct 28, 2007

Re: Irrigation Trigger + Variable

CraigM wrote:
jay (support) wrote:
Use the trigger specified above, and use the following script as the action (untested but should be close):

Code: Select all
# Get the sprinkler instance
sprinkler = indigo.devices[SPRINKLERID]
if sprinkler.states["activeZone"] > 0:
    #if the active zone is greater than 0 then it's running
    indigo.variable.updateValue(VARID, value="Irrigation Zone Running")
else:
    # if the active zone is 0 then it's not running
    indigo.variable.updateValue(VARID, value="")


Tested and seems to function perfectly. :D Thanks for the assist.

Just upgraded to v6 :D and going through my beta notes of items that might need to be changed/edited. This script was one of those items.
I made a note that the attribute "activeZone" was no more and should be changed to "activeZoneIndex', I was expecting this script not to function or throw an error, but it still seems to work fine.

Please advise

Posted on
Sat Aug 17, 2013 3:43 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Irrigation Trigger + Variable

Your script is fine. The activeZone sprinkler device instance attribute name is what changed. So if you had used sprinkler.activeZone in your script that would need to be changed to sprinkler.activeZoneIndex, but the state name (states["activeZone"]) and usage hasn't changed. We just changed the name of the attribute because it has a subtle difference compared to the state value.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 22 guests