Help needed with simple coding

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by pastorhinn, Feb 7, 2011.

  1. pastorhinn

    pastorhinn

    Joined:
    Aug 4, 2006
    Messages:
    43
    Likes Received:
    0
    Hi guys,

    I would love it if some one could help me with a problem please.I have a customer with a sensor in the toilet of there house. They would like to have the sensor ramp the downlights up slowly to say 60% when the sensor is activated between a certain time (say 11pm to 5am). And at all other times have the sensor just turn the light on as normal. I have a wiser unit in the installation so i have been trying to do it with a little logic but keep coming up with compile errors and cant work out the best way to do it.

    I have set the output of the sensor to "toilet control" for both day move and night move. And the actuall relay output to "us31". I have written it into logic where when the toilet control is active and between these times switch us31 or if its between the hours of 11pm to 5am ramp us31 to 60% over 10s. This is obviously a ruff example but im finding no mater how i write it,it just wont work????

    Any help is a good help.

    Thanks Brenton
     
    Last edited by a moderator: Feb 7, 2011
    pastorhinn, Feb 7, 2011
    #1
  2. pastorhinn

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    It sounds like you are on the right track.... can you post the code that is giving you compile errors? It may just be a simple syntax problem.

    Nick
     
    NickD, Feb 7, 2011
    #2
  3. pastorhinn

    pastorhinn

    Joined:
    Aug 4, 2006
    Messages:
    43
    Likes Received:
    0
    Hi Nick. dont know if i am on the right track or not. Here is what i have writen.

    once GetLightingState("toilet light control")=ON and
    ((Time > SunSet) and (Time < SunRise)) then
    SetLightingLevel("us31", 100%, "12s");
    end;
    until
    GetLightingState("toilet light control")=OFF then
    SetLightingLevel("us31", 0%, "12s");
    end;

    once GetLightingState("toilet light control")=on and
    ((Time < SunSet) and (Time > SunRise)) then
    SetLightingState("us31", ON);
    end;
    until
    GetLightingState("toilet light control")=off then
    SetLightingState("us31", OFF);
    end;

    Any help is a great help.

    Cheers Brenton
     
    pastorhinn, Feb 8, 2011
    #3
  4. pastorhinn

    mattyb

    Joined:
    Jul 29, 2005
    Messages:
    78
    Likes Received:
    0
    Location:
    Sydney, Australia
    Hi Brenton

    You definitely have a problem with

    it can never be before sunrise and after sunset on the same day - you need to use OR in this case. I fell into the same trap when I started doing this sort of thing with PIRs.

    Also, I always err on the side of too many brackets and begin/end pairs.

    I'm not sure you can use
    the way you have.

    I would normally have a separate piece of code for "once the PIR goes off".

    There's other ways to do this but one way would be...

    Code:
    once ((GetLightingState("toilet light control") = ON) and ((Time >= SunSet) or (Time <= SunRise))) then
    begin
      SetLightingLevel("us31", 60%, "12s");
    end;
    
    
    
    once ((GetLightingState("toilet light control") = ON) and ((Time < SunSet) and (Time > SunRise))) then
    begin
      SetLightingState("us31", ON);
    end;
    
    
    once (GetLightingState("toilet light control") = OFF) then
    begin
      SetLightingState("us31", OFF);
    end;
    Hope that helps.

    Cheers

    Matt
     
    mattyb, Feb 9, 2011
    #4
  5. pastorhinn

    pastorhinn

    Joined:
    Aug 4, 2006
    Messages:
    43
    Likes Received:
    0
    So simple and i was scratching my head for ages! Your code works a treat.

    Thanks heaps matt!
     
    pastorhinn, Feb 9, 2011
    #5
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.