Jump to content

Best Practices


PB11

Recommended Posts

Hello All.

Through the generous input of many people on this forum, I'm starting to understand that there are definitely best approaches to things such as scene changes, programs....

In trying to reduce the writes, and program requirements on my nodes and isy and so I'm wondering if the following is the right approach.

So, originally I had the "From-to"  if condition at the top followed by the device status condition. This got me thinking that I have the isy scanning for changes of the "then" devices that entire window of time.

The thing is I have 2 programs for each variable assessing the same conditions during different times of the day. If I'm assessing status of a device first, would the isy be more heavily loaded now having to assess which program falls within the time window?

Is it more efficient to trigger the "If" condition assessment by the status change of a device followed by the "From-to" condition. My thought is that the isy is only engaged at the moment in time that status of $sAPHome variable changes rather then the 8 hour period between sunrise/sunset.

Hope that's somewhat clear.

Appreciate any input as I have several programs arranged in this manner, and I suspect I'm placing unneeded load on my isy.

 

Arriving Home at Day Light AP Copy Copy - [ID 0067][Parent 002B]

If
        $sAPHome is 1
    And $sNeighborhood is 1
    And From    Sunrise - 59 minutes
        To      Sunset  + 59 minutes (same day)
 
Then
        Set 'Garage / Garage 2 / Garage 2' Open
        Wait  3 minutes 
        Set 'Garage / Garage 2 / Garage 2' Close
        Send Notification to 'Lake House' content 'AP Day Geofence Ran'
 
Else
   - No Actions - (To add one, press 'Action')
 

Thanks

Link to comment
Share on other sites

I think what you are asking is if the statement order in the IF body is important.  If that's the question the answer is no.  the entire if body is changed in to True Vs False the result of that determines what happens, they are not executed in order like a Then or Else body.

    $sAPHome is 1
    And $sNeighborhood is 1
    And From    Sunrise - 59 minutes
        To      Sunset  + 59 minutes (same day)

Might result in

       True

And False

And True

which in total is False.  Since there is nothing in the Else body nothing unnecessary occurs.

 

If however your program looked like this:

If
        $sAPHome is 1
    And $sNeighborhood is 1
    And From    Sunrise - 59 minutes
        To      Sunset  + 59 minutes (same day)
 
Then
        Set 'Garage / Garage 2 / Garage 2' Open
        Wait  3 minutes 
        Set 'Garage / Garage 2 / Garage 2' Close
        Send Notification to 'Lake House' content 'AP Day Geofence Ran'
 
Else
        Turn Light off  (or anything really)

then what happens is anytime the IF body is evaluated False it turns the light off (even if it's already off), so the Else body would run at sunset, and anytime either variable changed states.

 

 

 

 

 

 

Link to comment
Share on other sites

I don’t believe that the order of the conditions matter regarding workload of the ISY or to the read/write cycles.  If an individual condition is a trigger for a program, it will be a trigger (and be evaluated) whether it is the first condition, last condition, or any condition between.

Link to comment
Share on other sites

Thanks

Just for clarification.

 

34 minutes ago, MrBill said:

the entire if body is changed in to True Vs False the result of that determines what happens

Is the isy continuously assessing all "If" conditions of all my programs? I was thinking the change of state of a variable would trigger the assessment of any following conditions in the "If" statement. Guess I assumed it did it in order of listing.

Link to comment
Share on other sites

40 minutes ago, MrBill said:

I think what you are asking is if the statement order in the IF body is important.  If that's the question the answer is no

This was the simple question I was trying to ask in the 14 paragraphs above. :)

Link to comment
Share on other sites

1 minute ago, PB11 said:

Is the isy continuously assessing all "If" conditions of all my programs? I was thinking the change of state of a variable would trigger the assessment of any following conditions in the "If" statement. Guess I assumed it did it in order of listing.

My understanding is that when the value of state variable changes that causes the If body of any programs it's used in to be re-evaluated.  So no it's not constanlt evaluating all programs but when any of your 3 values (2 variables + a time window) change state, that causes the If to be evaluated in total.

And it's really neither evaluated "all at once" or in top to bottom order but follows normal logic precedence:  https://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order However the entire if body is evaluated to make a decision.

Link to comment
Share on other sites

1 hour ago, MrBill said:

Great read. Need to get my head around some of it, but it did touch on something I have tripped on in the past

"Folders may be created with or without conditions" I currently use the folders strictly for organization. 

Any examples when this may be helpful?

Seems like it would create a level of complexity and would be difficult to track as it wouldn't be my first thought to consider when trouble shooting issues.

Link to comment
Share on other sites

1 hour ago, PB11 said:

Great read. Need to get my head around some of it, but it did touch on something I have tripped on in the past

"Folders may be created with or without conditions" I currently use the folders strictly for organization. 

Any examples when this may be helpful?

Seems like it would create a level of complexity and would be difficult to track as it wouldn't be my first thought to consider when trouble shooting issues.

Setting a folder condition means the program inside are completely ignored if the folder is false.

I use this to change how the main kitchen light switch works based on time.  I'd post the whole programs but there's a lot going on that adds confusion.  So instead I'll simplify:

There is a state variable called $sDark.kitchen.    It changes to 1 at both Sunset and "dinner time" (different programs) meaning that whichever occurs first will effect the change.  In the winter Sunset will usually occur first, in the summer "Dinner Time" will normally occur first.   "bed time" actually turns the kitchen accent lights all the way off and sets $sDark.kitchen back to zero (so technically the overnight hours are treated as daytime.)

Then there are the Folders:

image.png.eda3fdbfa10e64e72e123c6829c48715.png

the "isDark" folder has a folder condition  "if $sDark.kitchen = 1"  and conversely the "notDark" folder has a folder condition "if $sDark.kitchen = 0".  With the folder conditions in place I can have different ON and OFF programs based on those time periods.   Basically the difference is Daytime omits turning on Over-cabinet accent lights, While the night programs turn on over-cabinet accent, and the nighttime off program turns off overhead and dims the table light, over cabinet and under cabinet.

The kitchen dinner Dim Button program is button G of a KPL programed non-toggle.  When it gets pressed (or you tell "Alexa it's dinner time") the lights transition to a setting for that (and set the $sDark.kitchen flag).   All this was not done with scenes originally because it's part Hue and was set up long before noderservers existed, therefor it had to be programs because Network Resources controlled the Hue.

(The other dinner dim program is actually a shortcut for me, the full title that got cutoff in the screenshot is Kitchen Dinner Dim Button.fastoff  its basically a program that does nothing but set $sDark.kitchen = 0 on a double tap of the same button, which makes it handy for testing or if someone (grandchild) pressed "dinner dim" during the day and i want to change the flag back without having to open the admin console.)

Another use case: I've since transitioned to doing it another way but I used to have a folder called "Vacation lights" that had a folder condition "if $sVacation = 1"

Another use case is to use it to prevent Insteon programs from running until after startup is complete if you have a big Insteon system and the system query at startup takes a long time (a method to deal with "queue full" errors during startup).   For this use case create a state variable $sStartup and set it's "init value" to 1.  Then create a simple program

Startup   (with Run at Startup enabled)

if

   $sStartup = 1

then

wait 9 minutes

$sStartup = 0

else

(nothing)

then create a folder with the folder condition "If $sStartup = 0"   and inside that folder add insteon programs that you don't want to run during the query at startup.

Link to comment
Share on other sites

Archived

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


  • Recently Browsing

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

  • Forum Statistics

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