Jump to content

If statement comparing two state variables


pjjameso

Recommended Posts

Would like to have an if statement as such;

    IF    $sAQI >= 50

  And $sDEQ < $sAQI

Then

....

Is this possible? Testing indoor Air Quality whereby if indoor is greater than 50 and the outdoor Air Quality is less than the indoor, then turn on ventilator, else do nothing. Currently posting values from IFTTT/Portal

Link to comment
31 minutes ago, pjjameso said:

IF    $sAQI >= 50

  And $sDEQ < $sAQI

You can write the If statement just as you have and anytime any of the variables change it will evaluate all conditions and possible run the THEN block, Warning tho, this is a the exact type of program where users get surprised by how often Else Run.   You indicated "else do nothing" which is great, but keep in mind that anytime any  of the values change or are updated either Then or Else is going to chosen to run, else.. nothing is perfect in this case.

If those values update often you might want to add:

IF    $sAQI >= 50

  And $sDEQ < $sAQI

  And Ventilator status is Off

then

   Turn on ventilator....

Depending on what platform controls the ventilator this may cut down on extra traffic... i.e. the ISY telling the ventilator to turn on frequently when the ventilator is in fact already on.

Note: if the outside air quality is irrelevant for triggering the routine... that is it's only a filter that might prevent the on trigger, then you might make DEQ an interger variable instead:

IF    $sAQI >= 50

  And $iDEQ < $sAQI

  And Ventilator status is Off

then

   Turn on ventilator....

by doing that the IF is only getting evaluated when sAQI changes, however the current outdoor can value DEQ is still used to determine whether to fire the routine.

 

 

Link to comment
But I assume that you can have 2 similar programs, one for each switch ?
Yes, definitely but only one program will trigger Then at any given time.

With multitasking processing these days they may appear simultaneous to a human, though.

In any one program, only one trigger will ever cause evaluation of the If section logic at any time. While one control/switched statement causes evaluation, any other control / switched statement will be False.

Thus Status condition statements are born. Status can act like a combination of event trigger and static condition from the same condition line....provided the program is NOT disabled.

Sent from my SM-G781W using Tapatalk


Link to comment

Archived

This topic is now archived and is closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...