Comfort  Automation/ Security System Forums Home
Home Search search Menu menu Not logged in - Login | Register

If/Then Programming example
 Moderated by: slychiu
 New Topic   Printer Friendly 
 Rate Topic 
AuthorPost
 Posted: Saturday May 5th, 2007 10:12 am
   
1st Post
ident
Administrator


Joined: Wednesday Aug 9th, 2006
Location: Singapore
Posts: 3493
Status: 
Offline

  back to top

This example shows how to do X from 6 AM to 11 PM and do Y at other times

If  Hours < 6 Then
   Do Y [Y]
Else
   If  Hours < 23 Then
         Do X [X]
   Else
       Do Y [Y]
   End If
End If


It needs to be programmed this way because Comfigurator is not able to do the following

IF (condition 1) AND (condition 2) THEN

or

IF (condition 1) OR (condition 2) THEN




 Posted: Monday Mar 31st, 2008 01:30 pm
   
2nd Post
BMagalhaes
Member


Joined: Thursday Sep 28th, 2006
Location: Lisbon, Portugal
Posts: 32
Status: 
Offline

  back to top

Hi,

So does it mean that a response such as follows will not work?

If Flag ILcozinhaFrt <> 0 Then
    If Input SC_LUZ_CZ_FRENTE = 0 Then
        Do ILcozinhaFrt_On []
        Do ILcozinhaFrt_Off [] After 300 Seconds Using IL_COZINHA_Frt
    Else
        Do ILcozinhaFrt_Off [] After 300 Seconds Using IL_COZINHA_Frt
    End If
End If


Tks, Bruno



 Posted: Monday Mar 31st, 2008 01:48 pm
   
3rd Post
admin
Administrator


Joined: Saturday Mar 3rd, 2007
Location: Singapore
Posts: 1200
Status: 
Offline

  back to top

It will work. Any valid programming statement done with Response wizard will work
My point is that the OR statement is not possible current;y, if so it would make things simpler



 Posted: Thursday Sep 15th, 2011 06:33 pm
   
4th Post
HenleyBranch
UCM Pi Users
 

Joined: Saturday Apr 30th, 2011
Location: United Kingdom
Posts: 75
Status: 
Offline

  back to top

Hi,

I am wondering if anyond can help me with an if/then query?

I would like to turn on lights in hallway house once my comfort is disarmed. However I would only like it to do this at night, or more precisely I would like it to do this 60 minutes before sunset until 60 minutes after sunrise. I am a newbie and am getting the hang of programming, I have set the sunrise and sunset for my location using Comfigurator, I have found the night time parameter, but am not sure how to go the next step - is there a way?

Many thanks for any help.



 Posted: Friday Sep 16th, 2011 09:46 am
   
5th Post
wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 546
Status: 
Offline

  back to top

My 2c worth, is create a number of different responses, rather than try and do it all in one response:-

First, create flags:-

1) Hall Light Flag
2) Sunset Flag

And timer, Hall Light Timer (if you want the light to turn off after a period)

Second, create responses:-


1) Hall Light on response does the following:-
If hall light flag is off
Turn Hall light flag on
Set hall light flag to on
Starts timer (hall light timer if you want to turn the light off after a while)

Else:
Start timer hall light

The above response is if you want the light to also turn off after a certain period. If the hall light is already on (flag is on), then all it does is reset the countdown timer, but if the flag is off, it turns on the light and starts the timer.

A second response is then needed to trun off the hall light as follows:-

2) Hall Light Off hall light off response
Turns hall ligh off
Sets hall light flag to off

3) For the timer you set up, have it run the Hall light off response when the timer expires


Now for the activation on security off if its nighttime

Create a response called "Home time" for example as follows:-

If flag sunset is on
Then:- Do response Hall light on
End

Last step then is to have the security off response point to your "home time" response.

The advantage of doing it this way, is that as you start wanting the house to do more on arriving home, al you need to do is create the responses, and then add them to the "Home time" response.

Hope this makes some level of sense, this is how I have my comfort system operating my x10 lights. If you want I can copy the repsonses from my fonfig file and paste them later when I get home!



 Posted: Friday Sep 16th, 2011 06:29 pm
   
6th Post
HenleyBranch
UCM Pi Users
 

Joined: Saturday Apr 30th, 2011
Location: United Kingdom
Posts: 75
Status: 
Offline

  back to top

Thank you for such a comprehensive response. Really very helpful. I am going to give that a go. Good suggestions, all my lights are X10.

If you could paste your code that would be marvellous.

I haven't made any flags as yet so this will be an interesting lesson. I am presuming that I can code the flag to be either side of the actual sunset sunrise - I am trying to overcome the issue of twilight.

Thank you



 Posted: Friday Sep 16th, 2011 07:52 pm
   
7th Post
wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 546
Status: 
Offline

  back to top

I would suggest starting off creating a flag and a timer for every element you have, so every x10 device etc should have a flag and a timer!



 Posted: Saturday Sep 17th, 2011 02:42 am
   
8th Post
ident
Administrator


Joined: Wednesday Aug 9th, 2006
Location: Singapore
Posts: 3493
Status: 
Offline

  back to top

There is also an action Sunrise/Sunset Time Offset which can offset the sunrise or sunset time by a number of minutes
This wil change the time at which sunrise or sunset Responses are activated so you can for  example cause lights to be turned on before sunset and to be turned of after sunrise

However the automatic Night Time flag which is turned on between sunrise and sunset time is unchanged. You can test the Night Time Flag in an If condition without having to set or clear a flag manually



 Posted: Thursday Oct 6th, 2011 06:10 pm
   
9th Post
HenleyBranch
UCM Pi Users
 

Joined: Saturday Apr 30th, 2011
Location: United Kingdom
Posts: 75
Status: 
Offline

  back to top

Thanks

Is the sunrise / sunset offset set within the individual response, or is it a global setting? I don't suppose you can refer me to any example code featuring this offset could you? I am still picking this up.

Wexfordman - I have made all my timers and flags and am having fun!



 Posted: Friday Oct 7th, 2011 06:21 am
   
10th Post
slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5493
Status: 
Offline

  back to top

The sunrise and sunset offset action causes the sunrise or sunset times to be offset by -128 to + 127 minutes from the programmed value. This allows you to, for example, turn on lights 30 minutes before sunset and/or 10 minutes after sunrise







In the above example the sunrise time has been offset by + 30 minutes, which means the Sunrise Response will be activated at Sunrise + 30 minutes

Offset Sunset time is done the same way

You create a Response with the action to offset the sunrise and/or sunset times. Then you need to activate the Response using an event for example in Time programs. This action remains in place until changed again by another sunrise/sunset offset action or until Comfort is reset


Note that this does not change the Night Time Flag which is automatically set between sunrise and sunset. It only changes the activation time of Sunrise or Sunset Responses




 Current time is 08:32 am
Top




UltraBB 1.172 Copyright © 2007-2014 Data 1 Systems