Jump to content

Return lights to "previous state" Programming Help


Recommended Posts

I need some help with programming logic.

I have a driveway alert wired into a zone on my Elk M1.

When this zone is violated, I would like it to flash the kitchen light on and off a few times, then return to the "Previous State".

I.e. if the light was on, flash on/off/on/off, then return the light back to on.  If the light was off, flash then leave off.

I can figure out the trigger and flashing, but returning to the previous condition has me stumped.

I thought about making 2 separate programs, one with the "IF" kitchen is on.  And a separate program for "IF" the kitchen light is off.

Guess I was hoping there was a smarter way to do this.

My system is all Z-wave, no Insteon products. Running 5.0.14

 

Happy Thanksgiving and I am "Thankful" for those who can help!

Jeff

Link to comment

I can think of no quick-and-easy way to do this.  If you only want to return to a pre-defined state, that may be reasonably doable.  If you somehow want to account for the possibility that lights could be any state that is not predictable due to manual control or something similar, it seems to me that there is little other than brute force...somehow continually tracking status of lights (perhaps with a variable) and returning to that state after all your flashing has taken place.

Link to comment

Thank you Larry!

I have not experimented with variables much, but I think I understand.

First I created a new variable by going to variable tab and make/save a new variable: i.e. "Kitchen_light_current_status"
Then made a program that writes the variable.

What is my "if" to trigger it?  It needs to trigger whenever light is changed.  Couldn't find anything that might work, except something like "is not 2%" (very unlikely I would hit 2%:).

I got it to write the variable (except when I deliberately selected 2%)! Yeah!

 

Now, if the program rewrites the variable whenever the status changes, how do I prevent that variable from changing (being revised) as the lights are being flashed on and off?  I assume my flashing program will be something like:
If driveway alert violated, 
then light 100%, wait 1 sec, light 0%, wait 1 sec, light 100%, wait 1 sec, light 0%, wait 1 sec, set light variable "Kitchen_light_current_status"

I assume I could time how long my lights flash, then put a wait in the variable program, so it would not update until x seconds after any change.

Thanks and safe travels!

Link to comment

Yes. Multiple triggers of the technique is a problem as the variable memory stack is only one deep.

I have a program to do this and I have disabled it to use as a subroutine only, usually for testing other programs.

In another example I flash a gathering room lamp red when my garage door is open and return it to it's normal white once the garage door is closed again.

Sent from my SM-G930W8 using Tapatalk

Link to comment

1) You need two programs.  Program 1 is the trigger (the Elk zone), program 2 executes the lighting.  If you use a single program, and the Elk zone changes before it finishes, it will kill the program.

2) I would use a network resource to set the light level.  It doesn't require writing any changes to the device settings, it just sets the level.  I assume you have network resources.  If you either paid for the network resource module or the portal, you have it.

Below are my example that I have tested and works.  For some reason, I needed a two second delay before the network resource or it didn't work consistently.  I don't know why.  The trigger program runs the flashing program which temporarily disables the triggering program to ensure the process completes.

 

flash and return 1 - [ID 0157][Parent 0093]

If
        Elk Zone 'Back Door' is Violated
 
Then
        Run Program 'flash and return' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')
 

 

This program then translates the % of the light to the 0-256 8-bit scale Insteon uses for levels.  Flashes the light, then sets it back.

flash and return - [ID 0154][Parent 0093]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Disable Program 'flash and return 1'
        $stest  = 'Back Hall / Back Hall Gar Dr-Hall L' Status 
        $stest *= 2.55    ****I edited this, I had 2.56 originally, but it is 2.55  . . .  256 values, 0-255****
        Wait  1 second
        Set 'Back Hall / Back Hall Gar Dr-Hall L' Fast On
        Wait  1 second
        Set 'Back Hall / Back Hall Gar Dr-Hall L' Fast Off
        Wait  1 second
        Set 'Back Hall / Back Hall Gar Dr-Hall L' Fast On
        Wait  1 second
        Set 'Back Hall / Back Hall Gar Dr-Hall L' Fast Off
        Wait  2 seconds
        Resource 'test'
        Enable Program 'flash and return 1'
 
Else
   - No Actions - (To add one, press 'Action')
 

 

The network resource is 

1) HTTP Get

2) host is ip address of your ISY

3) Path is   /rest/nodes/xx%20xx%20xx%201/cmd/DON/${var.y.z}

xx needs to be replaced by the address of your device.  like if it were 56 1B 3 1  Then the above would be 56%201B%2003%201   (%20 is equal to a space in html) The address will be found on the main page of isy.  Click on the device and in the right hand pane, underneath the name you gave the device will be the address.  Please note, it needs to be xx xx xx x format.  For example, 56 1B 3 1 needs to be entered in the network resorce as 56 1B 03 1   The last digit will always be a solo 1.

y= variable type you used to save the light level.  1= integer, 2=state.  In this case it doesn't matter which you use

z= variable id number for your variable.  This will be found to the left of the variable on the variable setup page.

4) You need to set your authorization.  In the "headers section" pick "add", then "authorization" then enter your ISY username and password.  

5) Click "update", then "Save", then "Save" again at the bottom of the network resource main page.

 

NOTE: This works regardless of whether the light is in a scene or not.  If it is in a scene, just use the switch that is the load switch.

Link to comment

Archived

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


×
×
  • Create New...