Jump to content

Automatically turning off lights after given delay


ppitkin

Recommended Posts

Posted

Hi,

Can someone check my logic below - I'm not sure if I have this correct and if I should be using a "Repeat 1" or a "Repeat 0" to break the first repeat.

 

What I'm Trying to do is as follows:

 

If the light switch has its state manually changed to anything other than OFF then start a countdown timer. (Then Clause)

If the light switch is manually turned OFF then stop the countdown and terminate the auto off (Else clause activated)

If the state changes to anything other than OFF while the countdown is running then the countdown restarts.

 

If the countdown reaches the prescribed period without interruption then It should flash the lights OFF and ON twice.

 

It should then wait a further minute (to allow for manual resetting of the switch if someone wants the light to remain on.). If it detects no action then it should switch the light OFF, update my internal counters and notify me. If it detects an action on the switch then it resets and start again from the beginning.

 

I don't seem to be seeing that the part after the Repeat 0 is running. I was assuming that Repeat 0 means do not repeat the section i.e. execute it only once.

If
        Control 'Ground Floor / Living Room / Light Switch (Ceiling)' is not switched Off
 
Then
        Wait  3 hours and 59 minutes 
        Repeat 2 times
           Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Fast Off
           Wait  1 second
           Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Fast On
           Wait  1 second
        Repeat 0 times
           Wait  1 minute 
           Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Off
           $i.cnt.LivingroomMainLightOFF += 1
           $i.cnt.LivingroomMainLightOFF Init To $i.cnt.LivingroomMainLightOFF
           Resource 'Pushover_LivingroomMainLightOff'
 
Else
   - No Actions - (To add one, press 'Action')
 


Thanks for any feedback that you might be able to provide.

Peter

Posted

According to the Wiki a Repeat 1 executes once.   Never tried a Repeat 0 but the result suggests do not run at all.

 

