Jump to content

Newbie to ISY994 programmimg. Sunrise-Sunset?


rlanza1054

Recommended Posts

Hi all,

 

I did try looking to this but can't find the answer I'm looking for.

 

I did study pogramming basics way back in the day, but programming wasn't for me.

 

So I do have a basic undestand of programming concepts.

 

The concept of logic in using 'IF', 'THEN' and 'ELSE'.

 

I don't seem to be able to make what I want to do inside the Programming area of the ISY. It could be either that I just know how to enter it or my program is not logical.

 

Here is what is inside my head.

 

I just want to do a simple Sunrise Sunset of a Plant Light attached to an Insteon ON-Off Module.

 

==========================================

IF

Sunrise

AND

Plant Light is=Off

 

Then

Set Plant Light = ON

 

Else 'If'

Sunset

AND Plant Light = On

THEN

Set Plant Light = OFF

 

END

==========================================

 

Without giving me the answer:

 

How do you enter this into the ISY.

 

Do I need to have two separate programs, one for 'sunrise' and the second for 'sunset'?

 

Or can this all be accomplished inside one program as I am having a hard time doing?

 

Everytime I try to enter the Sunset schedule into the ELSE area it ends up in he first IF at the top of the program.

 

Thank you!

 

Rob

 

PS UPDATE: Does the ISY have the ability to do NESTED IF's THEN's ELSE's?  How does one get something nested.

 

If there any video that showsd programming the ISY as a tutorial that would be great, so far I haven't found any programming examples on YouTube.

Link to comment

What do you want to happen if it is sunrise and light if ON?  Do you always want the light to be ON, starting at sunrise, regardless of the state prior to sunrise?  What do you want to happen if sunset and light is already off?  Stay off?  If so, one program is fine.

 

if

from sunrise to sunset

then

turn on light

else

turn off light

 

There is no harm in turning ON a light that is already ON, and OFF a light that is already OFF.  Keep things simple, I say.

Link to comment

What do you want to happen if it is sunrise and light if ON?  Do you always want the light to be ON, starting at sunrise, regardless of the state prior to sunrise?  What do you want to happen if sunset and light is already off?  Stay off?  If so, one program is fine.

 

if

from sunrise to sunset

then

turn on light

else

turn off light

 

There is no harm in turning ON a light that is already ON, and OFF a light that is already OFF.  Keep things simple, I say.

Thank you, that's exactly whatI enfed up figuring out and doing.

 

I is only 4 lines as you have suggested.

Link to comment

ISY does not use flow based if-then-else logic. It's event based. So, you need multiple programs each implementing if-then for your two conditions.

I am not a programmer, so I don't exactly know what you mean by your statement "ISY does not use flow based if-then-else logic. It's event based."?

 

What is event based mean?

 

I'll google the term, but I talked to Steve today aboit something else I want to do and he too said to break it down into multiple programs, because it can't do the logic of normal or regular programming that I learned in school. He said the ELSE is not using as one would think its used.

 

As I said I'm a newbie trying to get used to the interface to be able to design and actually write the programs.

 

I will be trying to find as many examples as I could to help me learn how to do the actual writing.

 

I did watcfh all the YouTube videos that I was able to find.

 

ISY has a total of 3: 1) basic setup 2) adding devices, linking and troubleshooting 3) variables

 

That's it!

 

I am a visual learner, so the videos help me greatly understand actually using the interface to do the composing.

 

I'll get there but in the meantime, I will just depend on everyone's help.

 

I thank you all greatly!

 

Rob

Link to comment

ISY programs have one (or more) triggering events that cause a program to evaluate the IF condition. Based on that evaluation - either 'Then' or 'Else' is run.

 

For example:

If
        From    Sunset  + 15 minutes
        To      11:17:00PM (same day)
    And $i_vacation_mode is not 0
Then
        Wait  5 minutes  (Random)
        Set 'Outside / Outside - Rear' On
Else
        Set 'Outside / Outside - Rear' Off
 

$i_vacation_mode is an integer (does not trigger evaluation). The 'From' and 'To' create two separate triggering events - one at Sunset+15mins (will evaluate 'True' when it occurs) and one at 11:17PM (same day - but will evaluate 'False' when it triggers).

So - when the two events occur from the 'From' and 'True' - the non-triggering conditions are evaluated to see their state.  If all events evaluate 'True' then 'Then' is run. Otherwise 'Else' is run.

 

Changing this (subtlety). 

If
        From    Sunset  + 15 minutes
        To      11:17:00PM (same day)
    And $s_vacation_mode is not 0
 
Then
        Wait  5 minutes  (Random)
        Set 'Outside / Outside - Rear' On
 
