Jump to content

Programming Question with Conditionals


jgcharlotte

Recommended Posts

NiteLite - [iD 003B][Parent 0007]

 

If

        Status  'MBR-Corner Lamp' is Off

    And Control 'ZW 002 MBR Motion Sensor' is switched On

 

Then

        Set 'MBR-Corner Lamp' 15%

        Wait  20 seconds

        Set 'MBR-Corner Lamp' Off

 

Else

   - No Actions - (To add one, press 'Action')

 

 

The OFF command never gets sent.  so is the entire program disabled as soon as the light turns on, IE, the WAIT > OFF does not execute?  It seems like the remainder of the program should execute regardless of the IF,

Link to comment

ISY programs stop executing when the if clause is no longer true. As soon as the light gets turned on to 15%, the program exits.

 

You can make a separate program (2) with no If clause and put the Then statements in it. Replace the statements in your existing program (1) with a Program Run Then statement to run program (2). That program will run until complete

 

NiteLite 1
If
        Status  'MBR-Corner Lamp' is Off
    And Control 'ZW 002 MBR Motion Sensor' is switched On
 
Then
        Run Program 'NightLite 2' Then clause
 
Else
   - No Actions - (To add one, press 'Action')
 
NiteLite 2
If
Then
        Set 'MBR-Corner Lamp' 15%
        Wait  20 seconds
        Set 'MBR-Corner Lamp' Off
 
Else
   - No Actions - (To add one, press 'Action')
 
Paul
Edited by paulbates
Link to comment

Or you could try this...

 

If
        Status  'MBR-Corner Lamp' is Off
    And Control 'ZW 002 MBR Motion Sensor' is switched On
 
Then
        Set 'MBR-Corner Lamp' 15%
       
Else
        Wait  20 seconds
        Set 'MBR-Corner Lamp' Off
 
You can observe the actions of the program by right clicking on it > Status Icons > Detailed then activate and observe
 
 
Jon...
 
Link to comment

Sure, it's meant as a night light.  If you get out of bed in the middle of the night, just put a little bit of light in the room.  If it didn't check OFF status, every time motion is detected it would go to 15%.  I did add a program that would turn it off prior to the auto turn-off time (which I set to 60 secs) if motion is detected, IE, going back to bed.

Link to comment

Thanks!  I guess that makes sense, just seems a bit illogical to me.

 

That's true, but programs do what you tell then do which is not always what you meant to say.

 

Consider the condition you wrote: Status  'MBR-Corner Lamp' is Off which triggers Set 'MBR-Corner Lamp' 15%. At that instant, the condition evaluates as false and the program stops (or executes the Else statements). Paul's programs (#2) work because NiteLite 2 doesn't have a condition that keeps it from running to its conclusion.

Edited by stusviews
Link to comment

Sure, it's meant as a night light.  If you get out of bed in the middle of the night, just put a little bit of light in the room.  If it didn't check OFF status, every time motion is detected it would go to 15%.  I did add a program that would turn it off prior to the auto turn-off time (which I set to 60 secs) if motion is detected, IE, going back to bed.

 

You'll learn it hand to create conditions such as Home | Away | Sleep | etc.. using State Variables and applying these to programs.

These variables can be changed using a number of different methods like a remote for sleep or your phone's WiFi (location) for Home/Away.

 

If
        Status  'MBR-Corner Lamp' is Off
    And Control 'ZW 002 MBR Motion Sensor' is switched On
    And $s.Sleep is 1
 
 
 
Jon...
Link to comment

 

Or you could try this...

 

If
        Status  'MBR-Corner Lamp' is Off
    And Control 'ZW 002 MBR Motion Sensor' is switched On
 
Then
        Set 'MBR-Corner Lamp' 15%
       
Else
        Wait  20 seconds

        Set 'MBR-Corner Lamp' Off
 
You can observe the actions of the program by right clicking on it > Status Icons > Detailed then activate and observe
 
 
Jon...
 

 

 

This would work great provided you don't want the light to ever be on aside from when the motion sensor triggers it.  Turning the light on manually will trigger the program (a "status" line in a program triggers every time the status of said device changes), it will evaluate to false (since the control on motion sensor line will be false), the else clause will run, and 20 seconds later the light turns off.

Link to comment

 

ISY programs stop executing when the if clause is no longer true. As soon as the light gets turned on to 15%, the program exits.

 

You can make a separate program (2) with no If clause and put the Then statements in it. Replace the statements in your existing program (1) with a Program Run Then statement to run program (2). That program will run until complete

 

NiteLite 1
If
        Status  'MBR-Corner Lamp' is Off
    And Control 'ZW 002 MBR Motion Sensor' is switched On
 
Then
        Run Program 'NightLite 2' Then clause
 
Else
   - No Actions - (To add one, press 'Action')
 
NiteLite 2
If
Then
        Set 'MBR-Corner Lamp' 15%
        Wait  20 seconds
        Set 'MBR-Corner Lamp' Off
 
Else
   - No Actions - (To add one, press 'Action')
 
Paul

 

 

Paul's solution worked perfectly, transferring control to the second program.  I just added another one that turns off the light if motion is detected again before the timeout (changed to 90 seconds) and I put the whole set in a folder controlled by a motion sensor dusk/dawn so it doesn't operate during the day.

 

Thanks!

Link to comment

Keeping programs in folders makes it easy to find the program for editing. Also, you can include sunset to sunrise as a program condition.

Link to comment
Guest
This topic is now closed to further replies.

×
×
  • Create New...