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.

Toggle a variable value

Featured Replies

Posted

I've got a program that sets a variable to 1 during two separate time spans. A couple other programs use this variable to determine what to do. If Variable = 1 than do something, if not, then do something else.

This all works just fine.

 

What I want to do is toggle the variable to 1 or 0 by either pressing a button on my inseton mini remote or by running a program from my MobiLinc app.

 

This seems like it should be dirt simple, but I am stumped. Programs run as event loops, right? So, I can't just run once and done.

 

Two problems with my scenario.

1: the time span part will override my variable value, setting it back to 1 no matter what I do during that time span.

2: if $var == 1

$var = 0

else

$var = 1

is an infinite loop.

 

Can someone straighten me out? Is it possible to toggle a variable value with a button click or a tap on my MobiLinc app?

Thanks in advance

If you disable that program and call it from another program (Run If Path) then you will get the result that you want. Disabling a program prevents it from self triggering but it does not prevent it being run from another program.

 

Hope this helps.

 

-Xathros

  • Author

Wow, thanks for the quick reply.

 

Your solution solves a big part of the problem.

 

Now I want a way to determine if that variable is set to 1 or 0 on my MobiLinc dashboard.

 

I'm trying to set up a security system. The variable == 1 when the system is "armed". I get text messages from my doors, windows, and motion detector if the system is "armed." That all works now.

 

I just needed a method to toggle the value of the variable (solved by you THANK YOU) and a way to easily see whether it's set.

 

I know I can drill down in the MobiLinc app and find the variable value. My wife won't want to do that.

 

I truly appreciate the help!

Why not var=1-var as a toggle?

 

Then you could bind the if conditional to a scene button being pressed.

Wow, thanks for the quick reply.

 

Your solution solves a big part of the problem.

 

Now I want a way to determine if that variable is set to 1 or 0 on my MobiLinc dashboard.

 

I'm trying to set up a security system. The variable == 1 when the system is "armed". I get text messages from my doors, windows, and motion detector if the system is "armed." That all works now.

 

I just needed a method to toggle the value of the variable (solved by you THANK YOU) and a way to easily see whether it's set.

 

I know I can drill down in the MobiLinc app and find the variable value. My wife won't want to do that.

 

I truly appreciate the help!

No Problem. As always, happy to help.

 

Make the toggle program a ML favorite. Edit the custom status labels to say 1 for true and 0 for false (or vice versa depending on how your toggle is coded) Make the Favorite action a RunIf that way you can actually toggle by pressing the favorite as well. You could also name the true/false labels based on what the variable does for you. I do this with a number of toggles in my system: Pellet Stove Enable/Disabe, Netfilter Enable/Disable, Home/Away etc.

 

-Xathros

  • 1 month later...
I know I can drill down in the MobiLinc app and find the variable value. My wife won't want to do that.

I have the X10 module and have defined a phoney unit called "Vacation Mode" which I turn On and Off from inside the ISY.

 

Mobilinc can see it as a device in My Favourites.

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.