To break a Repeat sequence, add a "Repeat 1 times". Actions after this Repeat will only run once (that is to say, they won't repeat at all). This is useful when you want some Actions repeated, but then want to continue on with more Actions that should not be repeated.

Posted

I have a couple of concerns. First, you may want to try:

 

Status is not off

 

As your program condition. "Control is not switched off" will trigger only upon receipt of an OFF command from the switch.

 

Second, I suspect your program will require breaking into two pieces if status is used.

Posted (edited)
....

 

As your program condition. "Control is not switched off" will trigger only upon receipt of an OFF command from the switch.

 

....

...and the "is not" will only run the "else" section, containing no program code. But it will terminate any then section running.

 

 

If

  (

  Control is  switched on

  or

  Control is  switched fast on

  or

   Control is switched fade up

  or

   Control is switched fade down

  )

and

  Control is not switched off

Edited by larryllix
Posted (edited)

Here is an example of a program I wrote that is quite similar.

If
        Control 'Alexis Room / Alexis BR-Overhead L' is switched On
     Or Control 'Alexis Room / Alexis BR-Overhead L' is switched Fast On
     Or Control 'Alexis Room / Alexis BR-Overhead L' is switched Fade Up
     Or Status  'Alexis Room / Alexis BR-Overhead L' is not Off
 
Then
        Wait  29 minutes 
        Repeat 60 times
           Wait  1 second
           Set 'Alexis Room / Alexis BR-Overhead L' 14 (Beep Duration)
        Repeat 1 times
           Set 'Alexis Room / Alexis BR-Overhead L' Off
 
Else
   - No Actions - (To add one, press 'Action')
 

The program allows the light to stay on 30 minutes since the last time the light switch was touched leaving the light in a "not off" situation.  During the last minute, it beeps to warn you that it is going to shut off.  If you want to reset the timer, any action on the switch will reset the timer from any condition, to any condition (except off).

 

Personally, I agree that the repeat 1 time or 0 times is confusing.  Repeat 0 times should just not be an option, and repeat 1 times should be replaced with "end repeat".  It would then be quite obvious what is going on.

Edited by apostolakisl
Posted

Thanks for all the helpful feedback.

 

Control was used as I only wanted it to respond to a physical action at the switch. This then allows me to turn it on and off in the program without it causing the if condition to re-trigger.

 

Oberkc, I think that   "Control is not switched off" will cause the if statement to be processed for any physical action on the switch. It should be TRUE for anything apart from turning the switch off (normally, not Fast OFF). Turning the switch OFF will therefore stop the Wait statement and exit via the ELSE i.e. do nothing. Any other physical action should cause it to start the wait loop from the beginning again. At least that is my understanding having read a large number of the posts and examples in the Forum.

 

Apostolakisl, I think that the "Control is not switched off" is the same as what you have done (but without the status part). It also however covers Fade Down and Fast OFF. As  mentioned above I didn't use status as it will cause the IF to be recalculated if you change the status of the device within the program (e.g. where I flash the lights on and off twice). I think your program only works correctly as you are setting the device to the OFF state as the last statement in the program.

 

I may however be totally wrong and have not understood correctly how the ISY logic handles "not Switched Off" - if so I'll take back all my comments above :oops:

 

I'll try changing to a "repeat 1" and see what that does. I noticed in the wiki that there was mention of a bug fix in one of the releases for the "Repeat 0" command - but it didn't say what the bug was or what fix was put in place. The wiki also doesn't appear to detail what Repeat 0 does - to me it implies don't repeat the following code i.e. run it only once.

Posted (edited)

I suspect that you at going to find your understanding of the "control not switched off" to be inaccurate. This will be triggered only by OFF commands, and run the ELSE path when triggered. If you care to confirm, turn on that switch and see if your program responds, if at all. I think you will Ind that it does not.

 

Apostolaksl and larrylix has, in my mind, the best solution for your stated requirements.

Edited by oberkc
Posted (edited)

OK,

happy to accept that. Unfortunately I can't test as my Insteon kit is located in my Holiday Chalet and not where I live and so its impossible for me to physically push a switch. I have to wait until a guest is staying there and then see what happens - not ideal!

 

I now have to change the If conditions on roughly 70 auto OFF programs - guess that's my evening gone again.

 

BTW I do see (in the admin console) the program being triggered and it having a TRUE state which should have meant it ran through the THEN path. I also see that the time it ran and the time that it ended corresponds to the first wait period. What I can't tell is what physical action was taken at the switch other than through the other program I have for each switch that records when the Switch was turned ON (again using Control rather than Status) and this seems to be showing that it ran at nearly the same time that the AUTO OFF program was started. This may be pure coincidence or it may be showing that the logic is working. What I also see is that when the Auto OFF program has a status of FALSE its end time is almost the same as the start time - meaning that the ELSE path was followed.

 

There just happens to be some guests staying in the chalet since yesterday and that's why I managed to determine something was wrong in that I was not getting the notifications being sent. I hate having to debug in a 'live' environment.  

Edited by ppitkin
Posted

I wanted the same results so I copied Apostolakis' program. If I push the switch "on" the program does not run. if I turn the switch on from the console it works. The same with off. Is my switch defective or am I doing something wrong? I copied it line by line.

Drkair 

Posted (edited)

I wanted the same results so I copied Apostolakis' program. If I push the switch "on" the program does not run. if I turn the switch on from the console it works. The same with off. Is my switch defective or am I doing something wrong? I copied it line by line.

Drkair 

How did you determine the program did not run?

 

Your switch may not be properly linked to the ISY. Did you factory reset the switch before usage?

Edited by larryllix
Posted

By looking at the program summary. I just checked the log and the manual pushes do not show up. I don't think I did a factory reset.

Drkair

Posted (edited)

 

Apostolakisl, I think that the "Control is not switched off" is the same as what you have done (but without the status part). It also however covers Fade Down and Fast OFF. As  mentioned above I didn't use status as it will cause the IF to be recalculated if you change the status of the device within the program (e.g. where I flash the lights on and off twice). I think your program only works correctly as you are setting the device to the OFF state as the last statement in the program.

 

 

 

 

"not switched off" behaves the same as "switched off", except it is false.  For example

 

if

control device x is not swithed off

Then

do x

Else

do y

 

Is the same exact thing as

 

If

control device x is switched off

Then

do y

Else

do x

 

Yes, you are correct that if you blink the lights, then the "status" line would screw it up.  Using "beep" does not.  In my case, that switch does not change status except from that switch or from ISY programs.  

 

I included the fade up and fast on commands so that any action on that switch would start the timer over.  "status" would fail to reset the switch if someone did a "fast on" or "fade up" when the light was already at 100%.  On the way down, the "status" line catches everything.  You could easily get rid of the status line and add "fade down".  You will also need to add a "not switched off" and "not switched fast off" to drive the else clause, otherwise the timer will still run if someone turns them off.  The one problem would be if someone fades to off.  The timer would still run and they would blink at the end of that timer.  The only way to fix that would be to have 2 programs.

Edited by apostolakisl
Posted

Why not use:

If
   Control 'Ground Floor / Living Room / Light Switch (Ceiling)' is  switched On
   and Control 'Ground Floor / Living Room / Light Switch (Ceiling)' is not switched Off

Then
   Wait 3 hours and 59 minutes 
   Repeat 2 times
   Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Fast Off
   Wait 1 second
   Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Fast On
   Wait 1 second
   Repeat 1 times
   Wait 1 minute 
   Set 'Ground Floor / Living Room / Light Switch (Ceiling)' Off
   $i.cnt.LivingroomMainLightOFF += 1
   $i.cnt.LivingroomMainLightOFF Init To $i.cnt.LivingroomMainLightOFF
   Resource 'Pushover_LivingroomMainLightOff'

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

This should provide the requested functionality AND allow the program to be canceled by manually turning the light off.

 

-Xathros

Guest
This topic is now closed to further replies.

×
×
  • Create New...