MarkJames Posted July 21 Posted July 21 (edited) I would like to do a compare of a variable's current value to its init value and if they're different then set the init value to the current value. Specifically this is for my sprinkler zone durations so that if I change the duration and then reboot then it will restart with the last changed value. Put simply if statevar_x <> (init value of statevar_x) then (init value of statevar_x) = statevar_x Is there a way to do an evaluation based on init values? Edited July 21 by MarkJames Quote
hart2hart Posted July 21 Posted July 21 As I recall, You’ll need to create another variable and keep its value and init to value in sync your variables init to value. Quote
MarkJames Posted July 22 Author Posted July 22 There doesn't seem to be a way to assign a variable to the init value either so I'm not sure I can do that. Quote
Jimbo.Automates Posted July 22 Posted July 22 Whenever statevar changes set it's initIf statevar <= 0 or statevar > 0 Set statevar init = statevar Sent from my SM-X808U using Tapatalk Quote
MarkJames Posted July 22 Author Posted July 22 (edited) That would only work if I know what statevar is... In your case statevar is 0. But if you don't know what its value is then that becomes harder. What I'm trying to do is like this... I have 14 zones in my sprinkler system. The duration each zone runs is variable s_zone1Duration, s_zone2Duration etc. At the beginning of the season I have a program that sets all the values and all the init values to defaults As time goes by and it gets hotter/cooler/wetter etc. I may need to adjust the durations. I want to make sure that if the ISY reboots the those adjusted durations will repopulate. So.... the <obvious> way is to increase or decrease the durations using a program that simultaneously increase/decreases and saves the new value to the respective init value. It's clunky, though, because I need 28 programs to accomplish this. It's far simpler, of course, to just use UD mobile to increase or decrease the value of the variable directly. What I had hoped to do is have a program that could check if the s_zone1Duration - s_zone1Duration (init) <> 0 then write the current value to the init value I thought this would be easy but so far it's not.... Another way to accomplish it would be to set a second set of state variables corresponding to the zone durations and make my if statement on matching_set_value - real_set_value <> 0. That would work too - I just hoped there would be a more direct way Edited July 22 by MarkJames Quote
Solution Jimbo.Automates Posted July 22 Solution Posted July 22 (edited) Need a program for each if s_zone1Duration <= 0 or s_zone1Duration > 0 then s_zone1Duration (init) = s_zone1Duration This will run anytime the variable changes and updates it's init value. Edited July 22 by Jimbo.Automates Quote
MarkJames Posted July 22 Author Posted July 22 I get it - the state variable value doesn't matter - it will trip the IF anytime it changes. I suppose I could just have one program with 14 bracketed OR's that writes ALL of the current values to their init values. Thanks 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.