Jump to content

Variable Variables


aLf

Recommended Posts

Posted

Maybe a thread here for you "high end" programers to post just how you have used "Variables". Us not so savvy users are a bit stumped by the option. Thanks guys. I'm sure I'll get some great ideas.

 

aLf

Posted

up and until now, I have created programs as Flags to act as variables. I would check to see if a flag program was true or not and have decisions made based on those values.

variables will allow us to have more control over just true and false. you can add values and look for various values in the variables to make program decisions.

 

BTW there is a topic now on the forum for variables with some good info:

http://forum.universal-devices.com/viewforum.php?f=68

 

For me, and many others we are really happy to have variables now.

IE: you now create counters for events and make decisions based on the count value, Do one thing based on a count of 1 or another thing based on a count of 5 or 6 or 10.

 

I for one, count the detection of my motion detector to make decisions and then send me an alert based on the high count.

 

Once you get the lowdown on variables you will like using them.

 

Clarence

Posted

Once you can read property values into variables and compare them to property values, you will start seeing some cool programs, I imagine. IMO, variables as they are in this first incarnation aren't good for much more than counters. We've been assured that more is coming, however.

Posted

I just bought my first ISY yesterday. Was shocked to find out variables were just invented. Here is one of my uses. Notifying me about a device left on and then turning it off if left on too far.

 

If
       Status  'Espresso Machine' is On
   And $EspressoReminder < 3

Then
       $EspressoReminder += 1
       Wait  20 minutes 
       Send Notification to 'Dan Mobile' content 'Espresso Still On'
       Run Program 'Espresso On' (If)

Else
       $EspressoReminder  = 0
       Set 'Espresso Machine' Off
       Send Notification to 'Dan Mobile' content 'Espresso Turned Off'
       Stop program 'Espresso On'

  • 2 weeks later...
Posted

As a follow up to this. Why doesn't this code work correctly?

 

It runs 3 times, but then does not run Else when $EspressoReminder is not <3. If I manually right click and choose Run If, it works.

 

If
       $EspressoReminder < 3
   And Status  'Living Room / . / Espresso Machine' is On

Then
       Repeat 3 times
          $EspressoReminder += 1
          Wait  20 seconds
          Send Notification to 'Dan Mobile' content 'Espresso Still On'

Else
       $EspressoReminder  = 0
       Set Scene 'Living Room / Espresso Machine' Off
       Send Notification to 'Dan Mobile' content 'Espresso Turned Off'

Posted

I think if you declare your variable to be a state variable the program will run everytime the value changes. But if I read your program right your program will run one extra time after you set the variable to zero and turn off the coffee machine because the variable was changed to zero. You may get an extra notification.

 

This is complicated stuff.

Posted
I think if you declare your variable to be a state variable the program will run everytime the value changes. But if I read your program right your program will run one extra time after you set the variable to zero and turn off the coffee machine because the variable was changed to zero. You may get an extra notification.

 

This is complicated stuff.

 

That's exactly the bug I'm trying to solve now!

 

I get duplicate messages saying the machine was turned off. What causes it to fire twice?

Posted

Well, let's see. If the machine is on you increase $ExpressoReminder (causes program to run again) and send yourself an EMail. all this 3 times. How many notifications are you getting?

 

Finally you hit the Else statement which changes $ExpressReminder to 0 (causes program to run) but the coffee machine is already off so it will execute the Else again which will send you a second reminder.

 

Thinking out loud ..

 

If

$EspressoReminder > 0

And Status 'Living Room / . / Espresso Machine' is On

 

Then

Repeat 3 times

$EspressoReminder -= 1

Wait 20 seconds

Send Notification to 'Dan Mobile' content 'Espresso Still On'

 

Else

Set Scene 'Living Room / Espresso Machine' Off

Send Notification to 'Dan Mobile' content 'Espresso Turned Off'

 

Not sure how you init $ExpressoReminder but init it to 3. This way the variable doesn't change in the Else statement.

 

Also, I don't know how the ISY processes a state variable changing within a program that tests it. Does it wait for the current program to finish or spawn off another instance of the program? If your program was almost working before, this might prevent the extra notification.

Posted

I see what you mean.

 

But I'd have to set the variable back to 3 when I turn it on.

 

I'm even trying resetting the variable in a different program after a wait but I'm still having the Else portion run twice.

 

Looks like a bug.

Posted

You can always have another program that sets $ExpressoReminder back to 3 when the coffee pot is turned on.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...