Jump to content

Refactoring ISY program


hart2hart

Recommended Posts

On occasion I go back and look at forum (thanks all) and see if there are better ways to accomplish tasks that I may have used brute force to accomplish (as a programmer from a few years ago, the ISY mixture of trigger and If structure  took me forever to appreciate subtle usage -- love it now).  Following is one of my first ISY programs sets  (actually recall more Michel :) than me).  It uses a motion sensor to turn on a light outside a garage door but prevents program from turning it if off if it was already on due to fact that I had turned it on at switch.  Continued motion resets timer  so that light  will remain on for 10 minutes after last motion detected.  It was before variables as you can see they use a program as a variable -- thought I had found and updated all these. 

 

 

Garage:Fence Motion

If
        Control 'Garage / Garage:Fence Motion Sensor' is switched On
    And Program 'Garage:Entry Door Status' is False
 
Then
        Set 'Garage / Garage:Outside Entry Door' 100%
        Wait  10 minutes
        Set 'Garage / Garage:Outside Entry Door' Off
 
Else
   - No Actions - (To add one, press 'Action')

 

 

------

 

 

Garage:Entry Door Off

If
        Control 'Garage / Garage:Outside Entry Door' is switched Off
 
Then
        Run Program 'Garage:Entry Door Status' (Else Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

 

----

 

Garage:Entry Door On

If
        Control 'Garage / Garage:Outside Entry Door' is switched On
 
Then
        Run Program 'Garage:Entry Door Status' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

 

 

-----

 

Garage:Entry Door Status - Variable only 

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
   - No Actions - (To add one, press 'Action')
 
Else
   - No Actions - (To add one, press 'Action')
 

 

 

 

The only issue and I mean small issue is the  delay between motion detected and light on.  Could I use an Insteon scene to turn light on (assuming motion sensor  does not send an off) and adapt programs as follows?  Changes (not correct syntax yet)  are in red.  In essence, is there a difference for the two programs tracking the on and off state of the light based on if it is turned on by the  ISY program or the light is turned on by scene membership?

 

 

Garage:Fence Motion

If
        Control 'Garage / Garage:Fence Motion Sensor' is switched On
    And Variable  Garage_Entry_Door_Status = 0
 
Then
          ----light would be turned on by scene membership----
        Wait  10 minutes
        Set 'Garage / Garage:Outside Entry Door' Off
 
Else
   - No Actions - (To add one, press 'Action')

 

 

------

 

 

Garage:Entry Door Off

If
        Control 'Garage / Garage:Outside Entry Door' is switched Off
 
Then
        Set Variable  Garage_Entry_Door_Status to 0
 
Else
   - No Actions - (To add one, press 'Action')

 

----

 

Garage:Entry Door On

If
        Control 'Garage / Garage:Outside Entry Door' is switched On
 
Then
        Set variable  Garage_Entry_Door_Status to 1
 
Else
   - No Actions - (To add one, press 'Action')

 

 

---

 

Variable

 

Garage_Entry_Door_Status defined as state variable

Link to comment

If you want the light always to come on (or stay on) when motion is sensed, having no other conditions, then using a scene seems like a better idea to me. This is how I do it, and it seems to work well for me. You should experience a faster response and that is one less failure mode. Be sure to configure the motion sensor to send only ON commands.

 

I notice, however, that you have a second condition for which you test before turning on the light: entry door program status is false. Using a scene will not allow you to check for this condition.

Link to comment

Archived

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


×
×
  • Create New...