Else
        Set 'Outside / Outside - Rear' Off
 

This time, the $s_vacation_mode is a 'state' variable. State variables cause evaluation of the condition every time they change.  So - the same happens at 'Sunset + 15' and 11:17pm (same day) - but if $s_vacation_mode changes at all an evaluation occurs then as well. So - setting $s_vacation_mode to '1' between the two times will cause 'Then' to run. Setting it to '0' will terminate 'Then' and start running 'Else'.  Critically - if you change $s_vacation_mode back to '0' within the (up to) 5 minutes wait in 'Then' of changing it to '1' - the still running 'Wait' will terminate - and 'Else' will immediately start.

 

It's driven by the triggering events.

 

You should do some research on what are triggering events to ISY. For example, Device 'status' triggers on any change of status (either locally, by scene or thru the API or product like Mobilinc). Device 'Control' triggers ONLY when the device is locally controlled. It's important to get to know what causes triggering when in the IF block to help understand the logic.

 

Flow based (or traditional) if-then-else does not have the notion of retriggering and reevaluation during the execution of the 'Then' or 'Else' code blocks. With traditional logic - after evaluation the 'Then' or 'Else' will generally always complete - often using 'Else If' and/or  ending with a 'End If' - neither of which have a place in the event driven method. With event based - if the triggering events change it will cause the 'Then' or 'Else' to terminate at the next 'Wait' or 'Repeat', the 'If' will be reevaluated and the 'Then' or 'Else will start from the top again.

 

Michael.

Link to comment

When triggered, a flow based program will run from beginning to end even if the state of the trigger becomes false during the execution of the program. An event based program will be interrupted if and when the condition become false.

 

This can be tricky. For example, if the trigger is that a device is manually turned on, then the program will not end if the device is turned off. That's because the condition only says what to do when the device is switched on, but not what to do if it's switched off.

 

To accomplish that, the condition should include that the device is switched on and the device is not switched off.

Link to comment

Thanks guys, I 'think' I get what you two are trying to say.

 

A flow based program just goes from line to line until it reaches an end.

 

A event based r triggered based program, will run the program but if a trigger or event happens the program can take a different direction.

 

Also, there is no real end of program (unless programmed to actually end) in a event based program because the program is continuallywaiting for an an event to happen or not to happen. Sort of link the task scheduler in a Windows OS.

 

Am I close in getting it?

 

Rob

Link to comment

Thanks guys, I 'think' I get what you two are trying to say.

 

A flow based program just goes from line to line until it reaches an end.

 

A event based r triggered based program, will run the program but if a trigger or event happens the program can take a different direction.

 

Also, there is no real end of program (unless programmed to actually end) in a event based program because the program is continuallywaiting for an an event to happen or not to happen. Sort of link the task scheduler in a Windows OS.

 

Am I close in getting it?

 

Rob

Yup! You got it!

 

Time frames are tricky gotcha ones.

 

When you use

 

If

  From 6:00 AM

  To 1:00 PM

Then

   ----

Else

  ----

 

At 6:00 AM  Else stops running (if it is) and Then starts  runnning

At 1:00 PM  Then stops running (if it is) and Else starts running

 

You can use the time frame as a condition / filter  for another trigger (you usually  have  no lines of code in Else) by putting  the time frame in another program with the disabled checked  This stops that program from triggering and auto-running.

 

If

    Control Switch is On      <---  anytime switch is tapped at the top, this is an event trigger

Then

   Run TimeFilter_Program (if)

Else

   ----    <---   will never run 'cause nothing will trigger a logical False in the If

 

 

TimeFilter_Program   (disabled)

----------------------------

If

     From 6:00 AM   <----this does NOT trigger then to run automatically

     to 1:00 PM        <-----this does NOT trigger Else to run automatically

Then

    do something     <---- this will run if inside time frame if the Switch is tapped up

Else

    do something else  <---- this will run if outside the time frame is the Switch is tapped up

 

 

Weird at first, but you it will become more natural with practice.

Link to comment

A flow based program just goes from line to line until it reaches an end.

 

Yes

 

A event based r triggered based program, will run the program but if a trigger or event happens the program can take a different direction.

 

Yes

 

 

 

Also, there is no real end of program (unless programmed to actually end) in a event based program because the program is continually waiting for an an event to happen or not to happen.

 

 

 

Yes

Link to comment

To the other replies, I will add/emphasise (if not already clear from Mwareman's post) that one needs to worry about programs halting only when there is a WAIT or REPEAT statement.  Otherwise, programs will run to conclusion and not be interrupted when a condition is triggered.

Link to comment

Archived

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


×
×
  • Create New...