hagak Posted April 29, 2012 Posted April 29, 2012 So I notice isy has varaibles for use with Programs however the Wiki does not seem to mention them and in fact mentions using Programs to accomplish the same task which seems bulky to me. I assume this is because variables are a newer feature than the Wiki entries. Question I have is I was playing around with variables to create a Countdown type feature. ie press a button it decrements a variable with each press. This appeared to work fine. However the problem I had was I had 2 other programs whose if statement ran if the variable == 0 for one and the other was variable > 0. Issue was those programs never ran. I would think those programs if statement would get evaluated anytime the variables value changed. Any ideas why that would not work? Count == 0 If $TestCountDown is 0 Then Set 'Office / Office-Chair-Lamp' Off Else - No Actions - (To add one, press 'Action') CountDown >0 If $TestCountDown > 0 Then Wait 10 seconds $TestCountDown -= 1 Else - No Actions - (To add one, press 'Action') Set countdown If Status 'Office / Office-Motion-Sensor' is On Then $TestCountDown = 4 Else - No Actions - (To add one, press 'Action') I used a motion sensor to reset the count down. This program runs as expected, however the 2 that trigger on the $TestCountDown value do not run. If I manually run (if) on each they run as expected.
LeeG Posted April 29, 2012 Posted April 29, 2012 There is a forum Category dedicated to Variables. The first few topics cover Variables in detail. If a Program is not being triggered with a Variable the variable is an Integer rather than a State variable. Both types are identical except State variables trigger Programs, Integer variables do not. This is all covered in the initial topics under the Variables forum category.
apostolakisl Posted April 29, 2012 Posted April 29, 2012 What Lee said plus a suggeston: When you name your variables, start all integer variables with an "i" and all state with an "s". This makes it easy while writing and trouble shooting your programs to know what you are dealing with. i.e. "iCountdown" "sCoundown"
Recommended Posts