Comfort Automation/ Security System Forums
Programming question - Printable Version

+- Comfort Automation/ Security System Forums (https://www.comfortforums.com)
+-- Forum: Support (https://www.comfortforums.com/forum-2.html)
+--- Forum: Problems & Troubleshooting (https://www.comfortforums.com/forum-36.html)
+--- Thread: Programming question (/thread-454.html)



- on4cet - 02-01-2007

Hi,

This may seem like a dumb question, but for the first time, I\'m programming my comfort system to do some things automatically, and I have a question on this.

I would like to move my shutters up at the morning (dawn), when my light-sensor input is low (0) (through lsm module), but,  in the week, this may not happen before let\'s say 7.00 AM, and in the week-end 8.00AM ... 

I have the shutters response coupled with the OFF response of my lsm-zone.  But I guess this response will only be triggered when the input(zone) changes state, so, if I put a condition in the response, let\'s say that the day of week >=6 and the hour must be >=7 (or 8 for the week-end), how can I become that comfort will keep walking through this response till the hour is good to start the shutters ?  If I keep this in a loop by re-calling the same-response, I guess my comfort will end up in an endless loop ??

Any help is much appreciated !

Kind regards,

Bart

 



- Guest - 02-02-2007

Why not make use of Time Programs? Time Programs allow you  to select the day of week and time at which the responses are triggered. Of course, you could make use of a flag to determine whether to trigger the response or not.



- lms - 02-02-2007

Try something like this:

Set a time program, let\'s call it \"Dawn\", to run the following response at 7:00am.

-----

Dawn:
Set Flag ShuttersClosed
If DayOfWeek < 6 Then
    Do OpenShutters
Else
    Do OpenShutters After 3600 Seconds Using TimerShutters
End If

-----

OpenShutters:
If Flag ShuttersClosed <> 0 Then
    If InputLSM = 0 Then
        [open the shutters]
        Clear Flag ShuttersClosed
    Else
        If Hours < 9 Then
            Do OpenShutters After 60 Seconds Using TimerShutters
        Else
            [what to do at 9:00am?]
        End If
End If

Haven\'t used the LSM yet, so not sure about checking the condition of this in the code above, but it sounds like you already have that figured out. The above also gives up waiting for the LSM at 9:00am - change as required. 60 seconds is only an example - set to whatever you need. I have responses that loop, waiting for some condition, every second, and have not had any problems yet with Comfort G2 - but would recommend careful testing! (Note that I haven\'t tested the above - just used one of responses as a template.)

Regards,
Leon




- on4cet - 02-02-2007

Hi,

Seems like in the example you also call the same respons again, that\'s how I had done it, but will the calling response run further from the point where it is called again when the called respons has ended, or will there be a complete exit out of the response when calling another one ?
[Edit 2/2/07]

Guess everything will work now (but all comments are welcome) :

Response=Shut-2Fl-Dwn-Sto,
  Number=66, Fixed=Yes,
  Description=\"Change Output State Of Output 15 To OFF, So Shutters Stop Moving Downwards\"
  Output Shutters-2Fl-Dwn Off
  ! ActionCodes=128,15,0,255
End Response

Response=Shut-2Fl-Dwn-Act,
  Number=64, Fixed=Yes,
  Description=\"Set Output 15 To ON, To Move All Shutters On 2nd Floor Down (Group Control Relais)\"
  Output Shutters-2Fl-Dwn On
  ! ActionCodes=128,15,1,255
End Response

Response=Shut-2Fl-Up-Stop,
  Number=62, Fixed=Yes,
  Description=\"Change Output State Of Output 14 To OFF, So Shutters Stop Moving Upwards\"
  Output Shutters-2Fl-Up Off
  ! ActionCodes=128,14,0,255
End Response

Response=Shut-2Fl-Up-Act,
  Number=60, Fixed=Yes,
  Description=\"Set Output 14 To ON, To Move All Shutters On 2nd Floor Up (Group Control Relais)\"
  Output Shutters-2Fl-Up On
  ! ActionCodes=128,14,1,255
End Response

Response=Shut-1Fl-Dwn-Sto,
  Number=58, Fixed=Yes,
  Description=\"Change Output State Of Output 13 To OFF, So Shutters Stop Moving Downwards\"
  Output Shutters-1Fl-Dwn Off
  ! ActionCodes=128,13,0,255
End Response

Response=Shut-1Fl-Dwn-Act,
  Number=56, Fixed=Yes,
  Description=\"Set Output 13 To ON, To Move All Shutters On 1st Floor Down (Group Control Relais)\"
  Output Shutters-1Fl-Dwn On
  ! ActionCodes=128,13,1,255
End Response

Response=Shut-1Fl-Up-Stop,
  Number=54, Fixed=Yes,
  Description=\"Change Output State Of Output 12 To OFF, So Shutters Stop Moving Upwards\"
  Output Shutters-1Fl-Up Off
  ! ActionCodes=128,12,0,255
End Response

Response=Shut-1Fl-Up-Act,
  Number=52, Fixed=Yes,
  Description=\"Set Output 12 To ON, To Move All Shutters On 1st Floor Up (Group Control Relais)\"
  Output Shutters-1Fl-Up On
  ! ActionCodes=128,12,1,255
End Response


Response=Dusk-Actions,
  Number=180, Fixed=Yes,
  Description=\"All Responses Which Need To Be Performed At Dusk (Continues On 181)\"
  Do All-Shutters-Dwn
  ! ActionCodes=74,160,255
End Response

Response=Dawn-Actions,
  Number=170, Fixed=Yes,
  Description=\"All Responses Which Need To Be Performed At Dawn (Continues On 171)\"
  If  DayOfWeek < 6 Then
    If  Hours >= 7 Then
      Do Shut-1Fl-Top
    End If
  Else
    Do Shut-1Fl-Top After 10800 Seconds Using Wait-Timer2
  End If

  ! ActionCodes=73,8,69,6,73,3,70,7,74,120,196,194,16,42,48,120,255
End Response

Response=All-Shutters-Dwn,
  Number=160, Fixed=Yes,
  Description=\"Move All Shutters Down To Bottom Position\"
  Do Shut-1Fl-Bottom
  Do Shut-2Fl-Bottom
  ! ActionCodes=74,130,74,150,255
End Response

Response=Shut-2Fl-Bottom,
  Number=150, Fixed=Yes,
  Description=\"Move Shutters 2nd Floor Down For 50 Seconds (To Bottom Position) (Continues On 151 & 152)\"
  If Input Input-Licht = 0 Then
    Do Shut-2Fl-Dwn-Act
    Do Shut-2Fl-Dwn-Sto After 50 Seconds Using Shutters-Timer
    Set Flag Shut-2Fl-Bottom
    Clear Flag Shut-2Fl-Top
  Else       
    Do Shut-2Fl-Bottom After 300 Seconds Using Wait-Timer2
  End If  
  ! ActionCodes=79,2,16,74,64,194,2,0,50,66,132,4,1,132,3,0,196,194,16,1,44,150,255
End Response

Response=Shut-2Fl-Top,
  Number=140, Fixed=Yes,
  Description=\"Move Shutters 2nd Floor Up For 50 Seconds (Top Position) (Continues On 141 & 142)\"
  Do Shut-2Fl-Up-Act
  Do Shut-2Fl-Up-Stop After 50 Seconds Using Shutters-Timer
  Set Flag Shut-2Fl-Top
  Clear Flag Shut-2Fl-Bottom
  ! ActionCodes=74,60,194,2,0,50,62,132,3,1,132,4,0,255
End Response

Response=Shut-1Fl-Bottom,
  Number=130, Fixed=Yes,
  Description=\"Move Shutters 1st Floor Down For 50 Seconds (To Bottom Position) (Continues On 131 & 132)\"
  If Input Input-Licht = 0 Then
    Do Shut-1Fl-Dwn-Act
    Do Shut-1Fl-Dwn-Sto After 50 Seconds Using Shutters-Timer
    Set Flag Shut-1Fl-Bottom
    Clear Flag Shut-1Fl-Top
  Else   
    Do Shut-1Fl-Bottom After 300 Seconds Using Wait-Timer1
  End If
  ! ActionCodes=79,2,16,74,56,194,2,0,50,58,132,2,1,132,1,0,196,194,15,1,44,130,255
End Response

Response=Shut-1Fl-Top,
  Number=120, Fixed=Yes,
  Description=\"Move Shutters 1st Floor Up For 50 Seconds (Top Position) (Continues On 121 & 122)\"
  If Input Input-Licht <> 0 Then
    Do Shut-1Fl-Up-Act
    Do Shut-1Fl-Up-Stop After 50 Seconds Using Shutters-Timer
    Set Flag Shut-1Fl-Top
    Clear Flag Shut-1Fl-Bottom  
  Else
    Do Shut-1Fl-Top After 300 Seconds Using Wait-Timer2
  End If  
  ! ActionCodes=79,2,15,74,52,194,2,0,50,54,132,1,1,132,2,0,196,194,16,1,44,120,255
End Response



! Time Programs
! =============

TimeProgram=Dawn-Actions,
  Mon=Yes, Tue=Yes, Wed=Yes, Thu=Yes, Fri=Yes, Sat=Yes, Sun=Yes,
  Hol=Yes, Hours=5, Minutes=0, Response=Dawn-Actions, Enabled=Yes
TimeProgram=Dusk-Actions,
  Mon=Yes, Tue=Yes, Wed=Yes, Thu=Yes, Fri=Yes, Sat=Yes, Sun=Yes,
  Hol=Yes, Hours=16, Minutes=0, Response=Dusk-Actions, Enabled=Yes

! Flags
! =====
Flag=Shut-1Fl-Top, Number=1
Flag=Shut-1Fl-Bottom, Number=2
Flag=Shut-2Fl-Top, Number=3
Flag=Shut-2Fl-Bottom, Number=4

! Timers
! ======
Timer=Light-Timer, Number=1
Timer=Shutters-Timer, Number=2
Timer=Wait-Timer1, Number=15
Timer=Wait-Timer2, Number=16


Kind regards & many thanks for the helping hands ...

Bart




- lms - 02-03-2007

Hi Bart:

Sorry, don\'t really have the time right now to go through all your responses, but briefly - and I\'m not an expert so hope someone will correct me if I\'ve got any details wrong - the way I understand it.....

If a response (OpenShutters in my example) is called from another response (Dawn in my example), then, if it is called with no timer argument, control will be returned to the next statement after completion of the called response (as per the first call to OpenShutters in my example). However, if called with a timer argument, the called response will be scheduled immediately, and the the calling reponse will continue with the subsequent statements (and exit as per my second call to OpenShutters). To keep things identical, I\'d probably add \"After 1 Seconds\" to the first \"Do OpenShutters\" statement, otherwise you could end up with different behaviour when the reponse gets more complex. (Unless, of course, you do want different behaviour!)

So, in my second response, \"OpenShutters\", the \"Do OpenShutters After 60 Seconds\" statement will be scheduled to run in 60 seconds time, while the current instance of OpenShutters will continue (and, in this example, simply exit and disappear). So this is not really an \"endless\" loop. Of course, you do need to be careful to avoid real endless loops which certainly will cause problems!

I\'m not entirely certain of what would happen if the first instance of a response is still running when a second instance is started. I\'d avoid such a situation - have not been able to find any documentation explaining exactly how the scheduler works and would appreciate a detailed description from anyone out there!

As mentioned in my previous message, I have responses that loop like this every second. Under certain conditions, I\'ve found that I\'ve had to make it 2 seconds. For example, I have PIRs which cause lights to be turned on - something like this:

Loop every second, waiting for PIR in Room 1 to activate.
On activation, turn on lamp in Room 2, then loop every second, waiting for PIR in Room 2 to activate.
On Room 2 PIR activation, turn on light in Room 3, turn off light in Room 1, then loop every second, waiting for PIR on Room 3 to activate.
And so on.

Probably not very useful - really just did it to get to grips with the programming methodology and didn\'t like to wait for the light to turn on when I was already in the dark room (I\'m using X10 so there are delays) . In Comfort G1 I had endless problems with this, but with G2, it works perfectly. And it does mean that I can save lots of energy by not having to lift my lazy arms to turn on the lights in the morning on my way from the bedroom to the kitchen and the bathroom and so on!

Post another message if I can be of any further assistance.

Regards,
Leon




- on4cet - 02-03-2007

Hi Leon,

You\'re comments were very clear ... , for which I would like to thank you !

Kind regards,

 

Bart