Jump to content

How do you handle multiple actions in a program?


416to305

Recommended Posts

Posted

More general question, but I get confused when I have multiple things that I want in a program.  For example, with Vera, I'd have my front door open, it would save the state of the light, set it to 100% brightness, and 5 minutes later change it back to the state it was in.  I know ISY doesn't do status variables, but I thought I could break it down a little with normal variables.

 

So for example:

If light is off, variable = 0

If light is between 1-25%, variable = 1

If light is between 26-50%, variable = 2

If light is between 51-75%, variable = 3

If light is between 76-99%, variable = 4

If light is on, variable = 5

 

Just a rough example.  Question is, do I need to make 6 different programs for that?  One for If light is > 0 and < 26, set variable 1, then another program for the other levels?  Or I thought it might work to cut it in half, such as:

 

If light is off, and light is NOT between 1-25, set varialble to 0, else set it to 1.  Then second program If light is between 26-50, and is NOT between 51-75, set variable to 2, else set it to 3, etc?  Not sure if that would work?

 

I know the first one would, but then when I get mixed up is writing a program.  I was thinking I'd make it basically "If front door opens", step 1 is to disable the programs that monitor the status and set the variable, basically saving the status of the light in a general variable since it won't update again.  Then turn the light on to 100%, wait 5 minutes, and then the last step is set the light back to where it was in a general value, such as "If variable = 3" I'd have it set the light to maybe 66% or something, so even if it was say at 74% when the door opened, it will put it back roughly where it was or close enough no one would notice.

 

Hope that makes sense.  So program is:

 

Wait 5 minutes

But my issue is right here.  How do I then say "If variable is 0, set light to this.  But if variable is 1, set it to this, if it's 2 set it to this, if it's 3 set to this etc."  Like not sure what that's called in programming, but basically I want THEN to run, but then evaluate more conditions.  I always get caught right here even with other programs, when I want further conditions to be evaluated etc.

 

Thanks so much hope that was clear a bit :)

 

Posted (edited)

Need multiple Programs. Cannot have one Program do 6 different things.

 

Program 1

If 'light' is Off

Then set variable to 0

 

Program 2

If 'light' is => 1%

And 'light' is <= 25%

Then set variable to 1

 

Program 3

If 'light' is => 26%

And 'light' is <= 50%

Then set variable to 2

 

and so on.

Edited by LeeG
Posted

Thanks, that's fine, what about though the second part of my question in terms of putting it back the way it was?  Like turn the light on, wait 5 minutes, and then evaluate multiple conditions?  Like if variable is at 0, turn the light off, if it's at 1, set it to 25%, if it's at 2 set it to 50%, etc?  That's where I get lost all the time, when I need an action to happen but based on different criteria.  Or would I use multiple "Light off" programs, such as:

 

If s.FrontDoorTripped = 1

and s.LightLevel = 0

Then wait 5 minutes, set light to 0, set s.FrontDoorTripped = 0

 

If s.FrontDoorTripped = 1

and s.LightLevel = 1

Then wait 5 minutes, set light to 25%, set s.FrontDoorTripped = 0

 

If s.FrontDoorTripped = 1

and s.LightLevel = 3

Then wait 5 minutes, set light to 50%, set s.FrontDoorTripped = 0

 

Etc?  I always feel like having lots of programs is bad for some reason, but would that be the proper way to do it?  The s.FrontDoorTripped variable is set to 1 when the door is open.  So basically a different countdown timer program for each?  Thanks!

Posted

Need multiple Programs to bring it back. The 5.0.x images may have enough variable changes to reduce the number of Programs needed but that will not happen until some time in 2015.

Posted

Great thanks!  Just wanted to make sure I wasn't being insanely inefficient or something by having multiple programs and then find out there's a proper way to do it.  Thanks for the help!

Posted

Why not just use programs as variables?

 

If light is at 10%

 

No then or else.

 

Then refer to the programs state (true or false) as the variable in another program.

Guest
This topic is now closed to further replies.

×
×
  • Create New...