Home Mode

Discussion in 'General Discussion' started by inpowers, Dec 15, 2008.

  1. inpowers

    inpowers

    Joined:
    Jul 1, 2007
    Messages:
    44
    Likes Received:
    0
    Location:
    Sydney
    Hi All
    I am having a bit of trouble with this logic.
    I have a bus coupler connected to a alarm system.
    What it does is turn lights on between sunset & sunrise once the alarm system has been turned off which is not a problem.
    My problem is if the alarm system has not been activated for a day or so once it get to the sunset time of day the lights come on automatically.
    How do I go about making it only work once the alarm has been activated and then turned off after sunset.


    Code:
    once (GetLightingState("Stay Mode") = ON) and
         (Time > sunset + "0:15:00") or
         (Time < sunrise) then
    begin
      SetScene("Home Mode");
    end;

    Thank in advance
    Rob
     
    inpowers, Dec 15, 2008
    #1
  2. inpowers

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    322
    Likes Received:
    5
    Location:
    FNQ
    Logic

    Hello Rob,

    maybe you just need an extra set of brackets for the time section...

    Code:
    once (GetLightingState("Stay Mode") = ON) and
         ((Time > sunset + "0:15:00") or
         (Time < sunrise)) then
    begin
      SetScene("Home Mode");
    end;
    Regards,

    Mark
     
    Mr Mark, Dec 15, 2008
    #2
  3. inpowers

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    Always always always use lots of brackets. Don't assume the computer knows what you want. Tell it. Use brackets whether they are needed or not.
     
    ashleigh, Dec 15, 2008
    #3
  4. inpowers

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    If you created the code with the logic wizard, you would have seen a message warning that a combination of AND and OR logic has been used and that AND has precedence over OR and you should check that the correct behaviour will result.
     
    Darren, Dec 15, 2008
    #4
  5. inpowers

    inpowers

    Joined:
    Jul 1, 2007
    Messages:
    44
    Likes Received:
    0
    Location:
    Sydney
    Thanks guys for the quick reply,
    Will give the brackets a go tonight and see what happens.
    Thanks again

    Rob
     
    inpowers, Dec 16, 2008
    #5
  6. inpowers

    inpowers

    Joined:
    Jul 1, 2007
    Messages:
    44
    Likes Received:
    0
    Location:
    Sydney
    Hi Guys
    Unfortunately it is still doing the same thing as the first post.
    Is there any thing else that I could try.

    Regards
    Rob
     
    inpowers, Dec 17, 2008
    #6
  7. inpowers

    Colin Smith

    Joined:
    Aug 3, 2004
    Messages:
    102
    Likes Received:
    0
    Location:
    Auckland, New Zealand
    Stay Mode - should this be ON or OFF when the alarm is NOT ACTIVE.
     

    Attached Files:

    Colin Smith, Dec 17, 2008
    #7
  8. inpowers

    Colin Smith

    Joined:
    Aug 3, 2004
    Messages:
    102
    Likes Received:
    0
    Location:
    Auckland, New Zealand
    Have I misread this - Are you looking for the lighting cycle to 'occur only once' after the alarm has been turned OFF, and not on any subsequent days?

    If this is the case then you will need to set a variable as a flag.
    This detects that the alarm was turned Off and sets the first level flag
    Code:
    once (Get the input that shows alarm has been turned off)
     begin
       (Boolean to indicate that the alarm has been turn off) = TRUE);
     end;
    This part will only run after the alarm has been because the flag is set to TRUE.
    Code:
    Once (Boolean to indicate that the alarm has been set = TRUE) and
         ((Time > sunset + "0:15:00") or (Time < sunrise)) then
    begin
       SetScene("Home Mode");
       (Boolean to indicate that the alarm has been turn off) = False);
    end;
     
    Colin Smith, Dec 17, 2008
    #8
  9. inpowers

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    There is a discrepancy between what you are describing and what the code will actually do.

    With the code you first posted:

    Code:
    once (GetLightingState("Stay Mode") = ON) and
         (Time > sunset + "0:15:00") or
         (Time < sunrise) then
    begin
      SetScene("Home Mode");
    end;
    The scene will be set under any of the following circumstances:
    • "Stay Mode" goes on while it is after sunset + 15
    • "Stay Mode" is already on when the time gets to sunset + 15
    • "Stay Mode" is off and the time changes to midnight (time is before sunrise)

    With the modified code (extra brackets):

    Code:
    once (GetLightingState("Stay Mode") = ON) and
         ((Time > sunset + "0:15:00") or
         (Time < sunrise)) then
    begin
      SetScene("Home Mode");
    end;
    The scene will be set under any of the following circumstances:
    • "Stay Mode" goes on while it is between sunset + 15 and sunrise
    • "Stay Mode" is already on when the time gets to sunset + 15

    To make the scene set when the alarm gets turned off and it is between sunset and sunrise, the code will be:

    Code:
    once (GetLightingState("Stay Mode") = ON) then
    begin
      if (Time > sunset + "0:15:00") or (Time < sunrise) then
        SetScene("Home Mode");
    end;
     
    Darren, Dec 18, 2008
    #9
  10. inpowers

    inpowers

    Joined:
    Jul 1, 2007
    Messages:
    44
    Likes Received:
    0
    Location:
    Sydney
    Hi Darren

    Thank you very much your logic worked a treat.
    Thanks again and have a great xmas.:):):)

    Regards
    Rob
     
    inpowers, Dec 18, 2008
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.