Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Compare to init

Featured Replies

Posted

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

Solved by Jimbo.Automates

Go to solution

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.

  • Author

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.

 

 

Whenever statevar changes set it's init
If statevar <= 0 or statevar > 0
Set statevar init = statevar

Sent from my SM-X808U using Tapatalk





  • Author

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

  • Solution

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 by Jimbo.Automates

  • Author

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

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.