Jump to content

Compare to init


Go to solution Solved by Jimbo.Automates,

Recommended Posts

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 by MarkJames
Link to comment
Posted (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 by MarkJames
Link to comment

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

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...